I'm getting the following error when trying to use SagePay Server (from printing out the response):
["data":protected]=>array(3) {
["VPSProtocol"]=>
string(4) "2.23"
["Status"]=>
string(7) "INVALID"
["StatusDetail"]=>
string(107) "The data in the BillingCountry field you supplied is an invalid length. Must be an ISO 3166-1 country code."
}
but I am passing the value "GB" as the billingCountry which is correct (SagePay expects billingCountry to be alphabetical and a max of 2 characters)
["card"]=>
object(Omnipay\Common\CreditCard)#46 (1) {
["parameters":protected]=>
object(Symfony\Component\HttpFoundation\ParameterBag)#48 (1) {
["parameters":protected]=>
array(11) {
["email"]=>
string(17) "test@test.com"
["billingFirstName"]=>
string(3) "Joe"
["shippingFirstName"]=>
string(3) "Joe"
["billingLastName"]=>
string(6) "Bloggs"
["shippingLastName"]=>
string(6) "Bloggs"
["billingAddress1"]=>
string(9) "Address 1"
["billingAddress2"]=>
string(9) "Address 2"
["billingCity"]=>
string(4) "City"
["billingPostcode"]=>
string(7) "AB1 1BA"
["billingCountry"]=>
string(2) "GB"
["billingPhone"]=>
string(13) "01234 567 890"
}
}
And this is my code:
$response = $this->gateway->Purchase(array(
'description'=> 'Online order',
'currency'=> 'GBP',
'transactionId'=> mt_rand(99, 9999),
'transactionReference' => 'test order',
'amount'=> '1.00',
'returnUrl' => 'http://www.test.com/returnURL/',
'cancelUrl' => 'http://www.test.com/cancelURL/',
'card' => array(
'email' => 'test@test.com',
'clientIp' => '123.123.123.123',
'firstName' => 'Joe',
'LastName' => 'Bloggs',
'billingAddress1' => 'Address 1',
'billingAddress2' => 'Address 2',
'billingCity' => 'City',
'billingPostcode' => 'AB1 1BA',
'billingCountry' => 'GB',
'billingPhone' => '01234 567 890'
)))->send();
I can't work it out as it all looks correct. I think I'm going slightly mad! Am I missing the totally obvious?
Updated 28.07.2014: I have been trying various things including sending the data in different formats:
$formInputData = array(
'firstName' => 'Joe',
'lastName' => 'Bloggs',
'billingAddress1' => '88',
'billingAddress2' => 'Address 2',
'billingCity' => 'City',
'billingPostcode' => '412',
'billingCountry' => 'GB',
'billingPhone' => '01234 567 890',
'email' => 'test@test.com',
'clientIp' => '123.123.123.123'
);
$card = new CreditCard($formInputData);
$transactionID = mt_rand(99, 9999);
$response = $this->gateway->purchase(['amount' => '1.00', 'returnUrl' => 'http://www.example.com/return/', 'transactionId'=> $transactionID, 'description'=> 'Online order', 'transactionReference' => 'test order', 'currency'=> 'GBP', 'card' => $card])->send();
and it doesn't make any difference.
I have also tried sending the same data (but with the addition of test credit card details in the card parameter) to both SagePay Direct and CardSave.
With SagePay Direct I get "The BillingCountry field is missing from the POST".
With CardSave the transaction goes through successfully but I notice that the country field has "N/A" when I look at the transaction history in my CardSave.