PaymentAbandonedHandler.php
4 years ago
PaymentCompleteHandler.php
4 years ago
PaymentHandler.php
4 years ago
PaymentProcessingHandler.php
4 years ago
PaymentRefundedHandler.php
4 years ago
RedirectOffsiteHandler.php
4 years ago
RespondToBrowserHandler.php
4 years ago
SubscriptionCompleteHandler.php
4 years ago
PaymentHandler.php
56 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\PaymentGateways\CommandHandlers; |
| 4 | |
| 5 | use Give\Framework\PaymentGateways\Commands\PaymentCommand; |
| 6 | |
| 7 | abstract class PaymentHandler |
| 8 | { |
| 9 | /** |
| 10 | * @var PaymentCommand |
| 11 | */ |
| 12 | protected $paymentCommand; |
| 13 | |
| 14 | /** |
| 15 | * @since 2.18.0 |
| 16 | * @return string |
| 17 | */ |
| 18 | abstract protected function getPaymentStatus(); |
| 19 | |
| 20 | /** |
| 21 | * @param PaymentCommand $paymentCommand |
| 22 | */ |
| 23 | public function __construct(PaymentCommand $paymentCommand) |
| 24 | { |
| 25 | $this->paymentCommand = $paymentCommand; |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @param PaymentCommand $paymentCommand |
| 30 | * @return static |
| 31 | */ |
| 32 | public static function make(PaymentCommand $paymentCommand) |
| 33 | { |
| 34 | return new static($paymentCommand); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @since 2.18.0 |
| 39 | * |
| 40 | * @param int $donationId |
| 41 | * @return void |
| 42 | */ |
| 43 | public function handle($donationId) |
| 44 | { |
| 45 | give_update_payment_status($donationId, $this->getPaymentStatus()); |
| 46 | |
| 47 | if( $this->paymentCommand->gatewayTransactionId ) { |
| 48 | give_set_payment_transaction_id($donationId, $this->paymentCommand->gatewayTransactionId); |
| 49 | } |
| 50 | |
| 51 | foreach( $this->paymentCommand->paymentNotes as $paymentNote ) { |
| 52 | give_insert_payment_note( $donationId, $paymentNote ); |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 |