Sequence
- Payment Options
- Custom – NetBanking
Payment Options
This method is used to retrieve available payment options.
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
include_net_banking_banks_list | boolean | No | Optional. If set to True, the response will include the list of Net Banking banks. Default: False |
For Python SDK Version **\ 0.0.3**, the imports should be:
from phonepe.sdk.pg.payments.**v1**
For Python SDK Version <= 0.0.3, the imports should be:
from phonepe.sdk.pg.payments
For Python SDK Version > 0.0.3, the imports should be:
from phonepe.sdk.pg.payments.v1
Example – Payment Options
from phonepe.sdk.pg.payments.v1.payment_client import PhonePePaymentClient
from phonepe.sdk.pg.env import Env
merchant_id = "<YOUR_MERCHANT_ID>"
salt_key = "<YOUR_SALT_KEY>"
salt_index = 1 # insert your salt index
env = Env.UAT
should_publish_events = True
phonepe_client = PhonePePaymentClient(merchant_id, salt_key, salt_index, env, should_publish_events)
response = phonepe_client.get_payment_options(include_net_banking_banks_list=True)
Returns
The function returns a PhonePeResponse object with the following properties:
Parameter | Type | Description |
---|---|---|
success | boolean | Success/failure of the request processing |
code | str | Response code explaining the reason for the status |
message | str | Message providing more information about the code |
data | PgOptionsResponse | Available payment options |
PgOptionsResponse Properties
Property | Type | Description |
---|---|---|
upi_collect | PGUpiCollect | UPI Collect options |
intent | PGIntent | Intent options |
cards | PGExternalCards | External cards options |
net_banking | NetBankingOptionsResponse | Net Banking options |
Custom – NetBanking
This method is used to initiate a NetBanking via the PhonePe PG Custom Checkout
Parameters
Parameter | Type | Mandatory | Description |
---|---|---|---|
merchant_transaction_id | str | Yes | The unique transaction ID assigned by the merchant. Note: – merchantTransactionId length should be less than 35 characters – No Special characters allowed except underscore “_” and hyphen “-“ |
amount | int | Yes | The amount of the payment. In paise. Minimum 100 i.e. 1 rupee |
bank_id | str | Yes | The ID of the bank for Net Banking payment. You can find the possible values in get_payment_options response |
merchant_user_id | str | No | The ID assigned to the user by the merchant. Note: – merchantUserId length should be less than 36 characters – No Special characters allowed except underscore “_” and hyphen “-“ |
redirect_url | str | No | The UI URL to redirect the user after a successful payment. |
redirect_mode | str | No | The mode of redirection after payment completion. |
callback_url | str | No | The S2S callback URL to which status notifications will be sent. |
callback_mode | str | No | The mode of callback handling. |
merchant_order_id | str | No | The ID of the order assigned by the merchant. |
device_os | str | No | The operating system of the device used for the payment. Possible values: ANDROID or IOS. |
Example (Custom – NetBanking)
import uuid
from phonepe.sdk.pg.payments.v1.models.request.pg_pay_request import PgPayRequest
from phonepe.sdk.pg.payments.v1.payment_client import PhonePePaymentClient
from phonepe.sdk.pg.env import Env
merchant_id = "<YOUR_MERCHANT_ID>"
salt_key = "<YOUR_SALT_KEY>"
salt_index = 1 # insert your salt index
env = Env.UAT
should_publish_events = True
phonepe_client = PhonePePaymentClient(merchant_id, salt_key, salt_index, env, should_publish_events)
unique_transaction_id = str(uuid.uuid4())[:-2]
s2s_callback_url = "https://www.merchant.com/callback"
amount = 100
id_assigned_to_user_by_merchant = 'YOUR_USER_ID'
bank_id = "<YOUR_BANK_ID>" #You can find the possible values in payment_options(), Eg. HDFC, ICIC
net_banking_payment = PgPayRequest.net_banking_pay_request_builder(merchant_transaction_id=unique_transaction_id,
amount=amount,
bank_id="bank_id")
pay_response = phonepe_client.pay(net_banking_payment)
url = pay_response.data.instrument_response.redirect_info.url
Returns
The pay function returns a PgPayResponse object. With NetBankingInstrumentResponse object in data.