PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
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 2.30.0 All 255 releases
← All changes | src/Framework/PaymentGateways/Controllers/GatewaySubscriptionController.php +18 -4 2.30.04.16.9 View file →
@@ -6,8 +6,9 @@
6 6 use Give\Framework\Exceptions\Primitives\Exception;
7 7 use Give\Framework\FieldsAPI\Exceptions\TypeNotSupported;
8 8 use Give\Framework\PaymentGateways\Actions\HandleGatewaySubscriptionCommand;
9 9 use Give\Framework\PaymentGateways\Commands\GatewayCommand;
10 +use Give\Framework\PaymentGateways\Exceptions\PaymentGatewayException;
10 11 use Give\Framework\PaymentGateways\Log\PaymentGatewayLog;
11 12 use Give\Framework\PaymentGateways\PaymentGateway;
12 13 use Give\Framework\PaymentGateways\Traits\HandleHttpResponses;
13 14 use Give\Subscriptions\Models\Subscription;
@@ -32,27 +33,40 @@
32 33 $this->gateway = $gateway;
33 34 }
34 35
35 36 /**
37 + * @since 3.0.0 Catch and handle errors from the gateway upstream
36 38 * @since 2.27.0
39 + *
40 + * @throws Exception|TypeNotSupported|PaymentGatewayException
37 41 */
38 42 public function create(Donation $donation, Subscription $subscription, array $gatewayData = [])
39 43 {
44 + $command = $this->gateway->createSubscription($donation, $subscription, $gatewayData);
45 +
46 + $this->handleGatewayCommand($command, $donation, $subscription);
47 + }
48 +
49 + /**
50 + * @since 2.33.0
51 + */
52 + public function synchronizeSubscription(Subscription $subscription)
53 + {
40 54 try {
41 - $command = $this->gateway->createSubscription($donation, $subscription, $gatewayData);
42 - $this->handleGatewayCommand($command, $donation, $subscription);
55 + $command = $this->gateway->synchronizeSubscription($subscription);
56 + $this->handleGatewayCommand($command, $subscription->initialDonation(), $subscription);
43 57 } catch (\Exception $exception) {
44 58 PaymentGatewayLog::error(
45 59 $exception->getMessage(),
46 60 [
47 61 'Payment Gateway' => $this->gateway::id(),
48 - 'Donation' => $donation->toArray(),
62 + 'Donation' => $subscription->initialDonation()->toArray(),
49 63 'Subscription' => $subscription->toArray(),
50 64 ]
51 65 );
52 66
53 67 $message = __(
54 - 'An unexpected error occurred while processing the subscription. Please try again or contact the site administrator.',
68 + 'An unexpected error occurred while synchronizing the subscription. Please try again or contact the site administrator.',
55 69 'give'
56 70 );
57 71
58 72 $this->handleExceptionResponse($exception, $message);