Kristoff Posted October 31, 2013 Share Posted October 31, 2013 Hi again guys, just ran in to a bit of an issue, with our old store (4.4.4) digital products were set as completed as soon as payment was made from sagepay, but now when we pay it's going to the order and the status is "Pending" has something changed? Or have I missed something I should change? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 Just to verify: are tangible orders going to Processing when paid through SagePay? Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 Ok think this may be the problem: Status - Amount - Gateway - Date/Time Not Available - £0.50 - SagePay - Today, 15:50 ??? Anybody any idea why the status of the order is unavailable?! Just to verify: are tangible orders going to Processing when paid through SagePay? No, gone to pending also. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 Sorry, could you mention on what CubeCart page these details are coming from? Can you check the details of transactions submitted to SagePay at your SagePay vendor login? Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 These are in the admin area: Dashboard » Orders » 13**1-15***33-59** Then on the transaction log page. Callback URL in sagepay is: **storeurl***/index.php?_g=rm&type=gateway&cmd=process&module=SagePay&cart_order_id=13**1-15***33-59**A I note an additional A at the end of the URL there, could that be an issue? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 Yes, that's going to be a problem. Would you please look in the file modulesgatewaySagePaygateway.class.php, lines 291 and 292. Anything strange here? Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 ."&SuccessURL=".$GLOBALS['storeURL'].'/index.php?_g=rm&type=gateway&cmd=process&module=SagePay&cart_order_id='.$this->_basket['cart_order_id'] ."&FailureURL=".$GLOBALS['storeURL'].'/index.php?_g=rm&type=gateway&cmd=process&module=SagePay&cart_order_id='.$this->_basket['cart_order_id'] That's those lines. The thing that struck me as strange was the fact they were both the same. Does the A stand for authenticated or something? Added on by Sagepay? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 To me, this was the first obvious place to look for corruption in the callback URL. Where are you looking to know what the actual callback URL was? Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 In the sagepay transactions area of MySagePay Have just put another transaction through to confirm that in sagepay it does say the correct order number next to "To pay for:" there is no A following the number. I have asked one of my colleagues if they can get me the callback URL for a previously successful payment. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 I don't know if the following is actually a problem, I'm sure you would have seen some error messages of some sort if it is: In the SagePay gateway file, line 209, there is elseIf, but all PHP commands and functions are in lowercase. I don't know if the non-functions must be lower-case. Anyway, change it to elseif. Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 Ok, it's still returning as Status "Not Available" in orders, and no transaction ID, however, this is the URL it returned me to: *storeURL*/index.php?cart_order_id=1**0*1-1**2*4-9**6&_a=complete ?? Line 363 of gateway.class: if($values['Status']=="OK"){ $order->orderStatus(Order::ORDER_PROCESS, $cart_order_id); $order->paymentStatus(Order::PAYMENT_SUCCESS, $cart_order_id); $transData['notes'] = $values['StatusDetail']; } else { $order->orderStatus(Order::ORDER_PENDING, $cart_order_id); $order->paymentStatus(Order::PAYMENT_PENDING, $cart_order_id); $transData['notes'] = $values['StatusDetail']; } $order->logTransaction($transData); httpredir(currentPage(array('_g', 'type', 'cmd', 'module'), array('_a' => 'complete'))); return false; } public function form() { return false; } } Mean anything?! Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 The order details in MySagePay are not corrupted, yet there is a field there that lists the callback URL. How is the callback URL presented to you? Is it listed for each order? You, as the customer, are supposed to be returned to the mentioned address. Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 In mysagepay when viewing the transaction details it is represented as: https://www.fullurl.com/index.php?_g=rm&type=gateway&cmd=process&module=SagePay&cart_order_id=*ORDERNUMBER*A After paying for an item I ended up back on the store with the order page saying "pending" here: https://www.fullurl.com/index.php?cart_order_id=*ORDERNUMBER*&_a=complete Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 In the gateway file, after line 347, add the following:trigger_error(print_r('From SagePay: QueryString: ' . $_SERVER['QUERY_STRING'] , true)); This will place in the admin System Error Log what will be the contents of the GET array sent back by SagePay in the callback URL Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 No error is showing after doing another transaction. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 Stupid me. Try: trigger_error('From SagePay: QueryString: ' . print_r($_SERVER['QUERY_STRING'] , true)); Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 Still no error Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 That is majorly bizarre. Just to be clear, line 347 is: public function process() { Ok, try this. Before line 331 ( $hidden = array( ), add:trigger_error("Data to be encrypted and sent:" . print_r($cryptVars , true)); Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 Yep, here is what I had before: public function process() { trigger_error('From SagePay: QueryString: ' . print_r($_SERVER['QUERY_STRING'] , true)); $Decoded = $this->_decodeAndDecrypt($_REQUEST['crypt']); Will try that now. Cheers Quote Link to comment Share on other sites More sharing options...
Kristoff Posted October 31, 2013 Author Share Posted October 31, 2013 Still no error showing up. Transactions are showing up in the Transaction log: Order Number Sort by Total descending Sort by Total ascendingTotal Sort by Gateway descending Sort by Gateway ascendingGateway Sort by Date descending Sort by Date ascendingDate 131031-*** £0.50 SagePay Today, 19:49 131031-*** £0.50 SagePay Today, 17:38 131031-*** £0.50 SagePay Today, 16:53 But when you go in to them it shows: Transaction ID Status Amount Gateway Date/Time Notes Not Available £0.50 SagePay Today, 19:49 Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 31, 2013 Share Posted October 31, 2013 Hmm. Look at the CubeCart_transactions database table, the last few test purchases, and let us know what's missing (other than 'captured'). If what is missing is no more, no less than 'trans_id', 'status', and 'notes', then I will conclude that the encrypted response from SagePay is not being properly decrypted -- or didn't accompany the callback. Here's something we can try. Near line 350, find: $values = $this->getToken($Decoded); Add the following: if(empty($values)) $values = array('StatusDetail' => "Decoding callback failed."); if(!isset($_REQUEST['crypt']) || empty($_REQUEST['crypt'])) $values['StatusDetail'] .= " Nothing to decrypt."; This will put a message in the Transaction Log, Notes column of troublesome transactions. In the SagePay module settings, do you have Encryption set to XOR or AES? (I am going to dismiss the "A" at the end of the Order Id as seen in your MySagePay screens as a problem with SagePay. We would not be getting this far with a bad cart_order_id.) Stab in the dark: please verify that the server running your site has or has not recently been changed to operate under a 64-bit version of the operating system and/or PHP. I am very concerned that trigger_error() is not putting the argument into the Cubecart admin Error Log, System Error Log. Quote Link to comment Share on other sites More sharing options...
Al Brookbanks Posted November 1, 2013 Share Posted November 1, 2013 Hi Kristoff, the SagePay module has two forms of encryption. AES and XOR. You can choose between them on the module configuration screen. Change it to which ever it isn't now and try again. We have often had issues with the SagePay encryption being decoded wrong by SagePay. The code in CubeCart is from their software development kit so I think its is due to encoding misalignment. Quote Link to comment Share on other sites More sharing options...
Kristoff Posted November 1, 2013 Author Share Posted November 1, 2013 Hi Al, have just tried changing it to AES and still no joy. Do I need to clear the cache? Quote Link to comment Share on other sites More sharing options...
Kristoff Posted November 1, 2013 Author Share Posted November 1, 2013 By the way, i've just been sent a successful referring URL from the old successful transactions: https://www.domain.com/index.php?_g=rm&type=gateway&cmd=process&module=Protx&cart_order_id=*OrderID*X On 2 other old, successful transactions, there is an X at the end instead of an A. Not sure what relevance this does or doesn't have. bssmither, just tried that code and got this: "Decoding callback failed. Nothing to decrypt." Erm, i've just noticed the old gateway also says Protx in the callback?! Could this be an error? I'm assuming that just tells the store which payment system was used? Quote Link to comment Share on other sites More sharing options...
Kristoff Posted November 1, 2013 Author Share Posted November 1, 2013 Could the A or X relate to AES or XOR? if so, any idea why it was sending a callback with A on when I had XOR selected?! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.