vendredi 26 février 2016

FirstData ParameterBag request object is empty - returns error

I have a var_dump of parameters like;

"txndate_processed" => string(17) "26/02/16 10:49:28"
"ccbin" => string(6) "417345666"
"timezone" => string(3) "CET"
"bemail" => string(25) "mike@example.com"
"oid" => string(38) "C-325d6-ae23-4737-ab3d-f8977fb9b"
"saddr2" => string(9) "Blah"
"saddr1" => string(15) "10 King Road"
"bzip" => string(7) "SW1A2HB"
"cccountry" => string(3) "N/A"

But really there is a lot more key/values (about 40). I am using the same exact data in two places. One as a raw string in Postman, the other in my unit test.

Postman returns true. Unit test returns an error;

I have whittled down the problem to one possible cause. Somehow, the unit test is not setting the request object. Here is a sample print out of the Postman one;

  ["httpRequest":protected]=>
  object(Symfony\Component\HttpFoundation\Request)#3387 (20) {
    ["attributes"]=>
    object(Symfony\Component\HttpFoundation\ParameterBag)#3384 (1) {
      ["parameters":protected]=>
      array(0) {
      }
    }
    ["request"]=>
    object(Symfony\Component\HttpFoundation\ParameterBag)#3386 (1) {
      ["parameters":protected]=>
      array(42) {
        ["txndate_processed"]=>
        string(17) "26/02/16 10:49:28"
        ["ccbin"]=>

See. array(42) For the unit test though, this is empty.

This is my code for completing a purchase;

$params['storeId'] = "1234567890";
$params['sharedSecret'] = "secret-password-example";
$params['currency'] = "GBP";

$gateway = Omnipay::create('FirstData_Connect');
$gateway->setStoreId($params['storeId']);
$gateway->setSharedSecret($params['sharedSecret']);

$gateway->initialize($params);
$response = $gateway->completePurchase($params)->send();

There is nothing dynamic being set here at all. Yet with a unit test it doesn't work.

What am I doing wrong?

This is the error I get back; http://ift.tt/1TbIqqG

And that's because all the $this->httpRequest->request->gets above it are empty. But why?

Aucun commentaire:

Enregistrer un commentaire