parent
0b252d03f4
commit
7e1ca1d3a3
|
@ -0,0 +1,11 @@
|
|||
jQuery(function( $ ){
|
||||
$('#woocommerce_paypal_payment_notification_handler').change(function(){
|
||||
if ( $(this).val() === 'IPN' ) {
|
||||
$('#woocommerce_paypal_receiver_email').closest('tr').show();
|
||||
$('#woocommerce_paypal_identity_token').closest('tr').hide();
|
||||
} else {
|
||||
$('#woocommerce_paypal_receiver_email').closest('tr').hide();
|
||||
$('#woocommerce_paypal_identity_token').closest('tr').show();
|
||||
}
|
||||
}).change();
|
||||
});
|
|
@ -36,21 +36,23 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
$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->email = $this->get_option( 'email' );
|
||||
$this->receiver_email = $this->get_option( 'receiver_email', $this->email );
|
||||
$this->title = $this->get_option( 'title' );
|
||||
$this->description = $this->get_option( 'description' );
|
||||
$this->testmode = 'yes' === $this->get_option( 'testmode', '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' );
|
||||
$this->payment_notification_handler = $this->get_option( 'payment_notification_handler', ( $this->identity_token ? 'PDT' : 'IPN' ) );
|
||||
|
||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||
|
||||
if ( ! $this->is_valid_for_use() ) {
|
||||
$this->enabled = 'no';
|
||||
} else {
|
||||
include_once( 'includes/class-wc-gateway-paypal-ipn-handler.php' );
|
||||
$ipn_handler = new WC_Gateway_Paypal_IPN_Handler( $this->testmode, $this->receiver_email );
|
||||
|
||||
if ( $identity_token = $this->get_option( 'identity_token' ) ) {
|
||||
if ( 'IPN' === $this->payment_notification_handler ) {
|
||||
include_once( 'includes/class-wc-gateway-paypal-ipn-handler.php' );
|
||||
$ipn_handler = new WC_Gateway_Paypal_IPN_Handler( $this->testmode, $this->receiver_email );
|
||||
} else {
|
||||
include_once( 'includes/class-wc-gateway-paypal-pdt-handler.php' );
|
||||
$pdt_handler = new WC_Gateway_Paypal_PDT_Handler( $this->testmode, $identity_token );
|
||||
}
|
||||
|
@ -184,6 +186,8 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public function admin_options() {
|
||||
wp_enqueue_script( 'wc-paypal-settings', WC_HTTPS::force_https_url( WC()->plugin_url() . '/includes/gateways/paypal/assets/js/paypal-settings.js' ), array( 'jquery' ), WC_VERSION, true );
|
||||
|
||||
if ( $this->is_valid_for_use() ) {
|
||||
parent::admin_options();
|
||||
} else {
|
||||
|
|
|
@ -37,7 +37,7 @@ return array(
|
|||
'placeholder' => 'you@youremail.com'
|
||||
),
|
||||
'testmode' => array(
|
||||
'title' => __( 'PayPal sandbox', 'woocommerce' ),
|
||||
'title' => __( 'PayPal Sandbox', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable PayPal sandbox', 'woocommerce' ),
|
||||
'default' => 'no',
|
||||
|
@ -50,30 +50,23 @@ return array(
|
|||
'default' => 'no',
|
||||
'description' => sprintf( __( 'Log PayPal events, such as IPN requests, inside <code>%s</code>', 'woocommerce' ), wc_get_log_file_path( 'paypal' ) )
|
||||
),
|
||||
'shipping' => array(
|
||||
'title' => __( 'Shipping options', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'description' => '',
|
||||
),
|
||||
'send_shipping' => array(
|
||||
'title' => __( 'Shipping details', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Send shipping details to PayPal instead of billing.', 'woocommerce' ),
|
||||
'description' => __( 'PayPal allows us to send 1 address. If you are using PayPal for shipping labels you may prefer to send the shipping address rather than billing.', 'woocommerce' ),
|
||||
'default' => 'no'
|
||||
),
|
||||
'address_override' => array(
|
||||
'title' => __( 'Address override', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable "address_override" to prevent address information from being changed.', 'woocommerce' ),
|
||||
'description' => __( 'PayPal verifies addresses therefore this setting can cause errors (we recommend keeping it disabled).', 'woocommerce' ),
|
||||
'default' => 'no'
|
||||
),
|
||||
'advanced' => array(
|
||||
'title' => __( 'Advanced options', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
'description' => '',
|
||||
),
|
||||
'payment_notification_handler' => array(
|
||||
'title' => __( 'Payment Notification Handler', 'woocommerce' ),
|
||||
'type' => 'select',
|
||||
'class' => 'wc-enhanced-select',
|
||||
'description' => __( 'Choose either IPN or PDT. This will be used to update orders after payment.', 'woocommerce' ),
|
||||
'default' => 'IPN',
|
||||
'desc_tip' => true,
|
||||
'options' => array(
|
||||
'IPN' => __( 'PayPal IPN', 'woocommerce' ),
|
||||
'PDT' => __( 'Payment Data Transfer (PDT)', 'woocommerce' )
|
||||
)
|
||||
),
|
||||
'receiver_email' => array(
|
||||
'title' => __( 'Receiver Email', 'woocommerce' ),
|
||||
'type' => 'email',
|
||||
|
@ -82,6 +75,14 @@ return array(
|
|||
'desc_tip' => true,
|
||||
'placeholder' => 'you@youremail.com'
|
||||
),
|
||||
'identity_token' => array(
|
||||
'title' => __( 'PayPal Identity Token', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'description' => __( 'Optionally enable "Payment Data Transfer" (Profile > Website Payment Preferences) and then copy your identity token here. This will allow payments to be verified without the need for PayPal IPN.', 'woocommerce' ),
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
'placeholder' => ''
|
||||
),
|
||||
'invoice_prefix' => array(
|
||||
'title' => __( 'Invoice Prefix', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
|
@ -89,6 +90,20 @@ return array(
|
|||
'default' => 'WC-',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'send_shipping' => array(
|
||||
'title' => __( 'Shipping Details', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Send shipping details to PayPal instead of billing.', 'woocommerce' ),
|
||||
'description' => __( 'PayPal allows us to send one address. If you are using PayPal for shipping labels you may prefer to send the shipping address rather than billing.', 'woocommerce' ),
|
||||
'default' => 'no'
|
||||
),
|
||||
'address_override' => array(
|
||||
'title' => __( 'Address Override', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable "address_override" to prevent address information from being changed.', 'woocommerce' ),
|
||||
'description' => __( 'PayPal verifies addresses therefore this setting can cause errors (we recommend keeping it disabled).', 'woocommerce' ),
|
||||
'default' => 'no'
|
||||
),
|
||||
'paymentaction' => array(
|
||||
'title' => __( 'Payment Action', 'woocommerce' ),
|
||||
'type' => 'select',
|
||||
|
@ -109,14 +124,6 @@ return array(
|
|||
'desc_tip' => true,
|
||||
'placeholder' => __( 'Optional', 'woocommerce' )
|
||||
),
|
||||
'identity_token' => array(
|
||||
'title' => __( 'PayPal Identity Token', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'description' => __( 'Optionally enable "Payment Data Transfer" (Profile > Website Payment Preferences) and then copy your identity token here. This will allow payments to be verified without the need for PayPal IPN.', 'woocommerce' ),
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
'placeholder' => __( 'Optional', 'woocommerce' )
|
||||
),
|
||||
'api_details' => array(
|
||||
'title' => __( 'API Credentials', 'woocommerce' ),
|
||||
'type' => 'title',
|
||||
|
|
Loading…
Reference in New Issue