## PG Pay Page Flow


<br>PG Pay Page has the following flow:

  1. <b>Initiating PAY API request </b> The merchant does a server-to-server call to initiate a payment request ([PAY API](🔗)). In the response to this PAY API call, a URL is returned for the PhonePe payment page for that particular transaction. <br><br>

  2. <b>Redirecting user to PhonePe web page</b> The merchant does a client-side redirection to the URL returned in Step 1. This will take the customer to the PhonePe payment page.<br><br>

  3. <b>Redirecting user to Merchant web page</b> Once the user has completed the payment, PhonePe will redirect to the redirectUrl passed in the request body to give the control back to the merchant. <br><br>

  4. <b>Status verification post redirection to merchant website</b> The merchant should check with their server if the [S2S response](🔗) is received.

  • If S2S is received, the checksum and amount have to be validated and the payment status has to be updated to the frontend.

  • If S2S is not received, then the [PG Check Status API](🔗) should be called and in the response, the amount has to be validated. The order is then placed based on the transaction status provided by PhonePe.<br><br>

  1. <b>Refund</b> In case of any cancellations or returns, a refund will be initiated by the merchant through PhonePe. This refund will be done against the originalTransactionId (The actual transaction id of the forward payment). Refer here for the [Refund API](🔗)