Zen Cart Logo
Forums / Addon Payment Modules / Create order before redirecting to payment gateway site for Hosted Payment Page payme

Create order before redirecting to payment gateway site for Hosted Payment Page payme

Views: 4,507

Results 1 to 2 of 2
8 Nov 2016, 2:24 PM
#1
vishwanathk avatar

vishwanathk

New Zenner

Join Date:
Mar 2016
Location:
India
Posts:
6
Plugin Contributions:
0

Create order before redirecting to payment gateway site for Hosted Payment Page payme

Hi All,

I have to create the order before redirecting to the payment gateway sit in my payment method(my custom payment method).

Process is like this :

  1. First create order with pending status.
  2. Redirect to payment gateway sit
  3. Do payment here is two case
    3a) If customer is not redirecting back to site then as per zencart flow order will not get created and make customer unsatisfied.
    3b) To use callback functionality to check payment transaction id, and update order status.

For this i am creating an order with pending status, but when customer have done payment and redirecting back to site then another order is creating with new order id.

So how i do this ?

Thanks,

8 Nov 2016, 6:26 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Create order before redirecting to payment gateway site for Hosted Payment Page payme

Zen Cart's v1 architecture was built based on osCommerce architecture which wasn't designed to do as you describe.

The common workaround for it is to create a database table into which you store the shopper's session, and then do a callback which repopulates their session and only converts the session into a saved order after the payment callback happens. This does run the risk of a lost order if the callback never happens or doesn't complete properly. (This is how the old PayPal Standard module worked, and the need for the callback (and lost orders) is the very reason why we strongly discourage people from using that old style of gateway.)

Alternatively, since you've already changed the core code to pre-store an incomplete order, you could make your callback simply update the order details (change order's order_status field, and add to the orders_status_history table) instead of creating a new order.

Or, if your gateway is similar to Authorize.net SIM or First Data Hosted Payment Pages you could do as they do and use the receipt_url to notify the store of the payment completion without having to store the order first. This would require that your gateway be capable of emulating the Authorizenet SIM POST Return capability.