| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | use Give\PaymentGateways\Gateways\Offline\Actions\DisableGatewayWhenDisabledPerForm; |
| 12 | 12 | use Give\PaymentGateways\Gateways\Offline\Actions\EnqueueOfflineFormBuilderScripts; |
| 13 | 13 | use Give\PaymentGateways\Gateways\Offline\Actions\UpdateOfflineMetaFromFormBuilder; |
| 14 | 14 | use Give\PaymentGateways\Gateways\PayPalCommerce\PayPalCommerceGateway; |
| 15 | +use Give\PaymentGateways\Gateways\Stripe\Actions\AddExtraMetadataToPaymentIntent; | |
| 15 | 16 | use Give\PaymentGateways\Gateways\Stripe\LegacyStripeAdapter; |
| 16 | 17 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Actions\AddStripeAttributesToNewForms; |
| 17 | 18 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Actions\EnqueueStripeFormBuilderScripts; |
| 18 | 19 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Actions\UpdateStripeFormBuilderSettingsMeta; |
| @@ -19,8 +20,10 @@ | ||
| 19 | 20 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\StripePaymentElementGateway; |
| 20 | 21 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\ChargeRefunded; |
| 21 | 22 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\CustomerSubscriptionCreated; |
| 22 | 23 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\CustomerSubscriptionDeleted; |
| 24 | +use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\CustomerSubscriptionResumed; | |
| 25 | +use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\CustomerSubscriptionUpdated; | |
| 23 | 26 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\InvoicePaymentFailed; |
| 24 | 27 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\InvoicePaymentSucceeded; |
| 25 | 28 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\PaymentIntentPaymentFailed; |
| 26 | 29 | use Give\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Webhooks\Listeners\PaymentIntentSucceeded; |
| @@ -54,8 +57,9 @@ | ||
| 54 | 57 | } |
| 55 | 58 | } |
| 56 | 59 | |
| 57 | 60 | /** |
| 61 | + * @since 4.16.8 register TestOffsiteGateway when GIVEWP_ENABLE_TEST_OFFSITE_GATEWAY is set | |
| 58 | 62 | * @since 3.0.0 |
| 59 | 63 | * |
| 60 | 64 | * @throws Exception |
| 61 | 65 | * @throws OverflowException |
| @@ -62,10 +66,13 @@ | ||
| 62 | 66 | */ |
| 63 | 67 | private function registerGateways() |
| 64 | 68 | { |
| 65 | 69 | add_action('givewp_register_payment_gateway', static function (PaymentGatewayRegister $registrar) { |
| 66 | - // Enable as needed for testing but do not push to production | |
| 67 | - // $registrar->registerGateway(TestOffsiteGateway::class); | |
| 70 | + // Not for production: it completes donations without charging anyone. The e2e suite turns it | |
| 71 | + // on through .wp-env.json to walk an offsite redirect end to end. | |
| 72 | + if (defined('GIVEWP_ENABLE_TEST_OFFSITE_GATEWAY') && GIVEWP_ENABLE_TEST_OFFSITE_GATEWAY) { | |
| 73 | + $registrar->registerGateway(TestOffsiteGateway::class); | |
| 74 | + } | |
| 68 | 75 | |
| 69 | 76 | $registrar->registerGateway(StripePaymentElementGateway::class); |
| 70 | 77 | |
| 71 | 78 | $registrar->registerGateway(PayPalCommerceGateway::class); |
| @@ -73,12 +80,21 @@ | ||
| 73 | 80 | |
| 74 | 81 | $this->addLegacyStripeAdapter(); |
| 75 | 82 | $this->addStripeWebhookListeners(); |
| 76 | 83 | $this->addStripeFormBuilderHooks(); |
| 84 | + $this->addStripeTransactionMetadata(); | |
| 77 | 85 | $this->bootOfflineDonations(); |
| 78 | 86 | } |
| 79 | 87 | |
| 80 | 88 | /** |
| 89 | + * @since 4.16.7 | |
| 90 | + */ | |
| 91 | + private function addStripeTransactionMetadata() | |
| 92 | + { | |
| 93 | + Hooks::addFilter('give_stripe_prepare_metadata', AddExtraMetadataToPaymentIntent::class, '__invoke', 10, 2); | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 81 | 97 | * @since 3.0.0 |
| 82 | 98 | */ |
| 83 | 99 | private function addStripeWebhookListeners() |
| 84 | 100 | { |
| @@ -114,8 +130,18 @@ | ||
| 114 | 130 | |
| 115 | 131 | Hooks::addAction( |
| 116 | 132 | 'give_recurring_stripe_processing_customer_subscription_deleted', |
| 117 | 133 | CustomerSubscriptionDeleted::class |
| 134 | + ); | |
| 135 | + | |
| 136 | + Hooks::addAction( | |
| 137 | + 'give_recurring_stripe_processing_customer_subscription_updated', | |
| 138 | + CustomerSubscriptionUpdated::class | |
| 139 | + ); | |
| 140 | + | |
| 141 | + Hooks::addAction( | |
| 142 | + 'give_recurring_stripe_processing_customer_subscription_resumed', | |
| 143 | + CustomerSubscriptionResumed::class | |
| 118 | 144 | ); |
| 119 | 145 | } |
| 120 | 146 | |
| 121 | 147 | /** |