CreateCheckoutSession.php
4 years ago
CreatePaymentIntent.php
4 years ago
GetOrCreateStripeCustomer.php
4 years ago
GetPaymentMethodFromRequest.php
4 years ago
SaveDonationSummary.php
4 years ago
UpdateStripeAccountStatementDescriptor.php
4 years ago
ValidatePaymentMethod.php
4 years ago
GetPaymentMethodFromRequest.php
33 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Gateways\Stripe\Actions; |
| 4 | |
| 5 | use Give\PaymentGateways\DataTransferObjects\GatewayPaymentData; |
| 6 | use Give\PaymentGateways\Gateways\Stripe\Exceptions\PaymentMethodException; |
| 7 | use Give\PaymentGateways\Gateways\Stripe\ValueObjects\PaymentMethod; |
| 8 | |
| 9 | class GetPaymentMethodFromRequest |
| 10 | { |
| 11 | /** |
| 12 | * @since 2.19.0 |
| 13 | * @param GatewayPaymentData $paymentData |
| 14 | * @throws PaymentMethodException |
| 15 | * @return PaymentMethod $paymentMethod |
| 16 | */ |
| 17 | public function __invoke( GatewayPaymentData $paymentData ) |
| 18 | { |
| 19 | if( ! isset( $_POST['give_stripe_payment_method'] ) ) { |
| 20 | throw new PaymentMethodException('Payment Method Not Found'); |
| 21 | } |
| 22 | |
| 23 | $paymentMethod = new PaymentMethod( |
| 24 | give_clean( $_POST['give_stripe_payment_method'] ) |
| 25 | ); |
| 26 | |
| 27 | give_update_meta($paymentData->donationId, '_give_stripe_source_id', $paymentMethod->id()); |
| 28 | give_insert_payment_note($paymentData->donationId, sprintf(__('Stripe Source/Payment Method ID: %s', 'give'), $paymentMethod->id())); |
| 29 | |
| 30 | return $paymentMethod; |
| 31 | } |
| 32 | } |
| 33 |