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
Request Parameters
| Parameter Name | Data Type | Mandatory | Description |
merchantOrderId | String | Yes | Unique merchant order id generated by merchant. |
amount | Long | Yes | Order amount in paisa. |
| List | Yes | Different 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();Response
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 Name | Data Type | Description |
orderId | String | PG generated internal order id. |
state | String | State of the order created, initially it will be PENDING. |
expiryAt | Long | Order expiry date in epoch (in milliseconds). |
IntentUrl | String | Intent url for the amount mentioned. |
qrData | String | QR Data which will be used to generate the QR. |