| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Framework\PaymentGateways\Contracts; |
| 4 |
|
| 5 |
use Give\Donations\Models\Donation; |
| 6 |
use Give\Framework\Exceptions\Primitives\Exception; |
| 7 |
use Give\Framework\PaymentGateways\Commands\GatewayCommand; |
| 8 |
use Give\Framework\PaymentGateways\Commands\RedirectOffsite; |
| 9 |
use Give\Framework\PaymentGateways\Exceptions\PaymentGatewayException; |
| 10 |
|
| 11 |
/** |
| 12 |
* @since 2.18.0 |
| 13 |
*/ |
| 14 |
interface PaymentGatewayInterface extends SubscriptionModuleInterface |
| 15 |
{ |
| 16 |
|
| 17 |
/** |
| 18 |
* Specify which form versions the gateway supports |
| 19 |
* |
| 20 |
* Currently, this corresponds to the major GiveWP versions (2, 3, etc) |
| 21 |
* |
| 22 |
* This will likely be removed in the future when GiveWP 2.x is no longer supported |
| 23 |
* |
| 24 |
* @since 2.30.0 |
| 25 |
*/ |
| 26 |
public function supportsFormVersions(): array; |
| 27 |
|
| 28 |
/** |
| 29 |
* Enqueue script for the gateway to display fields and interact with the form |
| 30 |
* |
| 31 |
* @since 2.30.0 |
| 32 |
*/ |
| 33 |
public function enqueueScript(int $formId); |
| 34 |
|
| 35 |
/** |
| 36 |
* Return a unique identifier for the gateway |
| 37 |
* |
| 38 |
* @since 2.18.0 |
| 39 |
*/ |
| 40 |
public static function id(): string; |
| 41 |
|
| 42 |
/** |
| 43 |
* Return a unique identifier for the gateway |
| 44 |
* |
| 45 |
* @since 2.18.0 |
| 46 |
* |
| 47 |
* @deprecated 2.22.2 use static id() method instead, can use on an instance: $this::id() or $gateway::id() — even in strings |
| 48 |
*/ |
| 49 |
public function getId(): string; |
| 50 |
|
| 51 |
/** |
| 52 |
* Returns a human-readable name for the gateway |
| 53 |
* |
| 54 |
* @since 2.18.0 |
| 55 |
* |
| 56 |
* @return string - Translated text |
| 57 |
*/ |
| 58 |
public function getName(): string; |
| 59 |
|
| 60 |
/** |
| 61 |
* Returns a human-readable label for use when a donor selects a payment method to use |
| 62 |
* |
| 63 |
* @since 2.18.0 |
| 64 |
* |
| 65 |
* @return string - Translated text |
| 66 |
*/ |
| 67 |
public function getPaymentMethodLabel(): string; |
| 68 |
|
| 69 |
/** |
| 70 |
* Determines if refunds are supported |
| 71 |
* |
| 72 |
* @since 2.29.0 |
| 73 |
* |
| 74 |
* @return bool |
| 75 |
*/ |
| 76 |
public function supportsRefund(): bool; |
| 77 |
|
| 78 |
/** |
| 79 |
* Determines if subscriptions are supported |
| 80 |
* |
| 81 |
* @since 2.18.0 |
| 82 |
* |
| 83 |
* @return bool |
| 84 |
*/ |
| 85 |
public function supportsSubscriptions(): bool; |
| 86 |
|
| 87 |
/** |
| 88 |
* Create a payment with gateway |
| 89 |
* Note: You can use "givewp_create_payment_gateway_data_{$gatewayId}" filter hook to pass additional data for gateway which helps/require to process transaction. |
| 90 |
* This filter will help to add additional arguments to this function which should be optional otherwise you will get PHP fatal error. |
| 91 |
* |
| 92 |
* @since 2.21.2 Add second param to function to pass gateway data to process transaction |
| 93 |
* @since 2.18.0 |
| 94 |
* |
| 95 |
* @param array $gatewayData |
| 96 |
* |
| 97 |
* @return GatewayCommand|RedirectOffsite|void |
| 98 |
* |
| 99 |
* @throws PaymentGatewayException |
| 100 |
* @throws Exception |
| 101 |
*/ |
| 102 |
public function createPayment(Donation $donation, $gatewayData); |
| 103 |
} |
| 104 |
|