PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.0
GiveWP – Donation Plugin and Fundraising Platform v4.15.0
4.18.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 All 257 releases
give / src / PaymentGateways / Gateways / Stripe / StripePaymentElementGateway / DataTransferObjects / StripePaymentIntentData.php

StripePaymentIntentData.php in GiveWP – Donation Plugin and Fundraising Platform 4.15.0, at src/PaymentGateways/Gateways/Stripe/StripePaymentElementGateway/DataTransferObjects/StripePaymentIntentData.php

101 lines 2.8 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\StripePaymentElementGateway\DataTransferObjects;
4
5 class StripePaymentIntentData
6 {
7 /**
8 * @var string
9 */
10 public $amount;
11 /**
12 * @var string
13 */
14 public $currency;
15 /**
16 * @var string
17 */
18 public $customer;
19 /**
20 * @var string
21 */
22 public $description;
23 /**
24 * @var array
25 */
26 public $metadata;
27 /**
28 * @var array|null
29 *
30 */
31 public $automaticPaymentMethods;
32 /**
33 * @var string|null
34 */
35 public $applicationFeeAmount;
36 /**
37 * @var string|null
38 */
39 public $receiptEmail;
40
41 /**
42 * @since 3.20.0 removed statement_descriptor. As of 01/02/2024, Stripe no longer supports the `statement_descriptor` parameter on the PaymentIntent API for PaymentIntents in which one of the supported `payment_method_types` is `card`.
43 * @since 3.0.0
44 *
45 * @param array{amount: string, currency: string, customer: string, description: string, metadata: array, automatic_payment_methods: array, application_fee_amount: string, receipt_email: string } $array
46 */
47 public static function fromArray(array $array): self
48 {
49 $self = new self();
50 $self->amount = $array['amount'];
51 $self->currency = $array['currency'];
52 $self->customer = $array['customer'];
53 $self->description = $array['description'];
54 $self->metadata = $array['metadata'];
55 $self->automaticPaymentMethods = !empty($array['automatic_payment_methods']) ? $array['automatic_payment_methods'] : null;
56 $self->applicationFeeAmount = !empty($array['application_fee_amount']) ? $array['application_fee_amount'] : null;
57 $self->receiptEmail = !empty($array['receipt_email']) ? $array['receipt_email'] : null;
58
59 return $self;
60 }
61
62 /**
63 * @since 3.0.0
64 */
65 public function toParams()
66 {
67 $args = [
68 'amount' => $this->amount,
69 'currency' => $this->currency,
70 'customer' => $this->customer,
71 'description' => $this->description,
72 'metadata' => $this->metadata
73 ];
74
75 if ($this->automaticPaymentMethods){
76 $args['automatic_payment_methods'] = $this->automaticPaymentMethods;
77 }
78
79 if ($this->applicationFeeAmount){
80 $args['application_fee_amount'] = $this->applicationFeeAmount;
81 }
82
83 if ($this->receiptEmail){
84 $args['receipt_email'] = $this->receiptEmail;
85 }
86
87 return apply_filters(
88 'givewp_stripe_create_intent_args',
89 $args
90 );
91 }
92
93 /**
94 * @since 3.0.0
95 */
96 public function toOptions(string $stripeConnectAccountId): array
97 {
98 return ['stripe_account' => $stripeConnectAccountId];
99 }
100 }
101