parent
d90aee6685
commit
a76f9d9096
|
@ -21,20 +21,17 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the gateway.
|
* Constructor for the gateway.
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->id = 'paypal';
|
$this->id = 'paypal';
|
||||||
$this->has_fields = false;
|
$this->has_fields = false;
|
||||||
$this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' );
|
$this->order_button_text = __( 'Proceed to PayPal', 'woocommerce' );
|
||||||
$this->liveurl = 'https://www.paypal.com/cgi-bin/webscr';
|
$this->liveurl = 'https://www.paypal.com/cgi-bin/webscr';
|
||||||
$this->testurl = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
$this->testurl = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
|
||||||
$this->method_title = __( 'PayPal', 'woocommerce' );
|
$this->method_title = __( 'PayPal', 'woocommerce' );
|
||||||
$this->method_description = __( 'PayPal standard works by sending the user to PayPal to enter their payment information.', 'woocommerce' );
|
$this->method_description = __( 'PayPal standard works by sending the user to PayPal to enter their payment information.', 'woocommerce' );
|
||||||
$this->notify_url = WC()->api_request_url( 'WC_Gateway_Paypal' );
|
$this->notify_url = WC()->api_request_url( 'WC_Gateway_Paypal' );
|
||||||
$this->supports = array(
|
$this->supports = array(
|
||||||
'products',
|
'products',
|
||||||
'refunds'
|
'refunds'
|
||||||
);
|
);
|
||||||
|
@ -67,7 +64,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
add_action( 'valid-paypal-standard-ipn-request', array( $this, 'successful_request' ) );
|
add_action( 'valid-paypal-standard-ipn-request', array( $this, 'successful_request' ) );
|
||||||
add_action( 'woocommerce_receipt_paypal', array( $this, 'receipt_page' ) );
|
|
||||||
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
|
||||||
add_action( 'woocommerce_thankyou_paypal', array( $this, 'pdt_return_handler' ) );
|
add_action( 'woocommerce_thankyou_paypal', array( $this, 'pdt_return_handler' ) );
|
||||||
|
|
||||||
|
@ -168,7 +164,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
/**
|
/**
|
||||||
* Check if this gateway is enabled and available in the user's country
|
* Check if this gateway is enabled and available in the user's country
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function is_valid_for_use() {
|
function is_valid_for_use() {
|
||||||
|
@ -197,9 +192,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise Gateway Settings Form Fields
|
* Initialise Gateway Settings Form Fields
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function init_form_fields() {
|
public function init_form_fields() {
|
||||||
$this->form_fields = array(
|
$this->form_fields = array(
|
||||||
|
@ -358,8 +350,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
/**
|
/**
|
||||||
* Get PayPal Args for passing to PP
|
* Get PayPal Args for passing to PP
|
||||||
*
|
*
|
||||||
* @access public
|
* @param WC_Order $order
|
||||||
* @param mixed $order
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function get_paypal_args( $order ) {
|
function get_paypal_args( $order ) {
|
||||||
|
@ -394,11 +385,11 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
'business' => $this->email,
|
'business' => $this->email,
|
||||||
'no_note' => 1,
|
'no_note' => 1,
|
||||||
'currency_code' => get_woocommerce_currency(),
|
'currency_code' => get_woocommerce_currency(),
|
||||||
'charset' => 'UTF-8',
|
'charset' => 'utf-8',
|
||||||
'rm' => is_ssl() ? 2 : 1,
|
'rm' => is_ssl() ? 2 : 1,
|
||||||
'upload' => 1,
|
'upload' => 1,
|
||||||
'return' => urlencode( esc_url( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) ) ),
|
'return' => esc_url_raw( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) ),
|
||||||
'cancel_return' => urlencode( esc_url( $order->get_cancel_order_url() ) ),
|
'cancel_return' => esc_url_raw( $order->get_cancel_order_url() ),
|
||||||
'page_style' => $this->page_style,
|
'page_style' => $this->page_style,
|
||||||
'paymentaction' => $this->paymentaction,
|
'paymentaction' => $this->paymentaction,
|
||||||
'bn' => 'WooThemes_Cart',
|
'bn' => 'WooThemes_Cart',
|
||||||
|
@ -565,70 +556,9 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
return $args;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate the paypal button link
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param mixed $order_id
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function generate_paypal_form( $order_id ) {
|
|
||||||
|
|
||||||
$order = wc_get_order( $order_id );
|
|
||||||
|
|
||||||
if ( 'yes' == $this->testmode ) {
|
|
||||||
$paypal_adr = $this->testurl . '?test_ipn=1&';
|
|
||||||
} else {
|
|
||||||
$paypal_adr = $this->liveurl . '?';
|
|
||||||
}
|
|
||||||
|
|
||||||
$paypal_args = $this->get_paypal_args( $order );
|
|
||||||
|
|
||||||
$paypal_args_array = array();
|
|
||||||
|
|
||||||
foreach ( $paypal_args as $key => $value ) {
|
|
||||||
$paypal_args_array[] = '<input type="hidden" name="'.esc_attr( $key ) . '" value="' . esc_attr( $value ) . '" />';
|
|
||||||
}
|
|
||||||
|
|
||||||
wc_enqueue_js( '
|
|
||||||
$.blockUI({
|
|
||||||
message: "' . esc_js( __( 'Thank you for your order. We are now redirecting you to PayPal to make payment.', 'woocommerce' ) ) . '",
|
|
||||||
baseZ: 99999,
|
|
||||||
overlayCSS:
|
|
||||||
{
|
|
||||||
background: "#fff",
|
|
||||||
opacity: 0.6
|
|
||||||
},
|
|
||||||
css: {
|
|
||||||
padding: "20px",
|
|
||||||
zindex: "9999999",
|
|
||||||
textAlign: "center",
|
|
||||||
color: "#555",
|
|
||||||
border: "3px solid #aaa",
|
|
||||||
backgroundColor:"#fff",
|
|
||||||
cursor: "wait",
|
|
||||||
lineHeight: "24px",
|
|
||||||
}
|
|
||||||
});
|
|
||||||
jQuery("#submit_paypal_payment_form").click();
|
|
||||||
' );
|
|
||||||
|
|
||||||
return '<form action="' . esc_url( $paypal_adr ) . '" method="post" id="paypal_payment_form" target="_top">
|
|
||||||
' . implode( '', $paypal_args_array ) . '
|
|
||||||
<!-- Button Fallback -->
|
|
||||||
<div class="payment_buttons">
|
|
||||||
<input type="submit" class="button alt" id="submit_paypal_payment_form" value="' . __( 'Pay via PayPal', 'woocommerce' ) . '" /> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">' . __( 'Cancel order & restore cart', 'woocommerce' ) . '</a>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery(".payment_buttons").hide();
|
|
||||||
</script>
|
|
||||||
</form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the payment and return the result
|
* Process the payment and return the result
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @param int $order_id
|
* @param int $order_id
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
@ -717,18 +647,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Output for the order received page.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function receipt_page( $order ) {
|
|
||||||
echo '<p>' . __( 'Thank you - your order is now pending payment. You should be automatically redirected to PayPal to make payment.', 'woocommerce' ) . '</p>';
|
|
||||||
|
|
||||||
echo $this->generate_paypal_form( $order );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check PayPal IPN validity
|
* Check PayPal IPN validity
|
||||||
**/
|
**/
|
||||||
|
@ -791,9 +709,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for PayPal IPN Response
|
* Check for PayPal IPN Response
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function check_ipn_response() {
|
public function check_ipn_response() {
|
||||||
|
|
||||||
|
@ -818,9 +733,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
/**
|
/**
|
||||||
* Successful Payment!
|
* Successful Payment!
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @param array $posted
|
* @param array $posted
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function successful_request( $posted ) {
|
public function successful_request( $posted ) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue