# Overview of Google Pay Merchant SDK

The **Google Pay Merchant SDK** (or **Google Pay SDK**) is a toolkit that enables
developers to integrate their applications with Google Pay for accepting
payments online. Users making purchases on the developers' apps can make
payments easily and conveniently.

The SDK can be integrated directly by the merchant into their app, or it may be
bundled into the SDK provided by their Payment Gateway (PG) . If you are a
merchant with an existing PG SDK, check with your PG if the Google Pay SDK
functionality can be provided within that PG SDK.

## High level Google Pay SDK flow

![SDK flow](https://developers.google.com/static/pay/india/api/merchant-sdk/images/GPay-merchant-SDK-flow2.png)

1. Merchant app integrated with Google Pay SDK calls the [`IsReadyToPay`](https://developers.google.com/pay/india/api/merchant-sdk/reference/api#isreadytopay) API to check if the user device is ready to pay with Google Pay. Assume the device is ready.
2. Merchant app calls the [`loadPaymentData`](https://developers.google.com/pay/india/api/merchant-sdk/reference/api#loadpaymentdata) API with the required input, which is passed on to Google Pay.
3. Google Pay user selects from available payment methods, and authenticates the payment. The Google Pay server backend is called with instructions to execute the payment.
4. The Google Pay server makes the payment call, either to the merchant's PG or to the user's PSP (Payment Service Provider). The former is used for card payments and for merchants who have UPI payments set up through their PG, while the latter is for cases where the merchant wants to integrate with UPI directly through Google Pay.
5. The payment status is returned to the Google Pay server.
6. The Google Pay client receives the state, and displays it in the UI that is rendered on the merchant app.
7. The Google Pay SDK reverts control to the merchant app. In cases where the
   merchant's PG has provided a response bundle for the merchant, this is
   included in the `gatewayResponse` field.

   1. The Google Pay response can be used for an initial check of payment parameters such as the amount, transaction ID, and payee VPA.
   2. To check the payment status, the merchant needs to do the following:

      - Verify the authenticity of `gatewayResponse`, if the field is populated.
      - Call their PG or acquiring PSP for status, if the `gatewayResponse` field is not populated.
8. The merchant displays the payment status and next steps for fulfilment in
   the merchant app.