PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / src / PaymentGateways / Gateways / Stripe / Traits / HandlePaymentIntentStatus.php

HandlePaymentIntentStatus.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at src/PaymentGateways/Gateways/Stripe/Traits/HandlePaymentIntentStatus.php

40 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\PaymentGateways\Gateways\Stripe\Traits;
4
5 use Give\Donations\Models\Donation;
6 use Give\Framework\PaymentGateways\Commands\PaymentCommand;
7 use Give\Framework\PaymentGateways\Commands\PaymentComplete;
8 use Give\Framework\PaymentGateways\Commands\PaymentProcessing;
9 use Give\Framework\PaymentGateways\Commands\RedirectOffsite;
10 use Give\PaymentGateways\Gateways\Stripe\Exceptions\PaymentIntentException;
11 use Give\PaymentGateways\Gateways\Stripe\ValueObjects\PaymentIntent;
12
13 trait HandlePaymentIntentStatus
14 {
15 /**
16 * @since 2.27.1 Update PaymentIntentException message.
17 * @since 2.21.0 Update second argument type to Donation model
18 * @since 2.19.7 fix param order and only pass donationId
19 *
20 * @return PaymentCommand|RedirectOffsite
21 * @throws PaymentIntentException
22 */
23 public function handlePaymentIntentStatus(PaymentIntent $paymentIntent, Donation $donation)
24 {
25 switch ($paymentIntent->status()) {
26 case 'requires_action':
27 $donation->gatewayTransactionId = $paymentIntent->id();
28 $donation->save();
29 return new RedirectOffsite($paymentIntent->nextActionRedirectUrl());
30 case 'succeeded':
31 return new PaymentComplete($paymentIntent->id());
32 case 'processing':
33 return new PaymentProcessing($paymentIntent->id());
34 default:
35 throw new PaymentIntentException(
36 sprintf(__('Unhandled payment intent status: %s', 'give'), $paymentIntent->status()));
37 }
38 }
39 }
40