| 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 SquareAddon extends AbstractPaymentGateway |
| 12 |
{ |
| 13 |
public array $supportedFeatures = []; |
| 14 |
|
| 15 |
private $addonSlug = 'square-for-fluent-cart'; |
| 16 |
private $addonFile = 'square-for-fluent-cart/square-for-fluent-cart.php'; |
| 17 |
|
| 18 |
public function __construct() |
| 19 |
{ |
| 20 |
$settings = new AddonGatewaySettings('square', 'fluent_cart_payment_settings_square'); |
| 21 |
|
| 22 |
$settings->setCustomStyles([ |
| 23 |
'light' => [ |
| 24 |
'icon_bg' => '#e5e7eb', |
| 25 |
'icon_color' => '#3e4348', |
| 26 |
], |
| 27 |
'dark' => [ |
| 28 |
'icon_bg' => 'rgba(62, 67, 72, 0.2)', |
| 29 |
'icon_color' => '#9ca3af', |
| 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' => 'Square', |
| 42 |
'route' => 'square', |
| 43 |
'slug' => 'square', |
| 44 |
'description' => 'Pay securely with Square - Credit and Debit Cards, Apple Pay, Google Pay, and Cash App Pay', |
| 45 |
'logo' => Vite::getAssetUrl('images/payment-methods/square-logo.svg'), |
| 46 |
'icon' => Vite::getAssetUrl('images/payment-methods/square-logo.svg'), |
| 47 |
'brand_color' => '#3e4348', |
| 48 |
'status' => false, |
| 49 |
'is_addon' => true, |
| 50 |
'requires_pro' => true, |
| 51 |
'addon_status' => $addonStatus, |
| 52 |
'addon_source' => [ |
| 53 |
'type' => 'cdn', |
| 54 |
'link' => 'https://fluentcart.com/?fluent-cart=get_license_version', |
| 55 |
'slug' => 'square-for-fluent-cart', |
| 56 |
'repo_link' => 'https://fluentcart.com/pricing/', |
| 57 |
], |
| 58 |
]; |
| 59 |
} |
| 60 |
|
| 61 |
public function makePaymentFromPaymentInstance(PaymentInstance $paymentInstance) |
| 62 |
{ |
| 63 |
return null; |
| 64 |
} |
| 65 |
|
| 66 |
public function handleIPN() |
| 67 |
{ |
| 68 |
// not active |
| 69 |
} |
| 70 |
|
| 71 |
public function getOrderInfo(array $data) |
| 72 |
{ |
| 73 |
return null; |
| 74 |
} |
| 75 |
|
| 76 |
public function addonNoticeMessage() |
| 77 |
{ |
| 78 |
$meta = $this->meta(); |
| 79 |
|
| 80 |
$config = [ |
| 81 |
'title' => __('Square Payment Gateway', 'fluent-cart'), |
| 82 |
'description' => __('Accept payments with Square - Cards, Apple Pay, Google Pay, and Cash App Pay. Works worldwide with no redirect.', 'fluent-cart'), |
| 83 |
'features' => [ |
| 84 |
__('Inline card form - no redirect', 'fluent-cart'), |
| 85 |
__('Apple Pay & Google Pay', 'fluent-cart'), |
| 86 |
__('Recurring subscriptions', 'fluent-cart'), |
| 87 |
__('Automatic refunds via webhooks', 'fluent-cart'), |
| 88 |
], |
| 89 |
'icon_path' => 'M17,22H7c-2.8,0-5-2.2-5-5V7c0-2.8,2.2-5,5-5h10c2.8,0,5,2.2,5,5v10C22,19.7,19.8,22,17,22zM7,4C5.3,4,4,5.3,4,7v10c0,1.7,1.3,3,3,3h10c1.7,0,3-1.3,3-3V7c0-1.7-1.3-3-3-3H7z M14,9h-4c-0.6,0-1,0.4-1,1v4c0,0.6,0.4,1,1,1h4c0.6,0,1-0.4,1-1v-4C15,9.4,14.6,9,14,9z', |
| 90 |
'addon_slug' => $this->addonSlug, |
| 91 |
'addon_file' => $this->addonFile, |
| 92 |
'repo_link' => 'https://fluentcart.com/pricing/', |
| 93 |
'pro_required' => true, |
| 94 |
'addon_source' => $meta['addon_source'] ?? [], |
| 95 |
'footer_text' => __('Premium addon - requires FluentCart Pro', 'fluent-cart'), |
| 96 |
]; |
| 97 |
|
| 98 |
return $this->settings->generateAddonNotice($config); |
| 99 |
} |
| 100 |
|
| 101 |
public function fields() |
| 102 |
{ |
| 103 |
return [ |
| 104 |
'notice' => [ |
| 105 |
'value' => $this->addonNoticeMessage(), |
| 106 |
'label' => __('Square Payment Gateway', 'fluent-cart'), |
| 107 |
'type' => 'html_attr', |
| 108 |
], |
| 109 |
]; |
| 110 |
} |
| 111 |
} |
| 112 |
|