We were trying to test out Iframe integration payment method, but for some reason it did not work. Every time we got re-directed back to payment review page.

Checking the logs on SagePay shows us this message - Transaction completed but Vendor systems returned INVALID or ERROR in response to notification POST. Transaction CANCELLED by the Vendor..

After few unsuccessful attempts I added a line in "commerce_sagepay_server.inc" to push out on watchdog log what's happening there. My code looks like this

watchdog('test_error', 'Order message %message for order %order_id', array('%message' => $notification['message'], '%order_id' => $order_id), WATCHDOG_NOTICE);

I put it around line 422.

Finally with this small hack I managed to get the contents of $notification['message'], which were - "MD5 did not match - signs of tampering" (see screenshot attached).
Contacted SagePay, they responded that this is our side to make sure that both $_REQUEST["VPSSignature"] and concatenated md5 hash of message contents should match.

Is there any idea why these two do not match?

FYI - We were using SagePay test server.

Comments

pasive’s picture

Managed to solve the problem.
It turns out to be a configuration problem. As SagePay Documentation states - http://www.sagepay.co.uk/file/15366/download-document/SERVER_Integration... on page 68

Please ensure the VendorName is lower case prior to hashing.

So we just went to SagePay settings admin page on Drupal and changed Capital case to lower case. Was easy though.
Later I realised that for some reason SagePay themselves may send you vendor information in Capital case.
So, case of a human error is quite obvious in this situation.
This patch ensures that Vendor name is always lover case before hashing.

pasive’s picture

Status: Active » Needs review
m1n0’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.03 KB

Thanks for this patch, definitely makes sense, I propose a small change here, make sure that vendor_name is always lowercase, even if the override is on - just for the sake of cleaner and more readable code.

  • m1n0 authored 61bc0ee on 7.x-1.x
    Issue #2483211 by pasive, m1n0: Server Iframe integration  produces -...
ikos’s picture

Status: Reviewed & tested by the community » Fixed

Committed thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.