PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.5
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/StripeSubscriptions.php +6 -10 1.6.2 → 1.6.5 View file →
@@ -112,8 +112,11 @@
112 112 ->where('transaction_type', 'charge')
113 113 ->first();
114 114
115 115 if (!$transaction) {
116 + $chargeCurrency = Arr::get($invoice, 'currency');
117 + $amountPaid = StripeHelper::toInternalAmount(Arr::get($invoice, 'amount_paid'), $chargeCurrency);
118 +
116 119 // check local transactions missing vendor_charge_id
117 120 $transaction = OrderTransaction::query()
118 121 ->select(['id', 'order_id'])
119 122 ->where('subscription_id', $subscriptionModel->id)
@@ -118,9 +121,9 @@
118 121 ->select(['id', 'order_id'])
119 122 ->where('subscription_id', $subscriptionModel->id)
120 123 ->where('vendor_charge_id', '')
121 124 ->where('transaction_type', 'charge')
122 - ->where('total', (int)Arr::get($invoice, 'amount_paid'))
125 + ->where('total', $amountPaid)
123 126 ->first();
124 127
125 128 if ($transaction) {
126 129 $transaction->update([
@@ -128,15 +131,8 @@
128 131 ]);
129 132 continue;
130 133 }
131 134
132 - $amountPaid = Arr::get($invoice, 'amount_paid');
133 - $chargeCurrency = Arr::get($invoice, 'currency');
134 -
135 - if ($chargeCurrency && CurrenciesHelper::isZeroDecimal($chargeCurrency)) {
136 - $amountPaid = $amountPaid * 100;
137 - }
138 -
139 135 $transactionData = [
140 136 'payment_method' => 'stripe',
141 137 'total' => (int)$amountPaid,
142 138 'vendor_charge_id' => Arr::get($invoice, 'payment_intent'),
@@ -188,9 +184,9 @@
188 184
189 185 $transaction->update([
190 186 'vendor_charge_id' => Arr::get($invoice, 'payment_intent'),
191 187 'status' => Status::TRANSACTION_SUCCEEDED,
192 - 'total' => (int)Arr::get($invoice, 'amount_paid')
188 + 'total' => StripeHelper::toInternalAmount(Arr::get($invoice, 'amount_paid'), Arr::get($invoice, 'currency'))
193 189 ]);
194 190
195 191 (new StatusHelper($transaction->order))->syncOrderStatuses($transaction);
196 192 }
@@ -276,9 +272,9 @@
276 272 return new \WP_Error('invalid_subscription', __('Invalid vendor subscription ID.', 'fluent-cart'));
277 273 }
278 274
279 275 // first check if the subscription is already canceled in Stripe
280 - $response = (new API())->getStripeObject('subscriptions/' . $vendorSubscriptionId, [], Arr::get($args, 'mode', 'live'));
276 + $response = (new API())->getStripeObject('subscriptions/' . $vendorSubscriptionId, [], Arr::get($args, 'mode', 'current'));
281 277
282 278 if (is_wp_error($response)) {
283 279 return $response;
284 280 }