/** * Initialize the gateway * * @since 1.0 * @param string $id the gateway id * @param SV_WC_Payment_Gateway_Plugin $plugin the parent plugin class * @param array $args gateway arguments */ public function __construct($id, $plugin, $args) { parent::__construct($id, $plugin, $args); // maybe add some settings descriptions, once we have the current settings values available $this->maybe_add_settings_descriptions(); }
/** * Load payment gateway and related settings * * @since 2.0 * @return \WC_Gateway_PayPal_Express */ public function __construct() { parent::__construct(WC_PayPal_Express::GATEWAY_ID, wc_paypal_express(), WC_PayPal_Express::TEXT_DOMAIN, array('method_title' => __('PayPal Express', WC_PayPal_Express::TEXT_DOMAIN), 'method_description' => __('PayPal Express is <strong>purposely designed to skip WooCommerce\'s checkout process</strong> - customers will instead be taken directly to PayPal to authorize funds, and then return to your store to choose shipping and pay.', WC_PayPal_Express::TEXT_DOMAIN), 'supports' => array(self::FEATURE_PRODUCTS, self::FEATURE_CARD_TYPES, self::FEATURE_CREDIT_CARD_CHARGE, self::FEATURE_CREDIT_CARD_AUTHORIZATION, self::FEATURE_CREDIT_CARD_CAPTURE, self::FEATURE_DETAILED_CUSTOMER_DECLINE_MESSAGES), 'card_types' => array('VISA' => 'Visa', 'MC' => 'MasterCard', 'AMEX' => 'American Express', 'DISC' => 'Discover', 'PAYPAL' => 'PayPal'), 'environments' => array('production' => __('Production', WC_PayPal_Express::TEXT_DOMAIN), 'test' => __('Sandbox', WC_PayPal_Express::TEXT_DOMAIN)), 'payment_type' => 'paypal')); // wc-api handler if (!has_action('woocommerce_api_' . strtolower(get_class($this)))) { add_action('woocommerce_api_' . strtolower(get_class($this)), array($this, 'handle_wc_api')); } // inject PayPal-provided checkout details to $_POST at checkout add_action('woocommerce_checkout_billing', array($this, 'set_checkout_post_data')); // disable all other gateways at checkout when confirming payment add_action('woocommerce_available_payment_gateways', array($this, 'disable_other_gateways')); // add checkout body class to aid JS selectors add_filter('body_class', array($this, 'add_body_class')); // augment standard WC checkout fields with express checkout data add_action('woocommerce_checkout_fields', array($this, 'augment_checkout_fields')); // show formatted address in checkout add_action('woocommerce_before_checkout_billing_form', array($this, 'render_formatted_billing_address'), 9); // add cancel link after order submit add_action('woocommerce_review_order_after_submit', array($this, 'render_cancel_link')); // clear session after checkout and cart emptied add_action('woocommerce_cart_emptied', array($this, 'clear_session_data')); }