FormData.php
4 years ago
GatewayPaymentData.php
4 years ago
GatewaySubscriptionData.php
4 years ago
GiveInsertPaymentData.php
4 years ago
SubscriptionData.php
4 years ago
GiveInsertPaymentData.php
103 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\DataTransferObjects; |
| 4 | |
| 5 | /** |
| 6 | * Class GiveInsertPaymentData |
| 7 | * |
| 8 | * This is used to expose data for use with give_insert_payment |
| 9 | * |
| 10 | * @since 2.18.0 |
| 11 | */ |
| 12 | class GiveInsertPaymentData |
| 13 | { |
| 14 | /** |
| 15 | * @var float |
| 16 | */ |
| 17 | public $price; |
| 18 | /** |
| 19 | * @var string |
| 20 | */ |
| 21 | public $priceId; |
| 22 | /** |
| 23 | * @var string |
| 24 | */ |
| 25 | public $date; |
| 26 | /** |
| 27 | * @var string |
| 28 | */ |
| 29 | public $purchaseKey; |
| 30 | /** |
| 31 | * @var string |
| 32 | */ |
| 33 | public $currency; |
| 34 | /** |
| 35 | * @var string |
| 36 | */ |
| 37 | public $amount; |
| 38 | /** |
| 39 | * @var string |
| 40 | */ |
| 41 | public $formTitle; |
| 42 | /** |
| 43 | * @var int |
| 44 | */ |
| 45 | public $formId; |
| 46 | /** |
| 47 | * @var array |
| 48 | */ |
| 49 | public $userInfo; |
| 50 | /** |
| 51 | * @var string |
| 52 | */ |
| 53 | public $donorEmail; |
| 54 | /** |
| 55 | * @var string |
| 56 | */ |
| 57 | public $paymentGateway; |
| 58 | |
| 59 | /** |
| 60 | * Convert data from array into DTO |
| 61 | * |
| 62 | * @since 2.18.0 |
| 63 | * |
| 64 | * @return self |
| 65 | */ |
| 66 | public static function fromArray(array $array) |
| 67 | { |
| 68 | $self = new static(); |
| 69 | |
| 70 | $self->price = $array['price']; |
| 71 | $self->priceId = $array['priceId']; |
| 72 | $self->formTitle = $array['formTitle']; |
| 73 | $self->formId = $array['formId']; |
| 74 | $self->currency = $array['currency']; |
| 75 | $self->date = $array['date']; |
| 76 | $self->purchaseKey = $array['purchaseKey']; |
| 77 | $self->donorEmail = $array['donorEmail']; |
| 78 | $self->userInfo = $array['userInfo']; |
| 79 | $self->paymentGateway = $array['paymentGateway']; |
| 80 | |
| 81 | return $self; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @return array |
| 86 | */ |
| 87 | public function toArray() |
| 88 | { |
| 89 | return [ |
| 90 | 'price' => $this->price, |
| 91 | 'give_form_title' => $this->formTitle, |
| 92 | 'give_form_id' => $this->formId, |
| 93 | 'give_price_id' => $this->priceId, |
| 94 | 'date' => $this->date, |
| 95 | 'user_email' => $this->donorEmail, |
| 96 | 'purchase_key' => $this->purchaseKey, |
| 97 | 'currency' => $this->currency, |
| 98 | 'user_info' => $this->userInfo, |
| 99 | 'status' => 'pending', |
| 100 | ]; |
| 101 | } |
| 102 | } |
| 103 |