Actions
4 years ago
Controllers
4 years ago
Exceptions
4 years ago
Helpers
4 years ago
Migrations
4 years ago
Traits
4 years ago
ValueObjects
4 years ago
BECSGateway.php
4 years ago
CheckoutGateway.php
4 years ago
CreditCardGateway.php
4 years ago
SEPAGateway.php
4 years ago
Workflow.php
4 years ago
WorkflowAction.php
4 years ago
CreditCardGateway.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Gateways\Stripe; |
| 4 | |
| 5 | use Give\Framework\PaymentGateways\Commands\GatewayCommand; |
| 6 | use Give\Framework\PaymentGateways\Contracts\SubscriptionModuleInterface; |
| 7 | use Give\Framework\PaymentGateways\Exceptions\PaymentGatewayException; |
| 8 | use Give\Framework\PaymentGateways\PaymentGateway; |
| 9 | use Give\Helpers\Form\Utils as FormUtils; |
| 10 | use Give\PaymentGateways\DataTransferObjects\GatewayPaymentData; |
| 11 | use Give\PaymentGateways\Gateways\Stripe\ValueObjects\PaymentIntent; |
| 12 | |
| 13 | /** |
| 14 | * @since 2.19.0 |
| 15 | */ |
| 16 | class CreditCardGateway extends PaymentGateway |
| 17 | { |
| 18 | use Traits\CreditCardForm; |
| 19 | use Traits\HandlePaymentIntentStatus; |
| 20 | |
| 21 | /** @var array */ |
| 22 | protected $errorMessages = []; |
| 23 | |
| 24 | public function __construct(SubscriptionModuleInterface $subscriptionModule = null) |
| 25 | { |
| 26 | parent::__construct($subscriptionModule); |
| 27 | |
| 28 | $this->errorMessages['accountConfiguredNoSsl'] = esc_html__( 'Credit Card fields are disabled because your site is not running securely over HTTPS.', 'give' ); |
| 29 | $this->errorMessages['accountNotConfiguredNoSsl'] = esc_html__( 'Credit Card fields are disabled because Stripe is not connected and your site is not running securely over HTTPS.', 'give' ); |
| 30 | $this->errorMessages['accountNotConfigured'] = esc_html__( 'Credit Card fields are disabled. Please connect and configure your Stripe account to accept donations.', 'give' ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * @inheritDoc |
| 35 | * @since 2.19.0 |
| 36 | * @return GatewayCommand |
| 37 | * @throws PaymentGatewayException |
| 38 | */ |
| 39 | public function createPayment( GatewayPaymentData $paymentData ) |
| 40 | { |
| 41 | $workflow = new Workflow(); |
| 42 | $workflow->bind( $paymentData ); |
| 43 | |
| 44 | $workflow->action( new Actions\GetPaymentMethodFromRequest ); |
| 45 | $workflow->action( new Actions\SaveDonationSummary ); |
| 46 | $workflow->action( new Actions\GetOrCreateStripeCustomer ); |
| 47 | $workflow->action( new Actions\CreatePaymentIntent ); |
| 48 | |
| 49 | return $this->handlePaymentIntentStatus( |
| 50 | $workflow->resolve( PaymentIntent::class ) |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @inheritDoc |
| 56 | */ |
| 57 | public static function id() |
| 58 | { |
| 59 | return 'stripe'; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * @inheritDoc |
| 64 | */ |
| 65 | public function getId() |
| 66 | { |
| 67 | return self::id(); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @inheritDoc |
| 72 | */ |
| 73 | public function getName() |
| 74 | { |
| 75 | return __('Stripe - Credit Card', 'give'); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * @inheritDoc |
| 80 | */ |
| 81 | public function getPaymentMethodLabel() |
| 82 | { |
| 83 | return __('Stripe - Credit Card', 'give'); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * @inheritDoc |
| 88 | */ |
| 89 | public function getLegacyFormFieldMarkup($formId, $args) |
| 90 | { |
| 91 | return $this->getCreditCardFormHTML( $formId, $args ); |
| 92 | } |
| 93 | } |
| 94 |