...
Code Block | ||
---|---|---|
| ||
// Get an instance of the Google Payments Client. getGooglePaymentsClient() // Load the payment data in console for the transaction. .loadPaymentData(req) // If the payment is successful, process the payment .then(function (res) { // show returned data for debugging console.log(res); // @note DO NOT save the payment credentials for future transactions, // unless they're used for merchant-initiated transactions with user // consent in place. const gatewayReq = getPayrixGatewayRequestData({ gatewayMerchantId: payrixTokenizationSpecification.parameters.gatewayMerchantId, totalPrice: req.transactionInfo.totalPrice, paymentDataResponse: res }); return fetch('{{your_payrix_gateway_url}}', { method: 'POST', headers: { 'Content-Type': 'application/json; charset=UTF-8', 'APIKEY': '{{your_payrix_gateway_apikey}}', }, body: JSON.stringify(gatewayReq), }); }) .then(function (gatewayRes) { if (!gatewayRes.ok) { throw new Error(`Payrix gateway response status: ${gatewayRes.status}`); } return gatewayRes.json(); }) .then(function (gatewayResJson) { if (gatewayResJson.errors && gatewayResJson.errors.length > 0) { throw new Error(`Payrix gateway response errors: ${gatewayResJson.errors}`); } // payment gateway authorizes payment console.log(gatewayResJson); }) // If there is an error, log it to the console. .catch(console.error); |
...
Sandbox Testing
To ensure a smooth integration and functionality of Google Pay on your web platform, follow the steps below to test in both Payrix and Google Pay's sandbox environments.
If you have created a direct integration with Google Pay using your own Google Pay Console account, you can proceed by following the steps in the Integration Checklist provided by Google for Developers. This checklist will guide you through the steps necessary to test your integration in the sandbox environment.
...
Conclusion
In summary, integrating Google Pay for Web with the Payrix gateway effectively processes payments on custom websites. This tutorial outlines essential steps for setting up Google Pay using a standalone button for efficient transaction management.
...