UPI INTENT


Request Details

Parameter NameData TypeMandatoryDescription
merchantOrderIdStringYesUnique order ID generated by merchant
amountlongYesAmount of order in Paisa
contraintsList<InstrumentConstraint>NoDifferent type of constraints that must be applied to the payment
deviceOSStringNoOperating system of the device. Allowed values are:
iOS
ANDROID
merchantCallbackSchemeStringNoRequired only in case targetApp = PHONEPE and deviceOS = IOS
targetAppStringNoThe target app identifier for the UPI Intent flow.
For IOS:
PHONEPE,
GPAY,
PAYTM.
For Android: com.phonepe.app, net.one97.paytm
Sample Request
public async Task<IActionResult> CustomPay()
    {
        var merchantOrderID = $"Order_{DateTime.UtcNow:yyyyMMddHHmmssfff}";

        var metaInfo = MetaInfo.Builder()
                .SetUdf1("xyz")
                .Build();

        var payRequest = PgPaymentRequest.UpiIntentPayRequestBuilder()
        .SetMerchantOrderId(merchantOrderID)
        .SetAmount(100)
        .SetDeviceOS("IOS")
        .SetTargetApp("PHONEPE")
        .SetMerchantCallBackScheme("")
        .SetMetaInfo(metaInfo)
        .SetExpireAfter(300)
        .Build();

        _logger.LogInformation("Custom Pay Request:\n{Request}", JsonSerializer.Serialize(payRequest, JsonOptions.IndentedWithRelaxedEscaping));
        try
        {
            var response = await _customCheckoutClient.Pay(payRequest);
            _logger.LogInformation("Custom Pay Response:\n{Response}", JsonSerializer.Serialize(response, JsonOptions.IndentedWithRelaxedEscaping));
            return Ok(response);
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Custom Pay API Failed");
            return StatusCode(500, new { message = ex.Message });
        }
    }

Extract the intentUrl from the response received.

Response Details

PropertyTypeDescription
orderIdStringOrder Id created by PhonePe
stateStringState of the order. Initially it will be PENDING.
expireAtLongOrder expire date in epoch
IntentUrlStringIntent url according to the targetApp mentioned in the request
Is this article helpful?