Carlos Arturo Alaniz
Carlos Arturo Alaniz

Reputation: 428

Using GooglePay with CyberSource Gateway

I'm currently using the PHP Simple Order Api REST client https://github.com/CyberSource/cybersource-rest-client-php

Both developers guides found on

Describe the same way to format the data obtained through google pay. They however describe different ways to format the request.

1) Set the encryptedPayment_data field to the value of the
encryptedMessage field that was returned in the Full Wallet 
response.

2) Set the paymentSolution field to 012. 

and

2) In the authorization request under the paymentInformation 
object, set the key field under the fluidData object to the 
Base64-encoded value obtained from the Google Pay blob.

3) Under the processingInformation object, set the 
paymentSolution field to 012.

I'm using the I tried the fluidData way since I couldn't find reference of an encryptedPayment field reference in Simple Order API but it's not working.

Request

{
    "clientReferenceInformation": {
        "code": "testcode"
    },
    "processingInformation": {
        "paymentSolution": "012"
    },
    "paymentInformation": {
        "fluidData": {
            "key":"<Google Pay Blob>"
        }
    },
    "orderInformation": {
        "amountDetails": {
            "totalAmount": "100.00",
            "currency": "USD"
        },
        "billTo": {
            "firstName": "John",
            "lastName": "Doe",
            "company": "ABC Company",
            "address1": "1 Market St",
            "locality": "san francisco",
            "administrativeArea": "CA",
            "postalCode": "94105",
            "country": "US",
            "email": "[email protected]",
            "phoneNumber": "4158880000"
        }
    }
}

Response

[body] => stdClass Object
        (
            [submitTimeUtc] => 2019-04-10T16:05:39Z
            [status] => INVALID_REQUEST
            [reason] => MISSING_FIELD
            [message] => Declined - The request is missing one or more fields
            [details] => Array
                (
                    [0] => stdClass Object
                        (
                            [field] => recipientInformation.card.number
                            [reason] => MISSING_FIELD
                        )

                )

        )

    [message] => [400] Error connecting to the API (https://apitest.cybersource.com/pts/v2/payments/)

Upvotes: 1

Views: 974

Answers (2)

Alistair Lloyd
Alistair Lloyd

Reputation: 1

OK - adding this in to this question as it was the most frequent one returned when I faced a similar problem with where to put fluidData for Cybersource Google Pay Integration:

Had to trawl deep into the PHP class structure as the documentation was...inconsistent. Here’s what I found:

This is an example using the Cybersource REST Api Samples, which can be found on Github here: https://github.com/CyberSource/cybersource-rest-samples-php

Preconditions / One time setup

Use the Business Dashboard Key Management Screen [ [https://ubctest.cybersource.com/ebc2/app/PaymentConfiguration/KeyManagement] to create a new REST-Shared Secret api key and secret.

Keep these handy, along with your Merchant ID (i.e. thiscompany_12345678) found at the top of the dashboard screen.

Going to assume that you all know how to download these sample PHPs to your server.

Edit the ./Resources/ExternalConfiguration.php file and change these three lines to have the same value as the Shared Secret api and secret, and your merchant id, that you generated in step ‘a’:

  $this->merchantID = "testrest";

  $this->apiKeyID = "08c94330-f618-42a3-b09d-e1e43be5efda";

  $this->secretKey = "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE=";

…and save it.

Other pre-condition – I’m also going to assume that you can generate a Google Pay Token via your app. We’ll come back to this later.

Making a payment test program

In the same library of files, navigate down to ./Samples/Payments/Payments

Copy the file DigitalPaymentGooglePay.php to new file name, say, testPay.php

Edit the testPay.php file, and make the following changes:

aa. Change the value of

$clientReferenceInformationArr = [
        "code" => "xxxx"

    ];

…and replace ‘xxxx’ with an easily remembered string (so you know it is “your” transaction that has been tested.). I use a random order number such as “1234-001”.

Make sure this statement says this (it should already...012 means 'Google Pay'):

$processingInformationArr = [
        "capture" => $capture,

        "paymentSolution" => "012"

];

cc. Immediately under that statement INSERT the following three statements like so:

 $paymentInformationFluidDataSet = [

                   "value" => "yyy…yyy=="

                   ];

$paymentInformationFluidData = new CyberSource\Model\Ptsv2paymentsPaymentInformationFluidData($paymentInformationFluidDataSet);


$paymentInformationArr = [

               "fluidData" => $paymentInformationFluidData

];

** where “yyy…yyy==” is your loooooong Base64 encoded Google Pay token mentioned in step “1e” above”

dd. DELETE or comment out the lines that read:

$paymentInformationTokenizedCardArr = [

        "number" => "4111111111111111",

        "expirationMonth" => "12",

        "expirationYear" => "2020",

        "cryptogram" => "EHuWW9PiBkWvqE5juRwDzAUFBAk=",

        "transactionType" => "1"

];

…and…

  $paymentInformationTokenizedCard = new CyberSource\Model\Ptsv2paymentsPaymentInformationTokenizedCard($paymentInformationTokenizedCardArr);

…and…

$paymentInformationArr = [

    "tokenizedCard" => $paymentInformationTokenizedCard

];

…as these populate the paymentInformation object with the plain old PAN and expiry date, which we do not need as its encoded in the token.

ee. Save it

ff. run it (i.e. php testPay.php)

gg.Celebrate

hh. Take a deep breath and take a long run up to do similarly for Apple Pay.

Upvotes: 0

pkbevans
pkbevans

Reputation: 23

You should be populating paymentInformation->fluidData->value - not "key". Should look something like this:

    "paymentInformation": {
      "fluidData": {
        "value": "eyJzaWduYXR1cmUiOiJNRVlDSVFEOWNseWVWaDdjQ1FQNjhSYjVDYjNYREF1aEZxZzJDcVAxZmxuL0lHQmJ2Z0loQU1oM3YxYlZoRUVwQjFJdThib2VmN01POE1TR1Q0Ni9CenRUcUVTMmpiYysiLCJwcm90b2NvbFZlcnNpb24iOiJFQ3YxIiwic2lnbmVkTWVzc2FnZSI6IntcImVuY3J5cHRlZE1lc3NhZ2VcIjpcIkg2YzFVcUNsQnNVRkFNUGd4aVp3M3V5aFgyaVpEQnlIWWU2NSs3Mnh2MTh4OWZUczZFd1lEc3FNTHNiMnh6aUpqRlZ4Vm1kcXBWTWVSSCtJbTI4WU9PQXcxY05USjBucko3YVdFSlQxY2xZYm4vZy9JS1FWb3Y2Q3FpYzlrTzJGcVpyMWhMWVZmU255ZnhjdXVkNHBvSWgvb0daQXBCMzZOWDBvSktWeG93LzlaR2lKSXBaR3o1VXByYm9pMVl0VlpvOVJiN1NsL3RPTEJyRm5XU2hXem1sbi96V3hobU5hcEN0REVpM005MWtuU2ZhMWg0NVordG0ybWZuVzJub1oxM1pNMURsaGg3UHpmKzZqZ1grK09qbVpLS01nMEk1bEZBcnhReGFLckw5bmRCNmkxTTZ0MjAzTVNhSlRmbjFjY1pXaEF0K3Vlb2EzbVQxdWVveURUL09OaUU5a0dub1dpYjJINjRoNlIvM0oxaHJBdVlpY0p6NTNGcjkvZ09iUTFBT0huclNMTHNuTzJSUUVORmdzTXA5Ri8wOWIycC91NDRBOGt6TE1HT2svdGZPVURXL2V3c1JRcVZzaFEyY1plSjRcXHUwMDNkXCIsXCJlcGhlbWVyYWxQdWJsaWNLZXlcIjpcIkJFQnpZRk13QjlOVjVJenlhZzFFMHBVMGZXK0hYbmxXVm5iN1JZWGVSLzR1K0tmUjJweVhoekJzSXVMOWsvTkNLZFNTOXRpSG1LUzZHUEdjZHozU3dnVVxcdTAwM2RcIixcInRhZ1wiOlwiYktUZVQrSVlBeUgwbWw3VEJuaXpGQVpCa2l0Q2dKS09uTStqOTI3enhWb1xcdTAwM2RcIn0ifQ=="
      }
    },

BTW the REST API and the Simple Order API are two different APIs, with different field names. The Simple Order API is SOAP.

Upvotes: 0

Related Questions