Jump to content

Automatically process digital products with sagepay?!


Kristoff
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

		."&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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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	 
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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."

 

:dizzy: 


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?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...