CreatePaymentAction.php
4 years ago
CreateSubscriptionAction.php
4 years ago
GetGatewayDataFromRequest.php
3 years ago
RegisterPaymentGateways.php
3 years ago
CreatePaymentAction.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\PaymentGateways\Actions; |
| 4 | |
| 5 | use Give\Log\Log; |
| 6 | use Give\PaymentGateways\DataTransferObjects\GiveInsertPaymentData; |
| 7 | |
| 8 | /** |
| 9 | * Class CreatePaymentAction |
| 10 | * @since 2.18.0 |
| 11 | */ |
| 12 | class CreatePaymentAction |
| 13 | { |
| 14 | /** |
| 15 | * @since 2.18.0 |
| 16 | * |
| 17 | * @param GiveInsertPaymentData $giveInsertPaymentData |
| 18 | * |
| 19 | * @return bool|int |
| 20 | */ |
| 21 | public function __invoke(GiveInsertPaymentData $giveInsertPaymentData) |
| 22 | { |
| 23 | // Record the pending payment |
| 24 | $payment = give_insert_payment($giveInsertPaymentData->toArray()); |
| 25 | |
| 26 | // If errors are present, send the user back to the donation page, so they can be corrected |
| 27 | if (!$payment) { |
| 28 | Log::error(esc_html__('Payment Error', 'give'), $giveInsertPaymentData->toArray()); |
| 29 | give_send_back_to_checkout('?payment-mode=' . $giveInsertPaymentData->paymentGateway); |
| 30 | } |
| 31 | |
| 32 | return $payment; |
| 33 | } |
| 34 | } |
| 35 |