|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Amazon Pay Payment Method Definition |
| 4 | + * |
| 5 | + * @package WCPay\PaymentMethods\Configs\Definitions |
| 6 | + */ |
| 7 | + |
| 8 | +namespace WCPay\PaymentMethods\Configs\Definitions; |
| 9 | + |
| 10 | +use WCPay\PaymentMethods\Configs\Interfaces\PaymentMethodDefinitionInterface; |
| 11 | +use WCPay\PaymentMethods\Configs\Constants\PaymentMethodCapability; |
| 12 | +use WCPay\PaymentMethods\Configs\Utils\PaymentMethodUtils; |
| 13 | + |
| 14 | +/** |
| 15 | + * Class implementing the Amazon Pay payment method definition. |
| 16 | + */ |
| 17 | +class AmazonPayDefinition implements PaymentMethodDefinitionInterface { |
| 18 | + |
| 19 | + /** |
| 20 | + * Get the internal ID for the payment method |
| 21 | + * |
| 22 | + * @return string |
| 23 | + */ |
| 24 | + public static function get_id(): string { |
| 25 | + return 'amazon_pay'; |
| 26 | + } |
| 27 | + |
| 28 | + /** |
| 29 | + * Get the keywords for the payment method. These are used by the duplicates detection service. |
| 30 | + * |
| 31 | + * @return string[] |
| 32 | + */ |
| 33 | + public static function get_keywords(): array { |
| 34 | + return [ 'amazon_pay', 'amazonpay', 'amazon' ]; |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * Get the Stripe payment method ID |
| 39 | + * |
| 40 | + * @return string |
| 41 | + */ |
| 42 | + public static function get_stripe_id(): string { |
| 43 | + return PaymentMethodUtils::get_stripe_id( self::get_id() ); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Get the customer-facing title of the payment method |
| 48 | + * |
| 49 | + * @param string|null $account_country Optional. The merchant's account country. |
| 50 | + * |
| 51 | + * @return string |
| 52 | + */ |
| 53 | + public static function get_title( ?string $account_country = null ): string { |
| 54 | + return __( 'Amazon Pay', 'woocommerce-payments' ); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Get the title of the payment method for the settings page. |
| 59 | + * |
| 60 | + * @param string|null $account_country Optional. The merchant's account country. |
| 61 | + * |
| 62 | + * @return string |
| 63 | + */ |
| 64 | + public static function get_settings_label( ?string $account_country = null ): string { |
| 65 | + return self::get_title( $account_country ); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Get the customer-facing description of the payment method |
| 70 | + * |
| 71 | + * @param string|null $account_country Optional. The merchant's account country. |
| 72 | + * @return string |
| 73 | + */ |
| 74 | + public static function get_description( ?string $account_country = null ): string { |
| 75 | + return __( 'Offer customers a fast, secure checkout experience with Amazon Pay.', 'woocommerce-payments' ); |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * Get the list of supported currencies |
| 80 | + * |
| 81 | + * @return string[] Array of currency codes |
| 82 | + */ |
| 83 | + public static function get_supported_currencies(): array { |
| 84 | + // Amazon Pay supports the same currencies as card payments. |
| 85 | + // Return all available currencies. |
| 86 | + return []; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Get the list of supported countries |
| 91 | + * |
| 92 | + * @param string|null $account_country Optional. The merchant's account country. |
| 93 | + * @return string[] Array of country codes |
| 94 | + */ |
| 95 | + public static function get_supported_countries( ?string $account_country = null ): array { |
| 96 | + return []; |
| 97 | + } |
| 98 | + |
| 99 | + /** |
| 100 | + * Get the payment method capabilities |
| 101 | + * |
| 102 | + * @return string[] |
| 103 | + */ |
| 104 | + public static function get_capabilities(): array { |
| 105 | + return [ |
| 106 | + PaymentMethodCapability::REFUNDS, |
| 107 | + PaymentMethodCapability::MULTI_CURRENCY, |
| 108 | + PaymentMethodCapability::TOKENIZATION, |
| 109 | + PaymentMethodCapability::CAPTURE_LATER, |
| 110 | + ]; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * Get the URL for the payment method's icon |
| 115 | + * |
| 116 | + * @param string|null $account_country Optional. The merchant's account country. |
| 117 | + * |
| 118 | + * @return string |
| 119 | + */ |
| 120 | + public static function get_icon_url( ?string $account_country = null ): string { |
| 121 | + return plugins_url( 'assets/images/payment-methods/amazon-pay.svg', WCPAY_PLUGIN_FILE ); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Get the URL for the payment method's dark mode icon |
| 126 | + * |
| 127 | + * @param string|null $account_country Optional. The merchant's account country. |
| 128 | + * |
| 129 | + * @return string Returns regular icon URL if no dark mode icon exists |
| 130 | + */ |
| 131 | + public static function get_dark_icon_url( ?string $account_country = null ): string { |
| 132 | + return self::get_icon_url( $account_country ); |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Get the URL for the payment method's settings icon |
| 137 | + * |
| 138 | + * @param string|null $account_country Optional. The merchant's account country. |
| 139 | + * |
| 140 | + * @return string |
| 141 | + */ |
| 142 | + public static function get_settings_icon_url( ?string $account_country = null ): string { |
| 143 | + return self::get_icon_url( $account_country ); |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Get the testing instructions for the payment method |
| 148 | + * |
| 149 | + * @param string $account_country The merchant's account country. |
| 150 | + * @return string HTML string containing testing instructions |
| 151 | + */ |
| 152 | + public static function get_testing_instructions( string $account_country ): string { |
| 153 | + return ''; |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Get the currency limits for the payment method |
| 158 | + * |
| 159 | + * @return array<string,array<string,array{min:int,max:int}>> |
| 160 | + */ |
| 161 | + public static function get_limits_per_currency(): array { |
| 162 | + return []; |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * Whether this payment method is available for the given currency and country |
| 167 | + * |
| 168 | + * @param string $currency The currency code to check. |
| 169 | + * @param string $account_country The merchant's account country. |
| 170 | + * |
| 171 | + * @return bool |
| 172 | + */ |
| 173 | + public static function is_available_for( string $currency, string $account_country ): bool { |
| 174 | + return PaymentMethodUtils::is_available_for( self::get_supported_currencies(), self::get_supported_countries( $account_country ), $currency, $account_country ); |
| 175 | + } |
| 176 | + |
| 177 | + /** |
| 178 | + * Get the minimum amount for this payment method for a given currency and country |
| 179 | + * |
| 180 | + * @param string $currency The currency code. |
| 181 | + * @param string $country The country code. |
| 182 | + * |
| 183 | + * @return int|null The minimum amount or null if no minimum. |
| 184 | + */ |
| 185 | + public static function get_minimum_amount( string $currency, string $country ): ?int { |
| 186 | + return null; |
| 187 | + } |
| 188 | + |
| 189 | + /** |
| 190 | + * Get the maximum amount for this payment method for a given currency and country |
| 191 | + * |
| 192 | + * @param string $currency The currency code. |
| 193 | + * @param string $country The country code. |
| 194 | + * |
| 195 | + * @return int|null The maximum amount or null if no maximum. |
| 196 | + */ |
| 197 | + public static function get_maximum_amount( string $currency, string $country ): ?int { |
| 198 | + return null; |
| 199 | + } |
| 200 | +} |
0 commit comments