TOKEN
Request
| Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
merchantOrderId | String | yes | Unique order ID generated by merchant |
amount | long | yes | Amount of order in Paisa |
contraints | List | yes | Different type of constraints that must be applied to the payment |
authMode | String | yes | Default to 3DS |
encryptionKeyId | long | yes | KeyId of key which merchant uses to encrypt card number & cvv. |
encryptedToken | String | yes | Encrypted TOKEN number which merchant passes to process card transaction |
encryptedCvv | String | yes | Encrypted CVV of the card with which payment is being initiated. |
cryptogram | String | yes | The cryptogram fetched from the gateway where the card was tokenized. |
panSuffix | String | yes | Last four digits of card number |
cardHolderName | String | yes | Card Holder Name |
expiryMonth | String | yes | Token expiry month |
expiryYear | String | yes | Token expiry year |
merchantUserId | String | yes | The unique identifier of the merchant user. It is used to associate the payment with a specific user. |
Sample Request
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
from phonepe.sdk.pg.common.models.request.meta_info import MetaInfo
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
encryption_key_id = 10
encrypted_cvv = "<encryptedCvv>"
auth_mode = "3DS"
pan_suffix = "7239"
cryptogram = "<cryptogram>"
encrypted_token = "<encryptedToken>"
merchant_user_id = "<merchantUserId>"
card_holder_name = "<cardHolderName>"
expiry_year = "2050"
expiry_month = "08"
ui_redirect_url = "<URL_TO_REDIRECT_USER>"
meta_info = MetaInfo() \
.udf1("free-text-value-1") \
.udf2("free-text-value-2") \
.udf3("free-text-value-3") \
.udf4("free-text-value-4") \
.udf5("free-text-value-5") \
.udf6("free-text-value-6") \
.udf7("free-text-value-7") \
.udf8("free-text-value-8") \
.udf9("free-text-value-9") \
.udf10("free-text-value-10") \
.udf11("ref_11") \
.udf12("tag-12") \
.udf13("user@13") \
.udf14("code.14") \
.udf15("val+15") \
.build()
custom_checkout_pay_request = PgPaymentRequest.build_token_pay_request(
amount=amount,
merchant_order_id=merchant_order_id,
auth_mode=auth_mode,
encryption_key_id=encryption_key_id,
encrypted_cvv=encrypted_cvv,
pan_suffix=pan_suffix,
cryptogram=cryptogram,
card_holder_name=card_holder_name,
expiry_month=expiry_month,
expiry_year=expiry_year,
merchant_user_id=merchant_user_id,
encrypted_token=encrypted_token,
redirect_url=ui_redirect_url,
meta_info=meta_info)
custom_checkout_pay_response = custom_checkout_client.pay(custom_checkout_pay_request)
redirect_url = custom_checkout_pay_response.redirect_url
Response
Extract the redirectUrl from the response received
| Property | Type | Description |
|---|---|---|
orderId | String | Order Id created by PhonePe |
state | String | State of the order. Initially it will be PENDING. |
expireAt | Long | Order expire date in epoch |
redirectUrl | String | Redirect url to perform the transaction |