UPI Intent

UPI Intent is one of the supported instruments available via the Java SDK’s pay() method. Based on the device OS, the targetApp field is configured differently.

Request Parameters
Parameter NameData TypeMandatoryDescription
targetAppStringNoThe target app identifier for the UPI Intent flow.
For IOS:
PHONEPE,
GPAY,
PAYTM.
For Android: com.phonepe.app, net.one97.paytm
merchantOrderIdStringYesUnique merchant order id generated by merchant.
amountLongYesOrder amount in paisa.
contraintsListNoDifferent type of constraints that must be applied to the payment.
deviceOSStringNoOperating system of the device. Allowed values are:
iOS
ANDROID
merchantCallbackSchemeStringNoRequired only in case targetApp = PHONEPE and deviceOS = iOS
Sample Request
import com.phonepe.sdk.pg.common.models.request.PgPaymentRequest;
import java.util.UUID;
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.payments.v2.CustomCheckoutClient;
import com.phonepe.sdk.pg.common.models.response.PgPaymentResponse;
 
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;
String deviceOS = "IOS";
String targetApp = "PHONEPE";
 
PgPaymentRequest pgPaymentRequest = PgPaymentRequest.UpiIntentPayRequestBuilder()
        .merchantOrderId(merchantOrderId)
        .amount(amount)
        .targetApp(targetApp)
        .deviceOS(deviceOS)
        .build();
 
PgPaymentResponse pgPaymentResponse = customCheckoutClient.pay(pgPaymentRequest);
String intentUrl = pgPaymentResponse.getIntentUrl();

Extract the intentUrl from the response received.

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 according to the targetApp mentioned in the request
Is this article helpful?