Initiate Payment

Standard checkout Pay

This method is used to initiate a payment via the PhonePe PG.

Merchants can use the StandardCheckoutPayRequest.build_request() to create the request and the following are the attributes that merchant can pass.

Standard checkout Pay Request Builder

Builds Pay Page request.

Attributes

AttributeData TypeMandatoryDescriptionConstraints
merchant_order_idstryesThe unique order ID assigned by the merchant.merchantOrderId length should be less than 63 characters<br/> 2. No Special characters allowed except underscore “_” and hyphen “-“
amountintyesOrder amount in paisa.Minimum value = 1 i.e. 100 paise
redirect_urlstrNoURL where user will be redirected after success/failed payment.

Use the above information as shown in the example below

Example :

from uuid import uuid4 from phonepe.sdk.pg.payments.v2.standard_checkout_client import StandardCheckoutClient from phonepe.sdk.pg.payments.v2.models.request.standard_checkout_pay_request import StandardCheckoutPayRequest from phonepe.sdk.pg.common.models.request.meta_info import MetaInfo from phonepe.sdk.pg.env import Env client_id = "<YOUR_CLIENT_ID>" client_secret = "<YOUR_CLIENT_SECRET>" client_version = 1 # Insert your client version here env = Env.SANDBOX # Change to Env.PRODUCTION when you go live should_publish_events = False client = StandardCheckoutClient.get_instance(client_id=client_id, client_secret=client_secret, client_version=client_version, env=env, should_publish_events=should_publish_events) unique_order_id = str(uuid4()) ui_redirect_url = "https://www.merchant.com/redirect" amount = 100 meta_info = MetaInfo(udf1="udf1", udf2="udf2", udf3="udf3") standard_pay_request = StandardCheckoutPayRequest.build_request(merchant_order_id=unique_order_id, amount=amount, redirect_url=ui_redirect_url, meta_info=meta_info) standard_pay_response = client.pay(standard_pay_request) checkout_page_url = standard_pay_response.redirect_url

Returns :

The function returns a StandardCheckoutPayResponse object with the following properties:

StandardCheckoutPayResponse properties

Here is the response property table for the given model:

AttributeData TypeDescription
statestrState of the order created, Expected value is PENDING
redirect_urlstrThe url for the PG Standard Checkout (merchant is supposed to redirect user to complete payment)
order_idstrPG generated internal order id
expire_atstrOrder expiry date in epoch