UPI QR

Use the pay() method to initiate a payment via UPI QR. This generates a QR code that the customer can scan using any UPI app to complete the payment.

Request Parameters
Parameter NameData TypeMandatoryDescription
merchantOrderIdStringYesUnique merchant order id generated by merchant.
amountLongYesOrder amount in paisa.
contraintsListYesDifferent type of constraints that must be applied to the payment.
Sample Request
import com.phonepe.sdk.pg.common.models.request.PgPaymentRequest;
import com.phonepe.sdk.pg.common.models.response.PgPaymentResponse;
import java.util.UUID;
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.payments.v2.CustomCheckoutClient;
 
String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = <clientVersion>;  //insert your client version here
Env env = Env.SANDBOX;      //change to Env.PRODUCTION when you go live
 
CustomCheckoutClient customCheckoutClient = CustomCheckoutClient.getInstance(clientId, clientSecret,
        clientVersion, env);
 
String merchantOrderId = UUID.randomUUID().toString();
long amount = 100;
 
PgPaymentRequest pgPaymentRequest = PgPaymentRequest.UpiQrRequestBuilder()
        .amount(amount)
        .merchantOrderId(merchantOrderId)
        .build();
 
PgPaymentResponse pgPaymentResponse = customCheckoutClient.pay(pgPaymentRequest);
String qrData = pgPaymentResponse.getQrData();

Extract the qrData from the response received. This string can be used to render the QR code on your app or website for the customer to scan and complete the payment.

Field NameData TypeDescription
orderIdStringPG generated internal order id.
stateStringState of the order created, initially it will be PENDING.
expiryAtLongOrder expiry date in epoch (in milliseconds).
IntentUrlStringIntent url for the amount mentioned.
qrDataStringQR Data which will be used to generate the QR.
Is this article helpful?