WC_Gateway_Paypal::__construct()publicWC 1.0

Constructor for the gateway.

Метод класса: WC_Gateway_Paypal{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Gateway_Paypal = new WC_Gateway_Paypal();
$WC_Gateway_Paypal->__construct();

Код WC_Gateway_Paypal::__construct() WC 8.7.0

public function __construct() {
	$this->id                = 'paypal';
	$this->has_fields        = false;
	$this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' );
	$this->method_title      = __( 'PayPal Standard', '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 );
	}

	// Actions.
	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';
			$pdt_handler = new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $this->identity_token );
			$pdt_handler->set_receiver_email( $this->receiver_email );
		}
	}

	if ( 'yes' === $this->enabled ) {
		add_filter( 'woocommerce_thankyou_order_received_text', array( $this, 'order_received_text' ), 10, 2 );
	}
}