parent
d90aee6685
commit
a76f9d9096
|
@ -21,9 +21,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
|
||||
/**
|
||||
* Constructor for the gateway.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'paypal';
|
||||
|
@ -67,7 +64,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
|
||||
// Actions
|
||||
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_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
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function is_valid_for_use() {
|
||||
|
@ -197,9 +192,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
|
||||
/**
|
||||
* Initialise Gateway Settings Form Fields
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
$this->form_fields = array(
|
||||
|
@ -358,8 +350,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
/**
|
||||
* Get PayPal Args for passing to PP
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $order
|
||||
* @param WC_Order $order
|
||||
* @return array
|
||||
*/
|
||||
function get_paypal_args( $order ) {
|
||||
|
@ -394,11 +385,11 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
'business' => $this->email,
|
||||
'no_note' => 1,
|
||||
'currency_code' => get_woocommerce_currency(),
|
||||
'charset' => 'UTF-8',
|
||||
'charset' => 'utf-8',
|
||||
'rm' => is_ssl() ? 2 : 1,
|
||||
'upload' => 1,
|
||||
'return' => urlencode( esc_url( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) ) ),
|
||||
'cancel_return' => urlencode( esc_url( $order->get_cancel_order_url() ) ),
|
||||
'return' => esc_url_raw( add_query_arg( 'utm_nooverride', '1', $this->get_return_url( $order ) ) ),
|
||||
'cancel_return' => esc_url_raw( $order->get_cancel_order_url() ),
|
||||
'page_style' => $this->page_style,
|
||||
'paymentaction' => $this->paymentaction,
|
||||
'bn' => 'WooThemes_Cart',
|
||||
|
@ -565,70 +556,9 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
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
|
||||
*
|
||||
* @access public
|
||||
* @param int $order_id
|
||||
* @return array
|
||||
*/
|
||||
|
@ -717,18 +647,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
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
|
||||
**/
|
||||
|
@ -791,9 +709,6 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
|
||||
/**
|
||||
* Check for PayPal IPN Response
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function check_ipn_response() {
|
||||
|
||||
|
@ -818,9 +733,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
|||
/**
|
||||
* Successful Payment!
|
||||
*
|
||||
* @access public
|
||||
* @param array $posted
|
||||
* @return void
|
||||
*/
|
||||
public function successful_request( $posted ) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue