Create Order with .NET SDK


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)
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 });
        }
    }

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.
Is this article helpful?