0

I’m trying to make a purchase request to a Simulator end point (https://test.sagepay.com/Simulator/VSPDirectGateway.asp), with the following data:

array(35) { ["VPSProtocol"]=> string(4) "2.23" ["TxType"]=> string(7) "PAYMENT" ["Vendor"]=> string(9) "MY VENDOR NAME" ["AccountType"]=> string(1) "E" ["Description"]=> string(13) "My Test Order" ["Amount"]=> string(4) "1.50" ["Currency"]=> string(3) "GBP" ["VendorTxCode"]=> string(1) "3" ["ClientIPAddress"]=> NULL ["ApplyAVSCV2"]=> int(0) ["Apply3DSecure"]=> int(0) ["BillingFirstnames"]=> string(3) "Sam" ["BillingSurname"]=> string(4) "King" ["BillingAddress1"]=> string(1) "1" ["BillingAddress2"]=> string(1) "2" ["BillingCity"]=> string(8) "Brighton" ["BillingPostCode"]=> string(3) "BN1" ["BillingState"]=> string(0) "" ["BillingCountry"]=> string(2) "GB" ["BillingPhone"]=> NULL ["DeliveryFirstnames"]=> NULL ["DeliverySurname"]=> NULL ["DeliveryAddress1"]=> NULL ["DeliveryAddress2"]=> NULL ["DeliveryCity"]=> NULL ["DeliveryPostCode"]=> NULL ["DeliveryState"]=> string(0) "" ["DeliveryCountry"]=> NULL ["DeliveryPhone"]=> NULL ["CustomerEMail"]=> NULL ["CardHolder"]=> string(8) "Sam King" ["CardNumber"]=> string(16) "4012888888881881" ["CV2"]=> string(3) "123" ["ExpiryDate"]=> string(4) "0215" ["CardType"]=> string(4) "visa" }

However, all I repeatedly keep getting back from Sagepay is a validation error:

"The CardHolder field should be between 1 and 50 characters long.”

However, as you can see in the above data array, I’m sending a CardHolder value of ‘Sam King’, which is clearly between 1 and 50 characters long.

For reference, I'm using the Omnipay (https://github.com/thephpleague/omnipay) library to make requests.

Any idea what I could be doing wrong here?

Sam
  • 43
  • 1
  • 4
  • Have you examined the POST body that this built? it could be that it is treating the next attribute as part of the same value due to a bad character or something. Are you encoding your values? – Carl Sep 29 '14 at 10:29
  • Encoding would, I imagine, be handled as part of the Curl preparation in the Omnipay library. I know it leverages Guzzle to form and make its HTTP requests. Reference: https://github.com/thephpleague/omnipay-common – Sam Sep 29 '14 at 11:59
  • Can you show us the final POST string that is sent to sagepay? – Carl Sep 29 '14 at 14:18
  • 1
    If you send NULL values to Sagepay, e.g. a string like `var1&var2&var3&var4`, the API gives very confusing feedback as to what fields are missing. I didn't realise, but Guzzle automatically converts NULL values to `var1&var2&var3`, but empty values to `var1=&var2=var3=`. When sending empty values to required fields, Sagepay will inform you that these fields cannot be empty. However, if you send NULL values, Sagepay almost ignores these, and, in my case, informed me I was missing a field that I had in fact provided. Adding values for all required fields fixed this issue. – Sam Oct 02 '14 at 10:00

0 Answers0