PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.6
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.6
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
← All changes | app/Modules/PaymentMethods/StripeGateway/StripeSettingsBase.php +33 -0 1.3.21 → 1.6.6 View file →
@@ -4,12 +4,19 @@
4 4
5 5 use FluentCart\Api\StoreSettings;
6 6 use FluentCart\App\Helpers\Helper;
7 7 use FluentCart\App\Modules\PaymentMethods\Core\BaseGatewaySettings;
8 +use FluentCart\Framework\Support\Arr;
8 9
9 10 class StripeSettingsBase extends BaseGatewaySettings
10 11 {
11 12
13 + /**
14 + * Checkout Session submit_type values Stripe accepts. 'auto' is our stored
15 + * spelling for "send nothing" — Stripe then picks pay/subscribe from the mode.
16 + */
17 + const SUBMIT_TYPES = ['auto', 'pay', 'book', 'donate', 'subscribe'];
18 +
12 19 public $settings;
13 20
14 21 public $methodHandler = 'fluent_cart_payment_settings_stripe';
15 22
@@ -59,8 +66,9 @@
59 66 'live_webhook_secret' => '',
60 67 // Others
61 68 'payment_mode' => 'live',
62 69 'checkout_mode' => 'onsite',
70 + 'submit_type' => 'auto',
63 71 'live_is_encrypted' => 'no',
64 72 'test_is_encrypted' => 'no',
65 73 'secure' => 'yes'
66 74 ];
@@ -85,8 +93,14 @@
85 93 {
86 94 $defaults = static::getDefaults();
87 95 $settings = wp_parse_args($settings, $defaults);
88 96
97 + // Goes straight onto the wire as a Checkout Session parameter, and the
98 + // controller hands this method the request body unfiltered.
99 + if (!in_array(Arr::get($settings, 'submit_type'), self::SUBMIT_TYPES, true)) {
100 + $settings['submit_type'] = 'auto';
101 + }
102 +
89 103 if (defined('FCT_STRIPE_LIVE_PUBLIC_KEY')) {
90 104 $settings['live_publishable_key'] = '';
91 105 }
92 106
@@ -104,8 +118,27 @@
104 118
105 119 fluent_cart_update_option($this->methodHandler, $settings);
106 120
107 121 return $settings;
122 + }
123 +
124 + /**
125 + * The Checkout Session submit_type to send, or null to let Stripe decide.
126 + *
127 + * Re-validated on read: `fluent_cart/stripe_settings` can rewrite the stored
128 + * value, and an unknown one is a 400 from Stripe on a live checkout.
129 + *
130 + * @return string|null
131 + */
132 + public function getSubmitType()
133 + {
134 + $submitType = Arr::get($this->settings, 'submit_type', 'auto');
135 +
136 + if ($submitType === 'auto' || !in_array($submitType, self::SUBMIT_TYPES, true)) {
137 + return null;
138 + }
139 +
140 + return $submitType;
108 141 }
109 142
110 143 public function getMode()
111 144 {