Checks whether Google Pay is available on the current device. Returns true if Google Pay is configured and available
Example:
if (!Eitri.canIUse(31)) {
  return;
}
const googlePayAvailable = await Eitri.googlePay.isAvailable()
// show button based on googlePayAvailable
- API LEVEL
31- Functionality added
Initializes and returns the Google Pay PaymentsClient from Google Pay JavaScript API.
This allows you to construct custom payment requests and interact with the Google Pay API directly.
Example:
if (!Eitri.canIUse(31)) {
  return;
}
const googlePayAvailable = await Eitri.googlePay.isAvailable();
if (!googlePayAvailable) {
  return;
}
// Initialize Google Pay client
const paymentsClient = await Eitri.googlePay.init("TEST"); // or "PRODUCTION"
// minimal paymentDataRequest, please refer to Google Pay API documentation for more details
// https://developers.google.com/pay/api/web/guides/tutorial#full-example
const paymentDataRequest = {
    apiVersion: 2,
    apiVersionMinor: 0,
    allowedPaymentMethods: [{
        type: "CARD",
        parameters: {
            allowedAuthMethods: ["PAN_ONLY", "CRYPTOGRAM_3DS"],
            allowedCardNetworks: ["AMEX", "DISCOVER", "MASTERCARD", "VISA"]
        },
        tokenizationSpecification: {
            type: "PAYMENT_GATEWAY",
            parameters: {
                gateway: "example",
                gatewayMerchantId: "exampleMerchantId",
            },
        }
    }],
    transactionInfo: {
        totalPriceStatus: "FINAL",
        totalPrice: "19.99",
        currencyCode: "USD",
        countryCode: "US",
    },
    merchantInfo: {
        merchantName: "Eitri-App Test",
        merchantId: "243124324321"
    }
};
// Request payment
try {
  const paymentData = await paymentsClient.loadPaymentData(paymentDataRequest);
  console.log("Payment successful:", paymentData.paymentMethodData);
} catch (error) {
  console.error("Payment failed:", error);
}
The Google Pay environment to use ("TEST" or "PRODUCTION"). Defaults to "TEST".
Timeout in milliseconds for loading the Google Pay API script. Defaults to 5000ms.
A Promise that resolves to the Google Pay PaymentsClient object
- API LEVEL
31- Functionality added
Generated using TypeDoc
Functions that allow an Eitri-App to initiate Google Pay on Android devices.