Payment Flow

  1. On the checkout screen, merchants call the v4/debit API call with merchantId, transactionId, transaction details and the extra property paymentScope: MSITE_INTENT as payload. Please check this for more details
  2. PhonePe returns a redirect URL with transaction id in the response object
  3. Create a paymentRequest object by providing the below objects as arguments in the constructor:
const supportedInstruments = [{
  supportedMethods: "https://mercury-uat.phonepe.com/transact/pay",
  // For PreProd: "https://mercury-uat.phonepe.com/transact/pay",
  // For Prod: "https://mercury-t2.phonepe.com/transact/pay",
  data: {
     url: redirectUrl //redirect uri returned by v4/debit api call
  }
}];

const details = {
  id: id // A unique transaction id/ if not passed browser will generate one...,
  total: {
    label: 'Total',
    amount: {
      // Amount details goes here...
    }
  }
};
  1. Check if hasEnrolledInstrument() method is supported then hasEnrolledInstrument() method and not supported then use canMakePayment() method call, to make sure that phonepe/pay method is supported by the browser and then show the “Pay by Phonepe”. Once a user clicks on the “Pay by Phonepe” button call show() method on PaymentRequest object, this will open the phonepe app where users can use various payment options to complete the transaction. Handle the callback for the show() method, on successful payment response, will be an app status, txnRef id, etc.