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.
Request
Use the CreateSdkOrderRequest Builder to create the request and the following are the attributes that you can pass:
| Parameter Name | Data Type | Mandatory (Yes/No) | Description |
merchantOrderId | String | Yes | Unique order ID generated by you |
amount | Long | Yes | Order amount in paisa |
redirectUrl | String | Yes | URL to which the user will be redirected after the payment (success or failure) |
disablePaymentRetry | Boolean | No | Setting 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;Response
The function returns a CreateOrderResponse object with the following properties:
Parameters
| Parameter Name | Data Type | Description |
orderId | String | Order ID generated by PhonePe PG. |
state | String | State of the Order. Initially it will be PENDING. |
expireAt | Long | Expiry time in epoch. |
token | String | Token used by your app to initiate order. |
What’s Next?
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.