| 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 FlutterwaveAddon extends AbstractPaymentGateway |
| 12 |
{ |
| 13 |
public array $supportedFeatures = []; |
| 14 |
|
| 15 |
private $addonSlug = 'flutterwave-for-fluent-cart'; |
| 16 |
private $addonFile = 'flutterwave-for-fluent-cart/flutterwave-for-fluent-cart.php'; |
| 17 |
|
| 18 |
public function __construct() |
| 19 |
{ |
| 20 |
$settings = new AddonGatewaySettings('flutterwave'); |
| 21 |
|
| 22 |
$settings->setCustomStyles([ |
| 23 |
'light' => [ |
| 24 |
'icon_bg' => '#fff7ed', |
| 25 |
'icon_color' => '#F5A623' |
| 26 |
], |
| 27 |
'dark' => [ |
| 28 |
'icon_bg' => 'rgba(245, 166, 35, 0.15)', |
| 29 |
'icon_color' => '#fbbf24' |
| 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' => 'Flutterwave', |
| 42 |
'route' => 'flutterwave', |
| 43 |
'slug' => 'flutterwave', |
| 44 |
'description' => __('Pay securely with Flutterwave - Card, Bank Transfer, Mobile Money, and more', 'fluent-cart'), |
| 45 |
'logo' => Vite::getAssetUrl("images/payment-methods/flutterwave-logo.svg"), |
| 46 |
'logo_light' => Vite::getAssetUrl("images/payment-methods/flutterwave-logo-light.svg"), |
| 47 |
'icon' => Vite::getAssetUrl("images/payment-methods/flutterwave-logo.svg"), |
| 48 |
'brand_color' => '#F5A623', |
| 49 |
'status' => false, |
| 50 |
'is_addon' => true, |
| 51 |
'addon_status' => $addonStatus, |
| 52 |
'addon_source' => [ |
| 53 |
'type' => 'cdn', |
| 54 |
'link' => 'https://addons-cdn.fluentcart.com/flutterwave-for-fluent-cart.zip', |
| 55 |
'slug' => 'flutterwave-for-fluent-cart', |
| 56 |
'repo_link' => 'https://fluentcart.com/fluentcart-addons' |
| 57 |
] |
| 58 |
]; |
| 59 |
} |
| 60 |
|
| 61 |
public function makePaymentFromPaymentInstance(PaymentInstance $paymentInstance) |
| 62 |
{ |
| 63 |
// This will not be called since the gateway is not active |
| 64 |
return null; |
| 65 |
} |
| 66 |
|
| 67 |
public function handleIPN() |
| 68 |
{ |
| 69 |
// This will not be called since the gateway is not active |
| 70 |
} |
| 71 |
|
| 72 |
public function getOrderInfo(array $data) |
| 73 |
{ |
| 74 |
// This will not be called since the gateway is not active |
| 75 |
return null; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Get Flutterwave-specific notice configuration |
| 80 |
*/ |
| 81 |
private function getNoticeConfig() |
| 82 |
{ |
| 83 |
$meta = $this->meta(); |
| 84 |
|
| 85 |
return [ |
| 86 |
'title' => __('Flutterwave Payment Gateway', 'fluent-cart'), |
| 87 |
'description' => __('Accept payments with Flutterwave - Card, Bank Transfer, Mobile Money, USSD, M-Pesa and more. Perfect for businesses in Africa.', 'fluent-cart'), |
| 88 |
'features' => [ |
| 89 |
__('Card payments & Bank transfers', 'fluent-cart'), |
| 90 |
__('Mobile Money, USSD & M-Pesa', 'fluent-cart'), |
| 91 |
__('Free & Open Source addon', 'fluent-cart') |
| 92 |
], |
| 93 |
'icon_path' => 'M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.31-8.86c-1.77-.45-2.34-.94-2.34-1.67 0-.84.79-1.43 2.1-1.43 1.38 0 1.9.66 1.94 1.64h1.71c-.05-1.34-.87-2.57-2.49-2.97V5H10.9v1.69c-1.51.32-2.72 1.3-2.72 2.81 0 1.79 1.49 2.69 3.66 3.21 1.95.46 2.34 1.15 2.34 1.87 0 .53-.39 1.39-2.1 1.39-1.6 0-2.23-.72-2.32-1.64H8.04c.1 1.7 1.36 2.66 2.86 2.97V19h2.34v-1.67c1.52-.29 2.72-1.16 2.73-2.77-.01-2.2-1.9-2.96-3.66-3.42z', |
| 94 |
'addon_slug' => $this->addonSlug, |
| 95 |
'addon_file' => $this->addonFile, |
| 96 |
'repo_link' => 'https://fluentcart.com/fluentcart-addons', |
| 97 |
'addon_source' => $meta['addon_source'] ?? [], |
| 98 |
'footer_text' => __('Free addon - Click the button above to get started', 'fluent-cart') |
| 99 |
]; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Generate addon notice message |
| 104 |
*/ |
| 105 |
public function addonNoticeMessage() |
| 106 |
{ |
| 107 |
return $this->settings->generateAddonNotice($this->getNoticeConfig()); |
| 108 |
} |
| 109 |
|
| 110 |
public function fields() |
| 111 |
{ |
| 112 |
return [ |
| 113 |
'notice' => [ |
| 114 |
'value' => $this->addonNoticeMessage(), |
| 115 |
'label' => __('Flutterwave Payment Gateway', 'fluent-cart'), |
| 116 |
'type' => 'html_attr' |
| 117 |
], |
| 118 |
]; |
| 119 |
} |
| 120 |
} |
| 121 |
|