PAYPAL API - SESSION ISSUE PLEASE HELP

Job ID: 36965483

Budget: $30 – $250 USD

on checkout i seem to be having a weird session issue where the information is not getting passed to the api server in order to complete payment properly.
the session or some of the session variables maybe are getting reset at certain points in the flow or are not giving the desired response leading to errors and failed payments.
As a workaround i have simply FORCED THE CODE to accept the order and catpure payment, i.e to bypass the errors and redirects.. This however is not a permanent workable solution, aside from the potential security risks.
i need someone familiar with PHP and preferably oscommerce to come fast and patch this or amend the code.
i think the payment process needs to be moved to the FINAL PAGE let me explain

CURRENT FLOW / SETUP
land on chckout_payment page (checkout_payment.php)
choose CARD
form appears to enter details on THIS PAGE
press continue
paypal server is contacted to start the processing
paypal finishes its processing and returns to the Confirmation page
land on checkout_confirmation page (checkout_confirmation.php)
Press CONFIRM ORDER
Then 1 of 2 things happen
1. user redirected to Payment Page (usually with an error and payment failure)
2. user redirected to checkout_success page (with success message, and usually payment captured

What im finding is that EVERY user is getting REJECTED and they are being REDIRECTED to the payment page with payment failure. This is due to the API not receiving essential information which i think is due to a session problem.
My proposed solution is to fix the session issue or bug causing this without changing the flow or maybe we could change the flow also as follows. Please note i had this flow on a previous shopping cart.

REVISED / ALTERNATIVE FLOW

land on checkout_payment page (checkout_payment.php)
choose CARD
press continue
land on checkout_confirmation page (checkout_confirmation.php)
a form will appear on this page and we enter card details
Press CONFIRM ORDER
api connects to paypal to start processing the payment
Then 1 of 2 things happen
1. user redirected to Payment Page (usually with an error and payment failure)
2. user redirected to checkout_success page (with success message, and usually payment captures

PLEASE NOTE THE DIFFERENCE in flows
in the revised flow the payment details are ENTERED on the CONFIRMATION page and NOT the payment page
the reason for this is that the session should have all its information at the correct times, and ensure that no order will be submitted to store owner if the payment fails, and that if payment is taken the order will be submitted to store owner
in the current setup it is possible for an order to be SENT to the store owner with a FAILED PAYMENT.
i dont need to explain the issue with this !!!! pretty obvious.
on the other hand we need to ensure if PAYMENT IS CHARGED (CAPTURED) then the order must be submitted for processing.
i think in the new flow this prevents any orders being submitted if payment fails and ensures that if payment succeeds the order is submitted.
Note: when i say submitted i mean the ORDER EMAIL is sent out.
Note 2: when i say payment taken or charged or captured i mean the STORE OWNER has RECEIVED the money in their merchant account e.g payal. it does NOT mean the money has come off the customers CARD as this can happen in an AUTHORISATION but i am not doing authorisation i am only doing SALE, or CAPTURE. Authorisations can be blocked , Sales or Captures are NOT blocked.
This guarantees the store owner will get their money if an order is submitted and that a customer will get their order if the payment is received by the shop.
However whats more important is that
1. NO ORDER IS SENT (EMAILED) if payment fails
2. ALL ORDERS ARE SENT (EMAILED) if payment succeeds.

the current flow allows for contravention of 1.

Regards
Related categories: PHP PayPal API OSCommerce MySQL PayPal