daniil_
daniil_

Reputation: 990

How to receive encrypted payment token data of Google Pay

I'm trying to use Google Pay on my website. Once I confirm the payment Google returns this data structure:

enter image description here

But I need something like this:

{
   "signature":"MEYCIQDTe92wpG6OUgxJ/8Qnr36XzSgjGGCM7R3LwxjgwPYMTAIhAJDrjHG9wEm1BxVM6MMMB+jGTGpi3VScEMVbHIUsObFi",
   "protocolVersion":"ECv2",
   "signedMessage":"{\"encryptedMessage\":\"FY8w/U3IbdsZQovX8ufNGFDOePgc/genRiMjHyvuIBqLY4a6uPz7wI0ra31K6YbFJlAnCjFhTwSvDxAYXw6hlmI8sESO5eM1eZlzfP3+NoKV80OXKvOM/xI/qOQEqpEQEVXx6Bw2EpMMFW8yBaA8XPUNee3EJlUk+/f8lRdRcNmI65QKPLAzUnySo75HzBkSc5It/8/oXdYwR93/K6HRKGZuD+bIaxy3SUvC9ehQqhBoP+A34yQX1knfJ1qjBMhhVVcPZHi+Bg6LXA4ms/lfDdim6D1Epr6XQhc2h4RZ/dT+6Enn81s/8ym+jMMs8kqsW9ib8vkdTARv9AbUu7zeGPrKTCAxwc1n6joRR72dSnNCI9j9sxd9tkuC9wuRyDmjbWT+hRZgLc1v/xzzNImo3NxdKdaPzKBE3t9XQZY5fp3lZELaoXAuxAZYtZ7bX64Mz9c28wD8EM+krvfbmGMiBjIt8EfeH48/SjeaUKfDu+yQnjPJAKbDZPhKJ1jqlY/ChP0Om7spQacT86QUVK/DwfzukwvwwRJkWydNEac5fgfS2T6ToZ+PW4VHbxkDnY/h+B0uwdlNQIL2a3Ar5Q\\u003d\\u003d\",\"ephemeralPublicKey\":\"BGkK4bSvob+e7ZgaNV/4vSJYYa10OJzd3aUk9yPEP6iNBRcfHiD/NTvhKjN4P24l0tEzH3L8TrySl6AczPJpCkw\\u003d\",\"tag\":\"xGEhEfJESIyBSfq2fExWiZxNWelnm3m4i8P7cgsarqg\\u003d\"}"
}

Could you please advice me what should I do to get the second data structure. Thank you!

Upvotes: 1

Views: 1502

Answers (2)

Pawan
Pawan

Reputation: 121

Not sure if this is still an open issue. But here are my 2 cents and might be the answer to your solution.

Please note: This is an answer if you are using WorldPay/Vantiv only.

From your first response above with the token, I believe you are using gateway as "vantiv"

  "gateway": "vantiv"
  "vantiv:merchantPayPageId": "YOUR_PAY_PAGE_ID"
  "vantiv:merchantOrderId": "YOUR_ORDER_ID"
  "vantiv:merchantTransactionId": "YOUR_TRANSACTION_ID"
  "vantiv:merchantReportGroup": "*web"

If you want to get the second response with signature and signedMessage then all you have to do is change the gateway to "worldpay" and you should get the same response:

  "gateway": "worldpay"
  "gatewayMerchantId": "YOUR_WORLDPAY_MERCHANT_ID"

You can find the request here

Upvotes: 0

Soc
Soc

Reputation: 7780

The response that you are after is found under paymentMethodData.tokenizationData.token. However, the contents of this field are determined by the request parameters that you pass to loadPaymentData. Are you able to include the request that was used to generate the above response?

FYI, the following JSFiddle will produce a result similar to what you are after:

const tokenizationSpecification = {
  type: 'DIRECT',
  parameters: {
    'protocolVersion': 'ECv2',
    'publicKey': 'BMzk6xvwPgU8vjB...7KRu4tuRmhm6nv8=',
  }
};

/*
{
  "signature":"MEUCI...TougPg",
  "protocolVersion":"ECv2",
  "signedMessage": "{\"encryptedMessage\":\"VhQuaN...5o0Ny6Y\\u003d\"}"
}
*/

I achieved this by using a DIRECT tokenization specification which is discouraged:

Key Point: The Direct integration allows merchants to decrypt the Google Pay response on their servers. To qualify, you must be Payments Card Industry (PCI) Data Security Standard (DSS) Level 1 compliant. Your servers also need to have the required infrastructure to securely handle users' payment credentials.

Third parties that supply gateway or processing services on behalf of actual merchants aren't eligible to use the Direct integration. For questions about your integration as a payment service provider, contact us.

If you don't meet the necessary prerequisites, we recommend that you use a supported gateway to receive a payment token.

Upvotes: 2

Related Questions