WC_Gateway_Paypal::__construct()
Constructor for the gateway.
Description Description
Source Source
File: includes/gateways/paypal/class-wc-gateway-paypal.php
public function __construct() { $this->id = 'paypal'; $this->has_fields = false; $this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' ); $this->method_title = __( 'PayPal', 'woocommerce' ); /* translators: %s: Link to WC system status page */ $this->method_description = __( 'PayPal Standard redirects customers to PayPal to enter their payment information.', 'woocommerce' ); $this->supports = array( 'products', 'refunds', ); // Load the settings. $this->init_form_fields(); $this->init_settings(); // Define user set variables. $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); $this->testmode = 'yes' === $this->get_option( 'testmode', 'no' ); $this->debug = 'yes' === $this->get_option( 'debug', 'no' ); $this->email = $this->get_option( 'email' ); $this->receiver_email = $this->get_option( 'receiver_email', $this->email ); $this->identity_token = $this->get_option( 'identity_token' ); self::$log_enabled = $this->debug; if ( $this->testmode ) { /* translators: %s: Link to PayPal sandbox testing guide page */ $this->description .= ' ' . sprintf( __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the <a href="%s">PayPal Sandbox Testing Guide</a> for more details.', 'woocommerce' ), 'https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/' ); $this->description = trim( $this->description ); } add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); add_action( 'woocommerce_order_status_processing', array( $this, 'capture_payment' ) ); add_action( 'woocommerce_order_status_completed', array( $this, 'capture_payment' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); if ( ! $this->is_valid_for_use() ) { $this->enabled = 'no'; } else { include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-ipn-handler.php'; new WC_Gateway_Paypal_IPN_Handler( $this->testmode, $this->receiver_email ); if ( $this->identity_token ) { include_once dirname( __FILE__ ) . '/includes/class-wc-gateway-paypal-pdt-handler.php'; new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token ); } } if ( 'yes' === $this->enabled ) { add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'order_received_text' ), 10, 2 ); } }