google-pay / google-pay-button

Google Pay button - React, Angular, and custom element
Apache License 2.0
256 stars 65 forks source link

JWT solution for react google pay button #301

Open devalensio opened 2 months ago

devalensio commented 2 months ago

Is your feature request related to a problem? Please describe.

Yes, the problem is that the current Google Pay Button implementation in React does not allow the use of the JWT solution provided by the Google Pay API for Web. This solution is crucial for platform partners who manage more than 100 web domains, as it allows the integration of Google Pay without registering individual web domains in the Google Pay & Wallet Console. Specifically, there is no support for passing the authJwt and merchantOrigin parameters in the merchantInfo object, which are necessary for using JWT.

Describe the solution you'd like

Please add support for authJwt and merchantOrigin in the merchantInfo object in the Google Pay Button for React. This would allow developers to use the JWT solution directly in their payment requests.

<GooglePayButton
  environment="TEST"
  paymentRequest={{
    apiVersion: 2,
    apiVersionMinor: 0,
    allowedPaymentMethods: [
      {
        type: 'CARD',
        parameters: {
          allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
          allowedCardNetworks: ['MASTERCARD', 'VISA'],
        },
        tokenizationSpecification: {
          type: 'PAYMENT_GATEWAY',
          parameters: {
            gateway: 'example',
            gatewayMerchantId: 'exampleGatewayMerchantId',
          },
        },
      },
    ],
    merchantInfo: {
      merchantId: '12345678901234567890',
      merchantName: 'Demo Merchant',
      // Add support for these fields:
      // authJwt: 'aaaaa.bbbbb.ccccc',
      // merchantOrigin: 'sub-merchant.com',
    },
    transactionInfo: {
      totalPriceStatus: 'FINAL',
      totalPriceLabel: 'Total',
      totalPrice: '100.00',
      currencyCode: 'USD',
      countryCode: 'US',
    },
  }}
  onLoadPaymentData={paymentRequest => {
    console.log('load payment data', paymentRequest);
  }}
/>

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

-

Additional context Add any other context or screenshots about the feature request here.

Adding support for authJwt and merchantOrigin will significantly ease the integration process for platform partners using the JWT solution. This feature is particularly beneficial for developers who manage multiple sub-merchants under one platform, simplifying the onboarding process and reducing the need to register each domain separately.

dmengelt commented 2 months ago

@devalensio thanks for reporting this. you have a very good point đŸ˜‰ we will look into it...

devalensio commented 2 months ago

Thanks for the response @dmengelt really looking forward to the feature, as of now, I'm considering using the Google Pay script and passing the data manually. However, I would prefer to use a React button library for our Google Pay integration.

dmengelt commented 2 months ago

Yes. For now you would need to integrate using pay.js directly.

devalensio commented 2 months ago

can I contribute to the project for this feature @dmengelt ?

dmengelt commented 2 months ago

@devalensio yes of course! A couple of thoughts: