Home Communication board WiKi Get Quote

PayPal express checkout and One step checkout module

If you want to use the PayPal express checkout and the One step checkout module, you might found that it's not compatibles by it's architecture. With the PayPal express checkout, your customers are filled the information on the PayPal side, and then they are back to your site for the order confirmation. But with the One step checkout, the information (including the payment information) is collected on one page and there are no any confirmation step. So here the problem with the comparability.

To solve this problem, thye following 3 things should be done:

  • We should disable the redirect from the cart.php
  • We need to set the PayPal token (“start” the PayPal checkout)
  • We should automatically submit the confirmation step on PayPal return.

For the first thing, we should modify the cart.php in the following way. Please find the code for the PayPal redrect and add the module condition here.

		x_session_register('paypal_begin_express');
		x_session_register('paypal_token');
		x_session_register("paypal_express_details");
		if (($paypal_begin_express !== false && (empty($paypal_token) && empty($paypal_express_details))) || (!empty($paypal_token) && (empty($paypal_express_details) || $paypal_token != $paypal_express_details['Token'])) && !$active_modules['OneStepCheckout']) {
			$paypal_begin_express = true;
			if (!$is_ajax) func_header_location($current_location.'/payment/ps_paypal_pro.php?payment_id='.$paymentid.'&mode=express');
		}

Secondly we should start the PayPal, it's better to make it in the payment/payment_cc.php in the following way.

    x_session_register('paypal_customer_notes');
    $paypal_customer_notes = $customer_notes;

    x_session_register('paypal_begin_express');
	x_session_register('paypal_token');
	x_session_register("paypal_express_details");
	if (($paypal_begin_express !== false && (empty($paypal_token) && empty($paypal_express_details))) || (!empty($paypal_token) && (empty($paypal_express_details) || $paypal_token != $paypal_express_details['Token']))) {
	    $paypal_begin_express = true;
		func_header_location($current_location.'/payment/ps_paypal_pro.php?payment_id='.$paymentid.'&mode=express');
    }

This way we are saving the customer notes in the session (we will need it on the last step) and begin the express checkout.

Ant lastly we should automatically submit the PayPal confirmation. The PayPal callback is going to the payment/ps_paypal_pro_us.php (if you are UK based, use the payment/ps_paypal_pro_uk.php ) and we need to replace the redirect to the confirmation page:

    	func_header_location($xcart_catalogs['customer'].'/cart.php?paymentid='.$paypal_payment_id.'&mode=checkout');

to the automatically form submission code:

    if ($active_modules['OneStepCheckout']) {
        x_session_register('paypal_customer_notes');

        $fields = array(
        'paymentid' => 19,
        'action' => 'place_order',
        'Customer_Notes' => $paypal_customer_notes,
        'xid' => $XCARTSESSID,
        'payment_method' => 'PayPal',
        );
	    func_create_payment_form($current_location.'/payment/payment_cc.php', $fields, "PayPal");
        die();
    }
    else    	func_header_location($xcart_catalogs['customer'].'/cart.php?paymentid='.$paypal_payment_id.'&mode=checkout');

That's all, now the PayPal express checkout is compatible with the one step checkout.

 
Home About us Privacy statement Terms & Conditions Refund policy © 2007–2024 ArsCommunity