GatewayCommand.php
4 years ago
PaymentAbandoned.php
4 years ago
PaymentCommand.php
3 years ago
PaymentComplete.php
4 years ago
PaymentProcessing.php
4 years ago
PaymentRefunded.php
4 years ago
RedirectOffsite.php
4 years ago
RespondToBrowser.php
4 years ago
SubscriptionComplete.php
3 years ago
SubscriptionProcessing.php
3 years ago
PaymentCommand.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\Framework\PaymentGateways\Commands; |
| 4 | |
| 5 | /*** |
| 6 | * @since 2.18.0 |
| 7 | */ |
| 8 | abstract class PaymentCommand implements GatewayCommand |
| 9 | { |
| 10 | /** |
| 11 | * The Gateway Transaction / Charge Record ID |
| 12 | * |
| 13 | * @var string|null |
| 14 | */ |
| 15 | public $gatewayTransactionId; |
| 16 | |
| 17 | /** |
| 18 | * Notes to be added to the payment. |
| 19 | * |
| 20 | * @var array|string[] |
| 21 | */ |
| 22 | public $paymentNotes = []; |
| 23 | |
| 24 | /** |
| 25 | * @param string|null $gatewayTransactionId |
| 26 | * |
| 27 | * @return static |
| 28 | */ |
| 29 | public static function make(string $gatewayTransactionId = null): PaymentCommand |
| 30 | { |
| 31 | return new static($gatewayTransactionId); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @since 2.18.0 |
| 36 | * @since 2.23.1 Make constructor final to avoid unsafe usage of `new static()`. |
| 37 | * |
| 38 | * @param string|null $gatewayTransactionId |
| 39 | */ |
| 40 | final public function __construct(string $gatewayTransactionId = null) |
| 41 | { |
| 42 | $this->gatewayTransactionId = $gatewayTransactionId; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * @since 2.22.0 add type, so it is typesafe |
| 47 | * |
| 48 | * @param string|string[] ...$paymentNotes |
| 49 | * |
| 50 | * @return $this |
| 51 | */ |
| 52 | public function setPaymentNotes(string ...$paymentNotes): PaymentCommand |
| 53 | { |
| 54 | $this->paymentNotes = $paymentNotes; |
| 55 | |
| 56 | return $this; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * @param string $gatewayTransactionId |
| 61 | * |
| 62 | * @return $this |
| 63 | */ |
| 64 | public function setTransactionId(string $gatewayTransactionId): PaymentCommand |
| 65 | { |
| 66 | $this->gatewayTransactionId = $gatewayTransactionId; |
| 67 | |
| 68 | return $this; |
| 69 | } |
| 70 | } |
| 71 |