Create Order with .NET SDK
Request Details
| 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) |
Sample Request
public async Task<IActionResult> CustomSdkOrder()
{
var merchantOrderID = $"SDK_Order_{DateTime.UtcNow:yyyyMMddHHmmssfff}";
var sdkOrderRequest = CreateSdkOrderRequest.CustomCheckoutBuilder()
.SetMerchantOrderId(merchantOrderID)
.SetAmount(100)
.SetExpireAfter(300)
.Build();
try
{
var response = await _customCheckoutClient.CreateSdkOrder(sdkOrderRequest);
_logger.LogInformation("Custom SDK Order Response:\n{Response}", JsonSerializer.Serialize(response, new JsonSerializerOptions { WriteIndented = true }));
return Ok(response);
}
catch (Exception ex)
{
_logger.LogError(ex, "Custom CreateSdkOrder API Failed");
return StatusCode(500, new { message = ex.Message });
}
}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. |