#REM Parameters: #SNIPPET.onPaymentAuthorized ... onPaymentAuthorized callback function name NOTE: I EXPECT to be called from a 'Basket' context, that has a PPCP payment line item, but I also work for a Payment Method object :D Include some general purpose functions used for GooglePay, used for both the payment wall and the payment page Example: #SNIPPET("SNIPPET-PayPalPPCP-GooglePay", "onPaymentAuthorized", "onPaymentAuthorized") #ENDREM var baseRequest = { apiVersion: 2, apiVersionMinor: 0, }, paymentsClient = null, allowedPaymentMethods = null, merchantInfo = null; #REM /* Configure your site's support for payment methods supported by the Google Pay */ #ENDREM function getGoogleIsReadyToPayRequest(allowedPaymentMethods) { return Object.assign({}, baseRequest, { allowedPaymentMethods: allowedPaymentMethods, }); } #REM /* Fetch Default Config from PayPal via PayPal SDK */ #ENDREM async function getGooglePayConfig() { if (allowedPaymentMethods === null || merchantInfo === null) { var googlePayConfig = await paypal.Googlepay().config(); allowedPaymentMethods = googlePayConfig.allowedPaymentMethods; merchantInfo = googlePayConfig.merchantInfo; } return { allowedPaymentMethods, merchantInfo, }; } function getGooglePaymentsClient() { if (paymentsClient === null) { paymentsClient = new google.payments.api.PaymentsClient({ environment: #IF((#LineItemContainer AND #LineItemContainer.Payment.PaymentMethod.IsInTestMode) OR (#IsInTestMode))"TEST"#ELSE#SPACE[0]"PRODUCTION"#ENDIF, #IF( #DEFINED(#SNIPPET.onPaymentAuthorized) ) paymentDataCallbacks: { onPaymentAuthorized: #SNIPPET.onPaymentAuthorized, }, #ENDIF }); } return paymentsClient; } #REM /* Note: the `googlePayConfig` object in this request is the response from `paypal.Googlepay().config()` */ #ENDREM async function getGooglePaymentDataRequest() { var googlePayConfig = await paypal.Googlepay().config(), paymentDataRequest = Object.assign({}, baseRequest); paymentDataRequest.allowedPaymentMethods = googlePayConfig.allowedPaymentMethods; paymentDataRequest.transactionInfo = getGoogleTransactionInfo(); paymentDataRequest.merchantInfo = googlePayConfig.merchantInfo; #IF( #DEFINED(#SNIPPET.onPaymentAuthorized) ) paymentDataRequest.callbackIntents = ["PAYMENT_AUTHORIZATION"]; #ENDIF return paymentDataRequest; } #IF(#LineItemContainer) function getGoogleTransactionInfo(){ return { currencyCode: '#LineItemContainer.CurrencyID', totalPriceStatus: 'FINAL', //countryCode: 'DE', totalPrice: '#LineItemContainer.GrandTotal' // Your amount } } #ENDIF var script = document.createElement('script'); script.type = "text/javascript"; script.setAttribute("defer", false); script.setAttribute("async", true); script.src = "https://pay.google.com/gp/p/js/pay.js"; document.getElementsByTagName('head')[0].appendChild(script);