1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
<?php
defined( 'ABSPATH' ) || exit();
if ( ! class_exists( 'WC_Payment_Gateway_Stripe_Local_Payment' ) ) {
return;
}
class WC_Payment_Gateway_Stripe_Alipay extends WC_Payment_Gateway_Stripe_Local_Payment {
use WC_Stripe_Local_Payment_Charge_Trait;
public function __construct() {
$this->local_payment_type = 'alipay';
$this->currencies = array( 'AUD', 'CAD', 'EUR', 'GBP', 'HKD', 'JPY', 'SGD', 'USD', 'CNY', 'NZD', 'MYR' );
$this->id = 'stripe_alipay';
$this->tab_title = __( 'Alipay', 'woo-stripe-payment' );
$this->template_name = 'local-payment.php';
$this->token_type = 'Stripe_Local';
$this->method_title = __( 'Alipay', 'woo-stripe-payment' );
$this->method_description = __( 'Alipay gateway that integrates with your Stripe account.', 'woo-stripe-payment' );
$this->icon = stripe_wc()->assets_url( 'img/alipay.svg' );
parent::__construct();
}
public function init_form_fields() {
parent::init_form_fields();
$this->form_fields['allowed_countries']['default'] = 'all';
}
public function validate_local_payment_available( $currency, $billing_country ) {
$country = stripe_wc()->account_settings->get_option( 'country' );
$default_currency = stripe_wc()->account_settings->get_option( 'default_currency' );
if ( in_array( $currency, $this->currencies ) ) {
if ( in_array( $country, array( 'DK', 'NO', 'SE', 'CH' ) ) ) {
return $currency === 'EUR';
} else {
return $currency === 'CNY' || $currency === $default_currency;
}
}
return false;
}
protected function get_payment_description() {
return __( 'Gateway will appear when store currency is CNY, or currency matches merchant\'s
default Stripe currency. For merchants located in DK, NO, SE, & CH, currency must be EUR.', 'woo-stripe-payment' );
}
}