I'm integrating Google Pay into my frontend and backend (Node.js + Express), and running into some confusion around how to properly handle the token returned from the Google Pay API.
Here’s a simplified version of my frontend code:
function processPayment(paymentData) {
const paymentToken = paymentData.paymentMethodData.tokenizationData.token;
console.log('=========== paymentData', paymentData);
console.log('paymentToken', JSON.parse(paymentToken));
// Send the payment token to your backend
fetch('/process-payment', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ paymentToken }),
})
.then(response => response.json())
.then(result => {
if (result.success) {
console.log('Payment successful! Transaction ID:', result.transactionId);
// Redirect to a success page or show a success message
} else {
console.error('Payment failed:', result.error);
// Show an error message to the user
}
})
.catch(error => {
console.error('Error sending payment token to backend:', error);
// Show an error message to the user
});
}
Problem 1: token
doesn't contain the expected id
Instead of a simple token with an id
(like we’re used to with Stripe), I get a structure like this:
{
"signature": "MEUC...",
"intermediateSigningKey": { ... },
"protocolVersion": "ECv2",
"signedMessage": "{\"encryptedMessage\":\"...\"}"
}
This looks like an ECv2-encrypted payload. It doesn’t match the typical token format we pass to our payment processor (Stripe or others). Should I be forwarding the full object as-is to the backend? Or is there an intermediate step required to decrypt or validate this structure?
Problem 2: How do I forward this data to my payment processor?
I’m unsure which APIs to call on the backend, or how to integrate this with our PSP (e.g., Stripe, Monext, or others). Google Pay's docs mention tokenization, but don't clearly explain what to do when you get a payload like this.
Context:
- Using Google Pay’s JS SDK:
.js
- Config is fetched dynamically from
/google-pay-config
- Button renders and opens the GPay sheet correctly
- Docs I’ve read: Monext’s Google Pay integration guide
Question:
- How should I handle the
tokenizationData.token
payload in this format? - Should I send the entire object to the backend, and if so, what kind of API (or PSP integration) is required to process this payment?
Thanks in advance!
I'm integrating Google Pay into my frontend and backend (Node.js + Express), and running into some confusion around how to properly handle the token returned from the Google Pay API.
Here’s a simplified version of my frontend code:
function processPayment(paymentData) {
const paymentToken = paymentData.paymentMethodData.tokenizationData.token;
console.log('=========== paymentData', paymentData);
console.log('paymentToken', JSON.parse(paymentToken));
// Send the payment token to your backend
fetch('/process-payment', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ paymentToken }),
})
.then(response => response.json())
.then(result => {
if (result.success) {
console.log('Payment successful! Transaction ID:', result.transactionId);
// Redirect to a success page or show a success message
} else {
console.error('Payment failed:', result.error);
// Show an error message to the user
}
})
.catch(error => {
console.error('Error sending payment token to backend:', error);
// Show an error message to the user
});
}
Problem 1: token
doesn't contain the expected id
Instead of a simple token with an id
(like we’re used to with Stripe), I get a structure like this:
{
"signature": "MEUC...",
"intermediateSigningKey": { ... },
"protocolVersion": "ECv2",
"signedMessage": "{\"encryptedMessage\":\"...\"}"
}
This looks like an ECv2-encrypted payload. It doesn’t match the typical token format we pass to our payment processor (Stripe or others). Should I be forwarding the full object as-is to the backend? Or is there an intermediate step required to decrypt or validate this structure?
Problem 2: How do I forward this data to my payment processor?
I’m unsure which APIs to call on the backend, or how to integrate this with our PSP (e.g., Stripe, Monext, or others). Google Pay's docs mention tokenization, but don't clearly explain what to do when you get a payload like this.
Context:
- Using Google Pay’s JS SDK:
https://pay.google/gp/p/js/pay.js
- Config is fetched dynamically from
/google-pay-config
- Button renders and opens the GPay sheet correctly
- Docs I’ve read: Monext’s Google Pay integration guide
Question:
- How should I handle the
tokenizationData.token
payload in this format? - Should I send the entire object to the backend, and if so, what kind of API (or PSP integration) is required to process this payment?
Thanks in advance!
Share Improve this question edited Mar 28 at 10:57 bouazra mouheb asked Mar 28 at 10:23 bouazra mouhebbouazra mouheb 213 bronze badges 01 Answer
Reset to default 1You have to send the whole tokenizationData.token
over to monext in the authorization request. The API accepts a card
object and part of the card
object is the paymentData
object. See the below link for more information:
https://docs.monext.fr/display/DT/Object+-+paymentData