← All changes
|
app/Modules/PaymentMethods/StripeGateway/Webhook/Webhook.php
+4
-3
1.6.4
→
1.6.5
View file →
| @@ -104,8 +104,9 @@ | ||
| 104 | 104 | |
| 105 | 105 | public function processAndInsertOrderByEvent($event) |
| 106 | 106 | { |
| 107 | 107 | $eventType = $event->type; |
| 108 | + $eventLivemode = isset($event->livemode) ? (bool)$event->livemode : null; | |
| 108 | 109 | |
| 109 | 110 | $this->unresolvedReason = ''; |
| 110 | 111 | |
| 111 | 112 | $metaDataEvents = [ |
| @@ -130,9 +131,9 @@ | ||
| 130 | 131 | |
| 131 | 132 | if ($eventType === 'setup_intent.succeeded') { |
| 132 | 133 | $setupIntentId = Arr::get((array)$vendorDataObject, 'id'); |
| 133 | 134 | if ($setupIntentId) { |
| 134 | - $result = (new Confirmations())->confirmSetupIntent($setupIntentId); | |
| 135 | + $result = (new Confirmations())->confirmSetupIntent($setupIntentId, null, StripeHelper::modeFromLivemode($eventLivemode)); | |
| 135 | 136 | if (!is_wp_error($result)) { |
| 136 | 137 | wp_send_json([ |
| 137 | 138 | 'message' => 'Setup intent confirmed successfully.', |
| 138 | 139 | ], 200); |
| @@ -147,9 +148,9 @@ | ||
| 147 | 148 | //check if subscription billing_cycle invoice paid or failed |
| 148 | 149 | $isSubscriptionCycle = $vendorDataObject->billing_reason === 'subscription_cycle'; |
| 149 | 150 | if ($isSubscriptionCycle) { |
| 150 | 151 | if ($eventType === 'invoice.paid') { |
| 151 | - $vendorDataObject = (new API())->getStripeObject('invoices/' . $vendorDataObject->id, ['expand' => ['payment_intent']]); | |
| 152 | + $vendorDataObject = (new API())->getStripeObject('invoices/' . $vendorDataObject->id, ['expand' => ['payment_intent']], StripeHelper::modeFromLivemode($eventLivemode)); | |
| 152 | 153 | $createdOrder = $this->processSubscriptionRenewal($vendorDataObject); |
| 153 | 154 | if ($createdOrder) { |
| 154 | 155 | wp_send_json([ |
| 155 | 156 | 'message' => 'Subscription renewal processed successfully. Order ID: ' . $createdOrder->id, |
| @@ -164,9 +165,9 @@ | ||
| 164 | 165 | |
| 165 | 166 | if ($eventType === 'invoice.payment_failed') { |
| 166 | 167 | $isSubscriptionCycle = $vendorDataObject->billing_reason === 'subscription_cycle'; |
| 167 | 168 | if ($isSubscriptionCycle) { |
| 168 | - $invoice = (new API())->getStripeObject('invoices/' . $vendorDataObject->id); | |
| 169 | + $invoice = (new API())->getStripeObject('invoices/' . $vendorDataObject->id, [], StripeHelper::modeFromLivemode($eventLivemode)); | |
| 169 | 170 | if (!is_wp_error($invoice)) { |
| 170 | 171 | list($subscription, $parentOrder) = $this->resolveSubscriptionAndOrder($invoice); |
| 171 | 172 | |
| 172 | 173 | if ($subscription && $parentOrder && $subscription->current_payment_method === 'stripe') { |