Create Order with .NET SDK


The Create SDK Order is used to generate a payment token when the backend is built in .NET 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)
Description
merchantOrderIdStringYesUnique order ID generated by you
amountLongYesOrder amount in paisa
redirectUrlStringYesURL to which the user will be redirected after the payment (success or failure)
disablePaymentRetryBooleanNoSetting this filed to true will disable retries on standard checkout payment page.
Sample Request
var merchantOrderID = Guid.NewGuid().ToString();

var sdkOrderRequest = CreateSdkOrderRequest.StandardCheckoutBuilder().SetMerchantOrderId(merchantOrderID).SetAmount(100).SetDisablePaymentRetry(true).SetRedirectUrl(redirectUrl).Build();

CreateSdkOrderResponse response = await checkoutClient.CreateSdkOrder(sdkOrderRequest);logger.LogInformation("CreateSDK Order Response:\n{Response}", JsonSerializer.Serialize(response, new JsonSerializerOptions { WriteIndented = true }));

var token = response.Token;

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?