UPI INTENT

Request Details

Parameter NameData TypeMandatoryDescription
merchantOrderIdStringyesUnique order ID generated by merchant
amountlongyesAmount of order in Paisa
contraintsListyesDifferent type of constraints that must be applied to the payment
deviceOSStringnoOperating system of the device. Allowed values are:
1. IOS
2. 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

Example : iOS

import uuid

from phonepe.sdk.pg.payments.v2.custom_checkout_client 
import CustomCheckoutClient

from phonepe.sdk.pg.env 
import Env

from phonepe.sdk.pg.common.models.request.pg_payment_request 
import PgPaymentRequest
 
client_id = "<client_id>"
client_secret = "<client_secret>"
client_version = 1  # insert your client version here
env = Env.SANDBOX  # change to Env.PRODUCTION when you go live
 
custom_checkout_client = CustomCheckoutClient.get_instance(client_id=client_id,
                                                           client_version=client_version,
                                                           client_secret=client_secret,
                                                           env=env)
 
merchant_order_id = str(uuid.uuid4())
amount = 100
device_os = "IOS"
target_app = "PHONEPE"
 
custom_checkout_pay_request = PgPaymentRequest.build_upi_intent_pay_request(merchant_order_id=merchant_order_id,
                                                                                    amount=amount,
                                                                                    target_app=target_app,
                                                                                    device_os=device_os)
 
custom_checkout_pay_response = custom_checkout_client.pay(custom_checkout_pay_request)
intent_url = custom_checkout_pay_response.intent_url

Example : Android

import uuid

from phonepe.sdk.pg.payments.v2.custom_checkout_client 
import CustomCheckoutClient

from phonepe.sdk.pg.env 
import Env

from phonepe.sdk.pg.common.models.request.pg_payment_request 
import PgPaymentRequest  
 
client_id = "<client_id>"
client_secret = "<client_secret>"
client_version = 1  # insert your client version here
env = Env.SANDBOX  # change to Env.PRODUCTION when you go live
 
custom_checkout_client = CustomCheckoutClient.get_instance(client_id=client_id,
                                                           client_version=client_version,
                                                           client_secret=client_secret,
                                                           env=env)
 
merchant_order_id = str(uuid.uuid4())
amount = 100
device_os = "ANDROID"
target_app = "com.phonepe.app"
 
custom_checkout_pay_request = PgPaymentRequest.build_upi_intent_pay_request(merchant_order_id=merchant_order_id,
                                                                                    amount=amount,
                                                                                    target_app=target_app,
                                                                                    device_os=device_os)
 
custom_checkout_pay_response = custom_checkout_client.pay(custom_checkout_pay_request)
intent_url = custom_checkout_pay_response.intent_url

Extract the intent_url 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?