Payment Module Error

Open to all! Ask other shopowners for help.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Payment Module Error

Post by raiwa »

Kofod95 wrote: Wed Jul 06, 2022 9:47 am I hooked a check in on checkout_process, that caught the order_id from the URL and recreated the customers' session from that before the file checks for log-in.

//Daniel
Would you share this
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Payment Module Error

Post by Kofod95 »

Sure - I'll look for it, next time I'm on my PC.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Payment Module Error

Post by Kofod95 »

I could only find the draft for OSC 2.3:

Code: Select all

//Fix return from Mobilepay - can be hooked in Phoenix using SiteWide-hook
  $cart_QuickPay_ID = $_GET['cart_QuickPay_ID'];
  $order_id = substr($cart_QuickPay_ID, strpos($cart_QuickPay_ID, '-') + 1);
  if( !tep_session_is_registered('customer_id') && isset($_GET['cart_QuickPay_ID'])) {
//Find the right customer
    $customer_info_query = tep_db_query("select c.customers_id, c.customers_firstname, o.customers_email_address, o.delivery_name, o.payment_method, ot.title, ot.value from customers c, orders o, orders_total ot where orders_id = '" . (int)$order_id . "' AND c.customers_email_address = o.customers_email_address AND ot.class = 'ot_shipping'");
    $customer_info = tep_db_fetch_array($customer_info_query);
	
	$customer_id = $customer_info['customers_id'];
    tep_session_register('customer_id');
	
    $customer_first_name = $customer_info['customers_firstname'];
    tep_session_register('customer_first_name');	
	
	$shipping = $customer_info['delivery_name'];
	tep_session_register('shipping');
	
	$sendto = $customer_default_address_id;
	tep_session_register('sendto');
	
	$shipping = array('id' => 1,
                                'title' => $customer_info['title'],
                                'cost' => $customer_info['value']);
    tep_session_register('shipping');
	
	$payment = $customer_info['payment_method'];
	tep_session_register('payment');

    $sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand());

      
    //Restore cart contents
    $cart->restore_contents();
        
    $cartID = $cart->cartID;
    tep_session_register('cartID');
  }
//End fix return from Mobilepay
For the Phoenix-shops, an update to the payment module fixed it, and I'm afraid I didn't keep the solutions for them around (though I might just have put the files somewhere and forgot about it - I'm still trying to find the right way to organise these kind of things, which means everything is rather messy :lol: )
//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Payment Module Error

Post by raiwa »

Kofod95 wrote: Sat Jul 09, 2022 10:31 am I could only find the draft for OSC 2.3:

Code: Select all

//Fix return from Mobilepay - can be hooked in Phoenix using SiteWide-hook
  $cart_QuickPay_ID = $_GET['cart_QuickPay_ID'];
  $order_id = substr($cart_QuickPay_ID, strpos($cart_QuickPay_ID, '-') + 1);
  if( !tep_session_is_registered('customer_id') && isset($_GET['cart_QuickPay_ID'])) {
//Find the right customer
    $customer_info_query = tep_db_query("select c.customers_id, c.customers_firstname, o.customers_email_address, o.delivery_name, o.payment_method, ot.title, ot.value from customers c, orders o, orders_total ot where orders_id = '" . (int)$order_id . "' AND c.customers_email_address = o.customers_email_address AND ot.class = 'ot_shipping'");
    $customer_info = tep_db_fetch_array($customer_info_query);
	
	$customer_id = $customer_info['customers_id'];
    tep_session_register('customer_id');
	
    $customer_first_name = $customer_info['customers_firstname'];
    tep_session_register('customer_first_name');	
	
	$shipping = $customer_info['delivery_name'];
	tep_session_register('shipping');
	
	$sendto = $customer_default_address_id;
	tep_session_register('sendto');
	
	$shipping = array('id' => 1,
                                'title' => $customer_info['title'],
                                'cost' => $customer_info['value']);
    tep_session_register('shipping');
	
	$payment = $customer_info['payment_method'];
	tep_session_register('payment');

    $sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand());

      
    //Restore cart contents
    $cart->restore_contents();
        
    $cartID = $cart->cartID;
    tep_session_register('cartID');
  }
//End fix return from Mobilepay
For the Phoenix-shops, an update to the payment module fixed it, and I'm afraid I didn't keep the solutions for them around (though I might just have put the files somewhere and forgot about it - I'm still trying to find the right way to organise these kind of things, which means everything is rather messy :lol: )
//Daniel
Thank you,

As far as I see the quick pay module saves the order before leaving the shop.
Sagepay direct, which is the module I have the issue, does not save the order to the database before the external 3D check. So this approach will not work for me. Or did you add to the Quickpay module the code to save the order?
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Payment Module Error

Post by ecartz »

raiwa wrote: Sat Jul 09, 2022 5:33 pm So this approach will not work for me. Or did you add to the Quickpay module the code to save the order?
When I look at SagePay Direct, line 356, I see

Code: Select all

          'VendorData' => 'Customer ID ' . $_SESSION['customer_id'],
Perhaps if you pass the session ID in there? Either instead of the customer ID or in addition to it. Then load the session from the session ID.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Payment Module Error

Post by raiwa »

Thank you Matt,
It’s an early EDGE or even Gold/pre Gold BS 3 version.
Before I do a live store test, if I add the session id to the redirect URL in ext\modules\payment\sage_pay\redirect.php:

Code: Select all

      $redirect_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, 'check=3D&session=' . session_id(), 'SSL');
and in checkout process.php at the top:

Code: Select all

  include('includes/application_top.php');

  if ( isset($_GET['check']) && $_GET['check'] == '3D' && isset($_GET['session']) ) {
    $GLOBALS['SID'] = $_GET['session'];
    tep_session_recreate();
  }
Could this work?
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
ecartz
Core Team
Posts: 3084
Joined: Tue Nov 05, 2019 6:02 pm
Phoenix Version:
Has thanked: 4 times
Been thanked: 208 times

Re: Payment Module Error

Post by ecartz »

Have you tried just

Code: Select all

      $redirect_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, session_name() . '=' . session_id(), 'SSL');
with Force Cookies turned off? Then it shouldn't need special code to recreate the session. Or with Force Cookies on, edit application_top.php (around line 151) to something like

Code: Select all

// set the session ID if it exists
  if (( SESSION_FORCE_COOKIE_USE == 'False' ) || (isset($_GET['check']) && ('3D' == $_GET['check']))) {
with

Code: Select all

      $redirect_url = tep_href_link(FILENAME_CHECKOUT_PROCESS, 'check=3D&' . session_name() . '=' . session_id(), 'SSL');
You might have to edit tep_session_start too.
raiwa
Certified Developer
Posts: 1640
Joined: Sat Dec 21, 2019 8:08 am
Phoenix Version: 1.1.0.6
Has thanked: 70 times
Been thanked: 152 times

Re: Payment Module Error

Post by raiwa »

I did some simulated tests. Adding the session to the return URL works with Force Cookies turned off. But the other modification with Force Cookies turned on, redirects to index.php because of this check in session.php:

Code: Select all

    if ($sane_session_id == false) {
      tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
    }
Meanwhile, if this problem persists in actual Phoenix 1.0.8.16 Pro with sagepay direct, it would be good to address it in core?
Public Phoenix Change Log Cheat Set on Google Sheets
https://docs.google.com/spreadsheets/d/ ... sp=sharing

Need Help?viewtopic.php?f=10&t=27
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Payment Module Error

Post by Kofod95 »

raiwa wrote: Sat Jul 09, 2022 5:33 pm As far as I see the quick pay module saves the order before leaving the shop.
Sagepay direct, which is the module I have the issue, does not save the order to the database before the external 3D check. So this approach will not work for me. Or did you add to the Quickpay module the code to save the order?
Though this may no longer be relevant, you are correct: QuickPay saves the order by default with a "Preparing"-status before leaving the shop. It also adds a link to the payment window in admin, that the shop owner can send to the customer, to help them make the payment.
I would think the suggestion @ecartz brought is better anyway, but saving the order before leaving the shop, but without clearing the cart until the payment is authorized has come in handy at times.

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply