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
metaInfoObjectNoMerchant defined meta info to store additional information.
same data will be returned in status and callback response.
• For udf1 to udf10, there is no constraint and Maximum length for Udf1-10 = 256 characters
• For udf11 to udf15, alphanumeric values with _-+@. are allowed and Maximum length for Udf11-15 = 50 characters
• It is mandatory to keep the parameter names udf1udf2, etc., exactly as they are in the metainfo block. Renaming these key values will result in a production error.
Sample Request
import com.phonepe.sdk.pg.common.models.MetaInfo;
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;
String deviceOS = "IOS";
String targetApp = "PHONEPE";

MetaInfo metaInfo = MetaInfo.builder()
        .udf1("free-text-value-1")
        .udf2("free-text-value-2")
        .udf3("free-text-value-3")
        .udf4("free-text-value-4")
        .udf5("free-text-value-5")
        .udf6("free-text-value-6")
        .udf7("free-text-value-7")
        .udf8("free-text-value-8")
        .udf9("free-text-value-9")
        .udf10("free-text-value-10")
        .udf11("ref_11")
        .udf12("tag-12")
        .udf13("user@13")
        .udf14("code.14")
        .udf15("val+15")
        .build();

PgPaymentRequest pgPaymentRequest = PgPaymentRequest.UpiIntentPayRequestBuilder()
        .merchantOrderId(merchantOrderId)
        .amount(amount)
        .targetApp(targetApp)
        .deviceOS(deviceOS)
        .metaInfo(metaInfo)
        .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?