| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons; |
| 4 |
|
| 5 |
use FluentCart\App\Modules\PaymentMethods\Core\AbstractPaymentGateway; |
| 6 |
use FluentCart\App\Modules\PaymentMethods\PromoGateways\Addons\AddonGatewaySettings; |
| 7 |
use FluentCart\App\Services\Payments\PaymentInstance; |
| 8 |
use FluentCart\App\Services\PluginInstaller\PaymentAddonManager; |
| 9 |
use FluentCart\App\Vite; |
| 10 |
|
| 11 |
class RazorpayAddon extends AbstractPaymentGateway |
| 12 |
{ |
| 13 |
public array $supportedFeatures = []; |
| 14 |
|
| 15 |
private $addonSlug = 'razorpay-for-fluent-cart'; |
| 16 |
private $addonFile = 'razorpay-for-fluent-cart/razorpay-for-fluent-cart.php'; |
| 17 |
|
| 18 |
public function __construct() |
| 19 |
{ |
| 20 |
$settings = new AddonGatewaySettings('razorpay', 'fluent_cart_payment_settings_razorpay'); |
| 21 |
|
| 22 |
$settings->setCustomStyles([ |
| 23 |
'light' => [ |
| 24 |
'icon_bg' => '#dcfce7', |
| 25 |
'icon_color' => '#16a34a' |
| 26 |
], |
| 27 |
'dark' => [ |
| 28 |
'icon_bg' => 'rgba(34, 197, 94, 0.15)', |
| 29 |
'icon_color' => '#4ade80' |
| 30 |
] |
| 31 |
]); |
| 32 |
|
| 33 |
parent::__construct($settings); |
| 34 |
} |
| 35 |
|
| 36 |
public function meta(): array |
| 37 |
{ |
| 38 |
$addonStatus = PaymentAddonManager::getAddonStatus($this->addonSlug, $this->addonFile); |
| 39 |
|
| 40 |
return [ |
| 41 |
'title' => 'Razorpay', |
| 42 |
'route' => 'razorpay', |
| 43 |
'slug' => 'razorpay', |
| 44 |
'description' => __('Pay securely with Razorpay - UPI, Cards, NetBanking, and Wallets', 'fluent-cart'), |
| 45 |
'logo' => Vite::getAssetUrl("images/payment-methods/razorpay-logo.svg"), |
| 46 |
'icon' => Vite::getAssetUrl("images/payment-methods/razorpay-logo.svg"), |
| 47 |
'brand_color' => '#0fa958', |
| 48 |
'status' => false, |
| 49 |
'is_addon' => true, |
| 50 |
'addon_status' => $addonStatus, |
| 51 |
'addon_source' => [ |
| 52 |
'type' => 'cdn', |
| 53 |
'link' => 'https://addons-cdn.fluentcart.com/razorpay-for-fluent-cart.zip', |
| 54 |
'slug' => 'razorpay-for-fluent-cart', |
| 55 |
'repo_link' => 'https://fluentcart.com/fluentcart-addons' |
| 56 |
] |
| 57 |
]; |
| 58 |
} |
| 59 |
|
| 60 |
public function makePaymentFromPaymentInstance(PaymentInstance $paymentInstance) |
| 61 |
{ |
| 62 |
// This will not be called since the gateway is not active |
| 63 |
return null; |
| 64 |
} |
| 65 |
|
| 66 |
public function handleIPN() |
| 67 |
{ |
| 68 |
// This will not be called since the gateway is not active |
| 69 |
} |
| 70 |
|
| 71 |
public function getOrderInfo(array $data) |
| 72 |
{ |
| 73 |
// This will not be called since the gateway is not active |
| 74 |
return null; |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Get Razorpay-specific notice configuration |
| 79 |
*/ |
| 80 |
private function getNoticeConfig() |
| 81 |
{ |
| 82 |
$meta = $this->meta(); |
| 83 |
|
| 84 |
return [ |
| 85 |
'title' => __('Razorpay Payment Gateway', 'fluent-cart'), |
| 86 |
'description' => __('Accept payments with Razorpay - UPI, Cards, NetBanking, and Wallets. Perfect for businesses in India.', 'fluent-cart'), |
| 87 |
'features' => [ |
| 88 |
__('UPI, Cards, NetBanking, and Wallets', 'fluent-cart'), |
| 89 |
__('Free & Open Source addon.', 'fluent-cart'), |
| 90 |
], |
| 91 |
'icon_path' => 'M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zM9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9V6zm9 14H6V10h12v10zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z', |
| 92 |
'addon_slug' => $this->addonSlug, |
| 93 |
'addon_file' => $this->addonFile, |
| 94 |
'repo_link' => 'https://fluentcart.com/fluentcart-addons', |
| 95 |
'addon_source' => $meta['addon_source'] ?? [], |
| 96 |
'footer_text' => __('Free addon - Click the button above to get started', 'fluent-cart') |
| 97 |
]; |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* Generate addon notice message |
| 102 |
*/ |
| 103 |
public function addonNoticeMessage() |
| 104 |
{ |
| 105 |
return $this->settings->generateAddonNotice($this->getNoticeConfig()); |
| 106 |
} |
| 107 |
|
| 108 |
public function fields() |
| 109 |
{ |
| 110 |
return [ |
| 111 |
'notice' => [ |
| 112 |
'value' => $this->addonNoticeMessage(), |
| 113 |
'label' => __('Razorpay Payment Gateway', 'fluent-cart'), |
| 114 |
'type' => 'html_attr' |
| 115 |
], |
| 116 |
]; |
| 117 |
} |
| 118 |
} |
| 119 |
|