Create Order with Java SDK


The Create SDK Order is used to generate a payment token when the backend is built in Java and integrated with any PhonePe Mobile SDK. This token enables secure payment processing within the mobile app.

Use the CreateSdkOrderRequest Builder to create the request and the following are the attributes that you can pass:

Parameter NameData TypeMandatory
(Yes/No)
DescriptionConstraints
merchantOrderIdStringYesUnique order ID generated by youMax length: 63 characters, no special characters except “_” and “-”
amountLongYesOrder amount in paisaMinimum value: 100 (in paisa)
disablePaymentRetryBooleanNoSetting this filed to true will disable retries on standard checkout payment page.
redirectUrlStringNoURL to which the user will be redirected after the payment (success or failure)
Sample Request
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
StandardCheckoutClient client = StandardCheckoutClient.getInstance(clientId, clientSecret,
        clientVersion, env);


String merchantOrderId = UUID.randomUUID()
        .toString();
long amount = 100;
String redirectUrl = "https://www.merchant.com/redirect";

CreateSdkOrderRequest createSdkOrderRequest = CreateSdkOrderRequest.StandardCheckoutBuilder()
        .merchantOrderId(merchantOrderId)
        .amount(amount)
        .disablePaymentRetry(true) // If you want to disable payment retries set this parameter to true
        .redirectUrl(redirectUrl)
        .build();

CreateSdkOrderResponse createSdkOrderResponse = client.createSdkOrder(createSdkOrderRequest);
String token = createSdkOrderResponse.getToken();

The function returns a CreateOrderResponse object with the following properties:

Parameters
Parameter NameData TypeDescription
orderIdStringOrder ID generated by PhonePe PG.
stateStringState of the Order. Initially it will be PENDING.
expireAtLongExpiry time in epoch.
tokenStringToken used by your app to initiate order.

Now that you have understood how to generate a payment token when the backend is built in Java and integrated with any PhonePe Mobile SDK. Let’s proceed to check the status of the order.

Is this article helpful?