### Subscription Setup Order Completed Callback Example Source: https://developer.phonepe.com/payment-gateway/enach/webhook-handling This JSON object represents a successful subscription setup order callback from PhonePe. It includes details about the merchant, order, subscription, and payment flow. ```json { "type": "SUBSCRIPTION_SETUP_ORDER_COMPLETED", "event": "subscription.setup.order.completed", "payload": { "merchantId": "TX12345", "merchantOrderId": "MO1774243061089", "orderId": "OMO2603231047412984235557BW", "state": "PENDING", "currency": "INR", "amount": 200, "expireAt": 1774243961270, "metaInfo": { "udf1": "udf1", "udf2": "udf2" }, "paymentFlow": { "type": "SUBSCRIPTION_SETUP", "merchantSubscriptionId": "MS1774243061089", "authWorkflowType": "ZERO", "amountType": "FIXED", "maxAmount": 20000000, "frequency": "MONTHLY", "expireAt": 1774643045000, "subscriptionId": "OMS2603231047412704235838BW", "productType": "ENACH_MANDATE", "authInstrumentType": "NET_BANKING" }, "paymentDetails": [] } } ``` -------------------------------- ### Subscription Setup - Transaction Flow Source: https://developer.phonepe.com/payment-gateway/payment-links/recurring-payments/paylinks-autopay/subscription-setup This example demonstrates setting up a recurring subscription using the TRANSACTION authorization workflow. The amount specified will be the initial debit amount. ```APIDOC ## POST /v1/payments/paylinks/autopay/subscription-setup ### Description Sets up a recurring payment subscription using the TRANSACTION authorization workflow. This is suitable for initial debits or when the exact first debit amount is known. ### Method POST ### Endpoint /v1/payments/paylinks/autopay/subscription-setup ### Headers - **Content-Type**: application/json - **Authorization**: O-Bearer ### Request Body - **merchantOrderId** (String) - Required - Unique order ID generated by the merchant (Max Length: 63 characters, Alphanumeric, underscore, hyphen allowed). - **description** (String) - Optional - Description of the payment (max size 150 characters). - **currency** (String) - Required - Currency of the subscription amount (e.g., INR, USD). - **amount** (Long) - Required - Transaction order amount in paise. For TRANSACTION flow, must be >= 100 or the first debit amount. - **expireAt** (epoch) - Required - Timestamp when the payment link will expire. - **paymentFlow** (Object) - Required - Contains details for the payment flow. - **type** (String) - Required - Allowed value: "SUBSCRIPTION_PAYLINK_SETUP". - **customerDetails** (Object) - Required - Customer information. - **name** (String) - Required - Customer's name. - **phoneNumber** (String) - Required - Customer's phone number. - **email** (String) - Required - Customer's email address. - **subscriptionDetails** (Object) - Required - Subscription configuration. - **subscriptionType** (String) - Required - Allowed value: "RECURRING". - **merchantSubscriptionId** (String) - Required - Unique ID for the subscription (Max Length: 63 characters). - **authWorkflowType** (String) - Required - Allowed value: "TRANSACTION". - **amountType** (String) - Required - Allowed values: "FIXED" or "VARIABLE". - **maxAmount** (Long) - Required - Maximum debit amount in paise (Max Limit: 1500000). - **productType** (String) - Required - Allowed value: "UPI_MANDATE". - **frequency** (String) - Required - Allowed values: DAILY, WEEKLY, MONTHLY, FORTNIGHTLY, BIMONTHLY, QUARTERLY. - **expireAt** (epoch) - Required - Subscription expiration timestamp. - **metaInfo** (Object) - Optional - Additional metadata. - **udf1** to **udf15** (String) - Optional - User-defined fields. ### Request Example ```json { "merchantOrderId": "MO110222000493", "description": "some message", "currency": "INR", "amount": 47900, "expireAt": 2592000, "paymentFlow": { "type": "SUBSCRIPTION_PAYLINK_SETUP", "customerDetails": { "name": "Nikhil", "phoneNumber": "+919845******", "email": "abc@gmail.com" }, "subscriptionDetails": { "subscriptionType": "RECURRING", "merchantSubscriptionId": "MS10022200000483", "authWorkflowType": "TRANSACTION", "amountType": "VARIABLE", "maxAmount": 47900, "productType": "UPI_MANDATE", "frequency": "ON_DEMAND", "expireAt": 2889689282000 }, "metaInfo": { "udf1": "string", "udf2": "string", "udf3": "string", "udf4": "string", "udf5": "string", "udf6": "string", "udf7": "string", "udf8": "string", "udf9": "string", "udf10": "string", "udf11": "string", "udf12": "string", "udf13": "string", "udf14": "string", "udf15": "string" } } } ``` ### Response (Success and Error response details not provided in the source text.) ``` -------------------------------- ### Setting Up Subscription with UPI_COLLECT Source: https://developer.phonepe.com/payment-gateway/autopay/autopay-backend-sdk/java-sdk-autopay/subscription-setup The `setup()` method can initiate subscription setup with `UPI_COLLECT`. Use the `PgPaymentRequest.build_subscription_setup_upi_collect()` builder to start the process. This method requires several attributes to be defined, including merchant order ID, subscription ID, amount, authentication workflow type, amount type, maximum amount, subscription frequency, and the Virtual Payment Address (VPA). Optional parameters include order expiration time, target app, and meta information. ```APIDOC ## Setting Up Subscription with UPI_COLLECT The `setup()` method can also initiate the subscription setup with `UPI_COLLECT`. Use the builder `PgPaymentRequest.build_subscription_setup_upi_collect()` to begin. ### Parameters #### Request Body Parameters - **merchant_order_id** (String) - Required - Unique order ID generated by the merchant. - **merchant_subscription_id** (String) - Required - Unique subscription ID generated by the merchant. - **amount** (Int) - Required - Amount in Paisa (FULL auth – first debit amount, PENNY auth – 200). - **order_expire_at** (Int) - Optional - Epoch timestamp; the order will automatically fail if not completed within the given time (default is 10 minutes). - **auth_workflow_type** (AuthWorkflowType) - Required - Type of setup workflow (TRANSACTION or PENNY_DROP). - **amount_type** (AmountType) - Required - Redemption amount type (FIXED or VARIABLE). - **max_amount** (Int) - Required - Maximum amount up to which redemptions will be allowed. - **frequency** (Frequency) - Required - Subscription frequency (DAILY, WEEKLY, MONTHLY, etc.). - **subscription_expire_at** (Int) - Optional - Subscription expiration timestamp (No operations allowed after expiry, default is 30 years). - **target_app** (String) - Optional - Target app for intent payment mode (e.g., Android package name, or PHONEPE/GPAY/PAYTM for iOS). - **meta_info** (MetaInfo) - Optional - User-defined fields for status checks and callbacks. - **vpa** (String) - Required - Virtual Payment Address (VPA) for which the collect request will be raised. ### Return Values The function returns a `PgPaymentResponse` object with the following properties: - **order_id** (String) - Unique order ID generated by PhonePe. - **state** (String) - State of the order. Initially it will be PENDING. - **expireAt** (Long) - Order expire date in epoch. ### Code Example ```java import com.phonepe.sdk.pg.common.models.request.PgPaymentRequest; import com.phonepe.sdk.pg.common.models.response.PgPaymentResponse; import com.phonepe.sdk.pg.subscription.v2.SubscriptionClient; import com.phonepe.sdk.pg.subscription.v2.models.request.AmountType; import com.phonepe.sdk.pg.subscription.v2.models.request.AuthWorkflowType; import com.phonepe.sdk.pg.subscription.v2.models.request.Frequency; import java.util.UUID; String clientId = ""; String clientSecret = ""; Integer clientVersion = 1; //insert your client version here Env env = Env.SANDBOX; //change to Env.PRODUCTION when you go live SubscriptionClient subscriptionClient = SubscriptionClient.getInstance(clientId, clientSecret, clientVersion, env); String merchantOrderId = UUID.randomUUID().toString(); String merchantSubscriptionId = UUID.randomUUID().toString(); long amount = 200; //In paisa AuthWorkflowType authWorkFlowType = AuthWorkflowType.TRANSACTION; //It can also be AuthWorkFlowType.PENNY_DROP AmountType amountType = AmountType.FIXED; //It can also be AmountType.VARIBALE Frequency frequency = Frequency.ON_DEMAND; String vpa = "VALID_VPA"; long maxAmount = 200; PgPaymentRequest setupRequest = PgPaymentRequest.SubscriptionSetupUpiCollectBuilder() .merchantOrderId(merchantOrderId) .merchantSubscriptionId(merchantSubscriptionId) .amount(amount) .authWorkflowType(authWorkFlowType) .amountType(amountType) .maxAmount(maxAmount) .frequency(frequency) .vpa(vpa) .build(); PgPaymentResponse setupResponse = subscriptionClient.setup(setupRequest); ``` ``` -------------------------------- ### Subscription Setup - Penny Drop Flow Source: https://developer.phonepe.com/payment-gateway/payment-links/recurring-payments/paylinks-autopay/subscription-setup This example shows how to set up a recurring subscription using the PENNY_DROP authorization workflow. This flow is used to verify the customer's bank account by depositing a small amount. ```APIDOC ## POST /v1/payments/paylinks/autopay/subscription-setup ### Description Sets up a recurring payment subscription using the PENNY_DROP authorization workflow. This is primarily for account verification before the first actual debit. ### Method POST ### Endpoint /v1/payments/paylinks/autopay/subscription-setup ### Headers - **Content-Type**: application/json - **Authorization**: O-Bearer ### Request Body - **merchantOrderId** (String) - Required - Unique order ID generated by the merchant (Max Length: 63 characters, Alphanumeric, underscore, hyphen allowed). - **description** (String) - Optional - Description of the payment (max size 150 characters). - **currency** (String) - Required - Currency of the subscription amount (e.g., INR, USD). - **amount** (Long) - Required - Transaction order amount in paise. For PENNY_DROP flow, must be exactly 200. - **expireAt** (epoch) - Required - Timestamp when the payment link will expire. - **paymentFlow** (Object) - Required - Contains details for the payment flow. - **type** (String) - Required - Allowed value: "SUBSCRIPTION_PAYLINK_SETUP". - **customerDetails** (Object) - Required - Customer information. - **name** (String) - Required - Customer's name. - **phoneNumber** (String) - Required - Customer's phone number. - **email** (String) - Required - Customer's email address. - **subscriptionDetails** (Object) - Required - Subscription configuration. - **subscriptionType** (String) - Required - Allowed value: "RECURRING". - **merchantSubscriptionId** (String) - Required - Unique ID for the subscription (Max Length: 63 characters). - **authWorkflowType** (String) - Required - Allowed value: "PENNY_DROP". - **amountType** (String) - Required - Allowed values: "FIXED" or "VARIABLE". - **maxAmount** (Long) - Required - Maximum debit amount in paise (Max Limit: 1500000). - **productType** (String) - Required - Allowed value: "UPI_MANDATE". - **frequency** (String) - Required - Allowed values: DAILY, WEEKLY, MONTHLY, FORTNIGHTLY, BIMONTHLY, QUARTERLY. - **expireAt** (epoch) - Required - Subscription expiration timestamp. - **metaInfo** (Object) - Optional - Additional metadata. - **udf1** to **udf15** (String) - Optional - User-defined fields. ### Request Example ```json { "merchantOrderId": "MO11022210010493", "description": "some message", "currency": "INR", "amount": 200, "expireAt": 2592000, "paymentFlow": { "type": "SUBSCRIPTION_PAYLINK_SETUP", "customerDetails": { "name": "Nikhil", "phoneNumber": "+919845******", "email": "abc@gmail.com" }, "subscriptionDetails": { "subscriptionType": "RECURRING", "merchantSubscriptionId": "MS100120483", "authWorkflowType": "PENNY_DROP", "amountType": "VARIABLE", "maxAmount": 47900, "productType": "UPI_MANDATE", "frequency": "ON_DEMAND", "expireAt": 2889689282000 }, "metaInfo": { "udf1": "string", "udf2": "string", "udf3": "string", "udf4": "string", "udf5": "string", "udf6": "string", "udf7": "string", "udf8": "string", "udf9": "string", "udf10": "string", "udf11": "string", "udf12": "string", "udf13": "string", "udf14": "string", "udf15": "string" } } } ``` ### Response (Success and Error response details not provided in the source text.) ``` -------------------------------- ### Magento Setup and Cache Commands Source: https://developer.phonepe.com/payment-gateway/e-commerce-plugins/magento Execute these Magento-specific commands for setup, dependency injection compilation, and cache flushing. ```bash php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:flush ``` -------------------------------- ### Check Setup Order Status Source: https://developer.phonepe.com/payment-gateway/autopay/standard-checkout/order-status Use this GET request to retrieve the status of a subscription order setup. It can be used to check if the subscription has been successfully created, is still pending user action, has failed, or is complete. ```APIDOC ## GET /checkout/v2/order/{merchantOrderId}/status ### Description This API helps you check whether the subscription has been successfully created, is still pending user action, has failed, or is complete. Once the customer completes the mandate through a Payment Service Provider app, use this API to check the status of a subscription setup after initiating it. ### Method GET ### Endpoint https://api.phonepe.com/apis/pg/checkout/v2/order/{merchantOrderId}/status (Production) https://api-preprod.phonepe.com/apis/pg-sandbox/checkout/v2/order/{merchantOrderId}/status (Sandbox) ### Parameters #### Path Parameters - **merchantOrderId** (String) - Yes - unique merchant order Id generated by the merchant. - **details** (Boolean) - No - `true` returns all attempt details under paymentDetails list; `false` returns only the latest attempt details under paymentDetails list. #### Request Headers - **X-MERCHANT-ID** (String) - Yes - The MerchantID of the end merchant. ### Response #### Success Response (200) - **merchantId** (String) - The ID of the merchant. - **merchantOrderId** (String) - The unique merchant order ID. - **orderId** (String) - The unique order ID generated by PhonePe. - **state** (String) - The current state of the order (e.g., COMPLETED, PENDING, FAILED). - **amount** (Number) - The total amount of the order. - **expireAt** (Number) - The timestamp when the order expires. - **metaInfo** (Object) - Additional metadata associated with the order. - **paymentFlow** (Object) - Details about the payment flow, including subscription-specific information. - **paymentDetails** (Array) - A list of payment attempts made for this order. #### Response Example ```json { "merchantId": "INFINITYSTORE", "merchantOrderId": "TEST_12243", "orderId": "OMO2602231553596470745286", "state": "COMPLETED", "amount": 47900, "expireAt": 1772015036470, "metaInfo": { "udf15": "some meta info of max length 50", "udf14": "some meta info of max length 50", "udf13": "some meta info of max length 50", "udf12": "some meta info of max length 50", "udf5": "some meta info of max length 256", "udf11": "some meta info of max length 50", "udf6": "some meta info of max length 256", "udf10": "some meta info of max length 256", "udf3": "some meta info of max length 256", "udf4": "some meta info of max length 256", "udf1": "some meta info of max length 256", "udf2": "some meta info of max length 256", "udf7": "some meta info of max length 256", "udf8": "some meta info of max length 256" }, "paymentFlow": { "type": "SUBSCRIPTION_CHECKOUT_SETUP", "merchantSubscriptionId": "{{merchantSubId}}", "authWorkflowType": null, "amountType": null, "maxAmount": null, "frequency": null, "expireAt": 1772015036470, "subscriptionId": null }, "paymentDetails": [ { "transactionId": "OM2602231553567707945516", "paymentMode": null, "timestamp": 1771842258086, "amount": 47900, "state": "COMPLETED", "instrument": { "type": "ACCOUNT", "maskedAccountNumber": "XXXXXXX20100", "ifsc": "TEST0000000", "accountType": "SAVINGS" }, "rail": { "type": "UPI", "utr": "712920414278", "vpa": "9999999999@ybl", "umn": "5e0bb6dfccf14nn1gbaf87fae06c3bbf@ybl" }, "splitInstruments": [ { "instrument": { "type": "ACCOUNT", "accountType": "SAVINGS" }, "rail": { "type": "UPI", "utr": "712920414278", "umn": "5e0bb6dfccf14nn1gbaf87fae06c3bbf@ybl" }, "amount": "47900" } ] } ] } ``` ``` -------------------------------- ### Initiate Payment Request with Selected Instruments (Python) Source: https://developer.phonepe.com/payment-gateway/backend-sdk/python-be-sdk/sdk-reference-python/initiate-payment This snippet demonstrates how to initiate a payment request while specifying selected payment instruments. It requires similar setup to the default instrument example, including client credentials and environment configuration. ```Python 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 ``` -------------------------------- ### Setting Up Subscription with UPI_COLLECT Source: https://developer.phonepe.com/payment-gateway/autopay/autopay-backend-sdk/python-sdk-autopay/subscription-setup Initiates a subscription setup using the `setup()` method with UPI_COLLECT. The `PgPaymentRequest.build_subscription_setup_upi_collect()` builder is used to construct the request. ```APIDOC ## Setting Up Subscription with UPI_COLLECT The `setup()` method can also initiate the subscription setup with `UPI_COLLECT`. Use the builder `PgPaymentRequest.build_subscription_setup_upi_collect()` to begin. ### Parameters #### Request Body Parameters - **merchant_order_id** (String) - Mandatory - Unique order ID generated by the merchant. - **merchant_subscription_id** (String) - Mandatory - Unique subscription ID generated by the merchant. - **amount** (Int) - Mandatory - Amount in Paisa (FULL auth – first debit amount, PENNY auth – 200). - **order_expire_at** (Int) - Optional - Epoch timestamp; the order will automatically fail if not completed within the given time (default is 10 minutes). - **auth_workflow_type** (AuthWorkflowType) - Mandatory - Type of setup workflow (TRANSACTION or PENNY_DROP). - **amount_type** (AmountType) - Mandatory - Redemption amount type (FIXED or VARIABLE). - **max_amount** (Int) - Mandatory - Maximum amount up to which redemptions will be allowed. - **frequency** (Frequency) - Mandatory - Subscription frequency (DAILY, WEEKLY, MONTHLY, etc.). - **subscription_expire_at** (Int) - Optional - Subscription expiration timestamp (No operations allowed after expiry, default is 30 years). - **target_app** (String) - Optional - Target app for intent payment mode (e.g., package name for Android, PHONEPE/GPAY/PAYTM for iOS). - **meta_info** (MetaInfo) - Optional - User-defined fields for status checks and callbacks. - **vpa** (String) - Mandatory - Virtual Payment Address (VPA) for which the collect request will be raised. ### Return Values The function will raise a collect request to the provided VPA and returns a `PgPaymentResponse` object. #### Success Response - **order_id** (String) - Unique order ID generated by PhonePe. - **state** (String) - State of the order. Initially it will be PENDING. ``` -------------------------------- ### eNACH Subscription Setup Templates Source: https://developer.phonepe.com/payment-gateway/enach/uat-sandbox Use these templates to simulate success or failure during the eNACH subscription setup process. ```text For Success - "Setup success via Enach" For Failure - "Setup failure via Enach" ``` -------------------------------- ### Install iOS Dependencies Source: https://developer.phonepe.com/payment-gateway/mobile-app-integration/standard-checkout-mobile/ionic/sdk-setup Navigate to the 'ios' directory and run 'pod install' to install the necessary iOS dependencies for the PhonePe SDK. ```bash cd ios pod install ``` -------------------------------- ### Install Dependencies with Composer Source: https://developer.phonepe.com/payment-gateway/backend-sdk/php-be-sdk/sdk-reference-php/installation Run this command in your project's root directory to install the SDK and its dependencies after configuring your composer.json file. ```bash composer install ``` -------------------------------- ### Install Node.js SDK Source: https://developer.phonepe.com/payment-gateway/backend-sdk/nodejs-be-sdk/api-reference-node-js/installation Use this npm command to install the PhonePe PG Backend SDK for Node.js in your project. ```bash npm i @phonepe-pg/pg-sdk-node ``` -------------------------------- ### Get Mandate Setup Details Source: https://developer.phonepe.com/payment-gateway/enach/mandate-setup/get-details Fetches the necessary details to initiate the e-Nach mandate setup process. This includes merchant information, mandate parameters, and available account and authentication modes. ```APIDOC ## GET /apis/b2b-pg/enach/ui/v1/setup/details ### Description Retrieves the details required for setting up an e-Nach mandate. This endpoint provides merchant identification, mandate configuration parameters (like max amount, start/end dates, frequency), and a list of available bank accounts and authentication methods (Net Banking, Debit Card) for the user. ### Method GET ### Endpoint `/apis/b2b-pg/enach/ui/v1/setup/details` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **merchantDetails** (object) - Details of the merchant. - **merchantId** (string) - The unique identifier for the merchant. - **merchantName** (string) - The name of the merchant. - **cancelRedirectUrl** (string) - The URL to redirect the user to if the mandate setup is cancelled. - **mandateDetails** (object) - Configuration details for the mandate. - **maxAmount** (integer) - The maximum amount allowed for the mandate in the smallest currency unit (e.g., paisa). - **startDate** (integer) - The start date of the mandate in epoch milliseconds. - **endDate** (integer) - The end date of the mandate in epoch milliseconds. - **frequency** (string) - The frequency of the mandate (e.g., "ON_DEMAND"). - **account** (array) - A list of bank accounts associated with the user. - **accountNumber** (string) - The masked account number. - **ifsc** (string) - The IFSC code of the bank. - **accountType** (string) - The type of the account (e.g., "SAVINGS", "CURRENT"). - **bankCustomerName** (string) - The name of the account holder. - **bankName** (string) - The name of the bank. - **bankLogoUrl** (string) - The URL for the bank's logo. - **accountSelectionId** (string) - An identifier for selecting this account. - **authMode** (array) - A list of available authentication modes (e.g., "NET_BANKING", "DEBIT_CARD"). #### Response Example ```json { "merchantDetails": { "merchantId": "TXMT8788", "merchantName": "TXMT" }, "cancelRedirectUrl": "http://merchant-defined-cancel-redirect-url", "mandateDetails": { "maxAmount": 20000000, "startDate": 1756103400000, "endDate": 1787639400000, "frequency": "ON_DEMAND" }, "account": [ { "accountNumber": "**********4872", "ifsc": "HDFC0101", "accountType": "SAVINGS", "bankCustomerName": "Davneet", "bankName": "HDFC Bank", "bankLogoUrl": "http:\\/\\/hdfc_logo.png", "accountSelectionId": "..." } ], "authMode": [ "NET_BANKING", "DEBIT_CARD" ] } ``` ``` -------------------------------- ### Get eNACH Mandate Status Source: https://developer.phonepe.com/payment-gateway/enach/mandate-setup/get-status This endpoint retrieves the status of an eNACH mandate setup. You can use this to monitor the progress of mandate registrations. ```APIDOC ## GET /enach/ui/v1/setup/status ### Description Retrieves the current status of an eNACH mandate setup. ### Method GET ### Endpoint `/enach/ui/v1/setup/status` ### Query Parameters - **merchantId** (string) - Required - The unique identifier for the merchant. - **transactionId** (string) - Required - The unique identifier for the transaction. - **subMerchantId** (string) - Optional - The unique identifier for the sub-merchant, if applicable. ### Response #### Success Response (200) - **status** (string) - The current status of the eNACH mandate. Possible values are "PENDING", "SUCCESS", or "FAILED". ### Response Example ```json { "status": "PENDING" } ``` ``` -------------------------------- ### Get Redirect URL Source: https://developer.phonepe.com/payment-gateway/enach/mandate-setup/get-redirecturl This API retrieves a redirect URL required for the eNach mandate setup process. It is available for both sandbox and production environments. ```APIDOC ## GET /apis/b2b-pg/enach/ui/v1/redirect-url ### Description Retrieves a redirect URL for initiating the eNach mandate setup process. ### Method GET ### Endpoint `/apis/b2b-pg/enach/ui/v1/redirect-url` ### Parameters This endpoint does not have any documented parameters. ### Request Example This endpoint does not require a request body. ### Response #### Success Response (200) - **redirectUrl** (string) - The URL to which the user will be redirected to complete the mandate setup. #### Response Example ```json { "redirectUrl": "http://merchant-defined-redirect-url" } ``` ``` -------------------------------- ### Sample Payment Request with Exception Handling Source: https://developer.phonepe.com/payment-gateway/backend-sdk/java-be-sdk/sdk-reference-java/webhook-handling Demonstrates how to initiate a payment request using the StandardCheckoutClient and handle potential PhonePeExceptions. Includes setup for the client and building the payment request. Ensure to replace placeholder values with your actual credentials and details. ```java import java.util.Map; import com.phonepe.sdk.pg.Env; import com.phonepe.sdk.pg.common.exception.PhonePeException; import com.phonepe.sdk.pg.payments.v2.StandardCheckoutClient; import com.phonepe.sdk.pg.payments.v2.models.request.StandardCheckoutPayRequest; import com.phonepe.sdk.pg.payments.v2.models.response.StandardCheckoutPayResponse; String clientId = ""; String clientSecret = ""; Integer clientVersion = ; //insert your client version here Env env = Env.SANDBOX; //change to Env.PRODUCTION when you go live StandardCheckoutClient client = StandardCheckoutClient.getInstance(clientId, clientSecret, clientVersion, env); String merchantOrderId = ""; //will throw exception long amount = 100; String redirectUrl = "https://merchant.com/redirectUrl"; StandardCheckoutPayRequest standardCheckoutPayRequest = StandardCheckoutPayRequest.builder() .merchantOrderId(merchantOrderId) .amount(amount) .redirectUrl(redirectUrl) .build(); try { StandardCheckoutPayResponse standardCheckoutPayResponse = client.pay(standardCheckoutPayRequest); } catch (PhonePeException phonePeException) { Integer httpStatusCode = phonePeException.getHttpStatusCode(); String message = phonePeException.getMessage(); Map data = phonePeException.getData(); String code = phonePeException.getCode(); } ``` -------------------------------- ### Sample Response for Get Status Source: https://developer.phonepe.com/payment-gateway/enach/mandate-setup/get-status This JSON object represents the status of an eNACH mandate setup. Possible values include PENDING, SUCCESS, or FAILED. ```json { "status": "PENDING" // or "SUCCESS" or "FAILED" } ``` -------------------------------- ### Initialize StandardCheckoutClient and Initiate Payment Source: https://developer.phonepe.com/payment-gateway/backend-sdk/java-be-sdk/sdk-reference-java/initiate-payment This snippet shows how to initialize the StandardCheckoutClient with your credentials and environment, then construct and send a StandardCheckoutPayRequest to initiate a payment. It includes configuration for allowed card types, other payment modes, and meta information. ```java String clientId = ""; String clientSecret = ""; Integer clientVersion = clientVersion; //insert your client version here Env env = Env.SANDBOX; //change to Env.PRODUCTION when you go live StandardCheckoutClient client = StandardCheckoutClient.getInstance(clientId, clientSecret, clientVersion, env); String merchantOrderId = UUID.randomUUID().toString(); long amount = 100; String redirectUrl = "https://redirecturl.com"; MetaInfo metaInfo = MetaInfo.builder() .udf1("udf1") .udf2("udf2") .udf3("udf3") .udf4("udf4") .udf5("udf5") .build(); Set < CardType > allowedCardTypes = new HashSet < > (); allowedCardTypes.add(CardType.DEBIT_CARD); allowedCardTypes.add(CardType.CREDIT_CARD); PaymentModeConstraint cardPaymentModeConstraint = CardPaymentModeConstraint.builder() .cardTypes(allowedCardTypes) .build(); PaymentModeConstraint netbanking = NetBankingPaymentModeConstraint.builder().build(); PaymentModeConstraint upiIntent = UpiIntentPaymentModeConstraint.builder().build(); PaymentModeConstraint upiQr = UpiQrPaymentModeConstraint.builder().build(); PaymentModeConstraint upiCollect = UpiCollectPaymentModeConstraint.builder().build(); PaymentModeConfig paymentModeConfigEnabled = PaymentModeConfig.builder() .enabledPaymentModes(Arrays.asList(cardPaymentModeConstraint, netbanking, upiIntent, upiQr)) .build(); StandardCheckoutPayRequest standardCheckoutPayRequest = StandardCheckoutPayRequest.builder() .merchantOrderId(merchantOrderId) .amount(amount) .redirectUrl(redirectUrl) .metaInfo(metaInfo) .paymentModeConfig(paymentModeConfigEnabled) .message("Message that will be visible in collect message") .expireAfter(3600L) .build(); StandardCheckoutPayResponse standardCheckoutPayResponse = client.pay(standardCheckoutPayRequest); String checkoutPageUrl = standardCheckoutPayResponse.getRedirectUrl(); ``` -------------------------------- ### Check Order Status API Endpoint Source: https://developer.phonepe.com/payment-gateway/autopay/standard-checkout/order-status Use the GET method to retrieve the status of a subscription order setup. The endpoint varies between sandbox and production environments. ```HTTP GET https://api-preprod.phonepe.com/apis/pg-sandbox/checkout/v2/order/{merchantOrderId}/status ``` ```HTTP GET https://api.phonepe.com/apis/pg/checkout/v2/order/{merchantOrderId}/status ``` -------------------------------- ### Java SDK: Subscription Setup with UPI_COLLECT Source: https://developer.phonepe.com/payment-gateway/autopay/autopay-backend-sdk/java-sdk-autopay/subscription-setup Use this code to set up a subscription using the UPI_COLLECT method. Ensure you have the necessary client details and environment configuration. The `setup()` method initiates a collect request to the provided VPA. ```java import com.phonepe.sdk.pg.common.models.request.PgPaymentRequest; import com.phonepe.sdk.pg.common.models.response.PgPaymentResponse; import com.phonepe.sdk.pg.subscription.v2.SubscriptionClient; import com.phonepe.sdk.pg.subscription.v2.models.request.AmountType; import com.phonepe.sdk.pg.subscription.v2.models.request.AuthWorkflowType; import com.phonepe.sdk.pg.subscription.v2.models.request.Frequency; import java.util.UUID; String clientId = ""; String clientSecret = ""; Integer clientVersion = 1; //insert your client version here Env env = Env.SANDBOX; //change to Env.PRODUCTION when you go live SubscriptionClient subscriptionClient = SubscriptionClient.getInstance(clientId, clientSecret, clientVersion, env); String merchantOrderId = UUID.randomUUID().toString(); String merchantSubscriptionId = UUID.randomUUID().toString(); long amount = 200; //In paisa AuthWorkflowType authWorkFlowType = AuthWorkflowType.TRANSACTION; //It can also be AuthWorkFlowType.PENNY_DROP AmountType amountType = AmountType.FIXED; //It can also be AmountType.VARIBALE Frequency frequency = Frequency.ON_DEMAND; String vpa = "VALID_VPA"; long maxAmount = 200; PgPaymentRequest setupRequest = PgPaymentRequest.SubscriptionSetupUpiCollectBuilder() .merchantOrderId(merchantOrderId) .merchantSubscriptionId(merchantSubscriptionId) .amount(amount) .authWorkflowType(authWorkFlowType) .amountType(amountType) .maxAmount(maxAmount) .frequency(frequency) .vpa(vpa) .build(); PgPaymentResponse setupResponse = subscriptionClient.setup(setupRequest); ``` -------------------------------- ### C# Example for Checking Payment Status Source: https://developer.phonepe.com/offline-integration/refund-flow/check-payment-status-api This C# code demonstrates how to send a request to the PhonePe StatusCheck API and generate the necessary 'x-verify' header. Ensure you have the Newtonsoft.Json library installed for JSON deserialization. ```csharp using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Net; using System.Text; using System.Security.Cryptography; using Newtonsoft.Json; namespace Rextester { public class Program { private const string PHONEPE_STAGE_BASE_URL = "https://mercury-uat.phonepe.com/enterprise-sandbox"; private string merchantKey = "8289e078-be0b-484d-ae60-052f117f8deb"; private const string merchantId = "M2306160483220675579140"; private string transactionId = "mer_order_8"; public bool SendCheckPaymentStatusRequest() { string headerString = String.Format("/v3/transaction/{0}/{1}/status{2}", merchantId, transactionId, merchantKey); Console.WriteLine("headerString: " + headerString); string checksum = GenerateSha256ChecksumFromBase64Json("", headerString); checksum = checksum + "###1"; Console.WriteLine(checksum); bool result = CallPhonePeStatusApi(checksum); return result; } private bool CallPhonePeStatusApi(String xVerify) { Console.WriteLine("CallPhonePeStatusApi ()"); string txnURL = PHONEPE_STAGE_BASE_URL; String urlSuffix = String.Format("/v3/transaction/{0}/{1}/status", merchantId, transactionId); txnURL = txnURL + urlSuffix; Console.WriteLine("Url: " + txnURL); try { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(txnURL); webRequest.Method = "GET"; webRequest.ContentType = "application/json"; webRequest.Headers.Add("x-verify", xVerify); string responseData = string.Empty; using (StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream())) { responseData = responseReader.ReadToEnd(); if (responseData.Length > 0) { PhonePeStatusResponseBody responseBody = JsonConvert.DeserializeObject(responseData); Console.WriteLine(responseData); Console.WriteLine(responseBody.message); } } } catch (Exception e) { Console.WriteLine(e); return false; } return false; } // calculate SHA256 private string GenerateSha256ChecksumFromBase64Json(string base64JsonString, string jsonSuffixString) { string checksum = null; SHA256 sha256 = SHA256.Create(); string checksumString = base64JsonString + jsonSuffixString; byte[] checksumBytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(checksumString)); checksum = BitConverter.ToString(checksumBytes).Replace("-", string.Empty); return checksum; } public static void Main(string[] args){ ``` -------------------------------- ### Subscription Setup Response Source: https://developer.phonepe.com/payment-gateway/enach/subscription-setup/setup This is a sample response received after initiating a subscription setup. It contains the order ID, current state, and a redirect URL for authentication. ```json { "orderId" : "OMO123", "state" : "PENDING", "redirectUrl" : "http-redirect-url" } ``` -------------------------------- ### Initialize StandardCheckoutClient Source: https://developer.phonepe.com/payment-gateway/backend-sdk/nodejs-be-sdk/api-reference-node-js/class-initialization Instantiate the StandardCheckoutClient once with your unique credentials and desired environment. Ensure client secret is stored securely. Use Env.SANDBOX for testing and switch to Env.PRODUCTION for live transactions. ```javascript import { StandardCheckoutClient, Env } from 'pg-sdk-node'; const clientId = ""; const clientSecret = ""; const clientVersion = ; //insert your client version here const env = Env.SANDBOX; //change to Env.PRODUCTION when you go live const client = StandardCheckoutClient.getInstance(clientId, clientSecret, clientVersion, env); ``` -------------------------------- ### Java - Initialize Dynamic QR Request Source: https://developer.phonepe.com/offline-integration/dynamic-qr-solution/dqr-init-api Sets up the parameters for a dynamic QR code initialization request and prepares for making the API call. Includes sample request parameters. ```java public static void main(String[] args) throws Exception, IOException { String apiUrl = "https://mercury-uat.phonepe.com/enterprise-sandbox/v3/qr/init"; // Request parameters Map params = new HashMap(); params.put("merchantId", "PATNAUAT"); params.put("transactionId", "TX1234567890104"); params.put("merchantOrderId", "M1234567013"); params.put("amount", (long) 100); params.put("expiresIn", (long) 1800); params.put("storeId", "store1"); params.put("terminalId", "terminal1"); ``` -------------------------------- ### Subscription Setup Request (JSON) Source: https://developer.phonepe.com/payment-gateway/autopay/api-integration/api-reference/subscription-setup This is a sample JSON request body for setting up a subscription. It includes details like order ID, amount, expiry, and payment flow configuration. ```json { "merchantOrderId": "M27", "amount": 100, "expireAt": 1807681114000, "paymentFlow": { "type": "SUBSCRIPTION_SETUP", "merchantSubscriptionId": "MS27", "authWorkflowType": "TRANSACTION", "amountType": "FIXED", "maxAmount": 100, "frequency": "ON_DEMAND", "expireAt": 1807681114000, "paymentMode": { "type": "UPI_INTENT", "targetApp": "com.phonepe.app" } }, "deviceContext": { "deviceOS": "ANDROID" }, "metaInfo": { "udf1": "some meta info of max length 256", "udf2": "some meta info of max length 256", "udf3": "some meta info of max length 256", "udf4": "some meta info of max length 256", "udf5": "some meta info of max length 256", "udf6": "some meta info of max length 256", "udf7": "some meta info of max length 256", "udf8": "some meta info of max length 256", "udf10": "some meta info of max length 256", "udf11": "some meta info of max length 50", "udf12": "some meta info of max length 50", "udf13": "some meta info of max length 50", "udf14": "some meta info of max length 50", "udf15": "some meta info of max length 50" } } ``` -------------------------------- ### Install CocoaPods Source: https://developer.phonepe.com/payment-gateway/mobile-app-integration/standard-checkout-mobile/ios/sdk-setup Run this command in your terminal to install CocoaPods if it's not already on your system. CocoaPods is required for installing the PhonePePayment SDK. ```bash sudo gem install cocoapods ``` -------------------------------- ### Install PhonePe JS SDK using NPM Source: https://developer.phonepe.com/switch/documentation/faqs-for-troubleshooting/downloading-js-sdk-using-npm-package Use this command to install the PhonePe JS SDK from the NPM registry. Ensure you have Node.js and npm installed on your system. ```bash npm install phonepesdk-web ``` -------------------------------- ### Account Response Example Source: https://developer.phonepe.com/offline-integration/integrated-edc-solution/edc-status-check-api Example JSON response for a successful payment using an account. ```json { "success": true, "code": "SUCCESS", "message": "Your request has been successfully completed.", "data": { "merchantId": "MERCHANTUAT", "storeId": "teststore1", "terminalId": "testTerminal1", "orderId": "MRCH124", "transactionId": "TXN0011113211_18OCT04", "referenceNumber": "457143042016", "paymentMode": "DQR", "amount": 0, "status": "SUCCESS", "responseCode": "null", "paymentInstruments": [ { "type": "ACCOUNT", "amount": 100, "upiTransactionId": "YBL4b8450b7e81e46bc962fbee3ee855945" } ], "timestamp": 1729252056166 } } ``` -------------------------------- ### Initialize PG SDK for Production Source: https://developer.phonepe.com/payment-gateway/native-sdks/ios-native-sdk/sdk-setup Initialize the PPPayment class with the production environment, a flow ID, and your merchant ID. Enable logging only for debugging purposes in non-production environments. ```swift let ppPayment = PPPayment(environment: .production, flowId: "FLOW_ID", merchantId: "MERCHANT_ID") ``` -------------------------------- ### Wallet Response Example Source: https://developer.phonepe.com/offline-integration/integrated-edc-solution/edc-status-check-api Example JSON response for a successful payment using a wallet. ```json { "success": true, "code": "SUCCESS", "message": "Your request has been successfully completed.", "data": { "merchantId": "MERCHANTUAT", "storeId": "teststore1", "terminalId": "testTerminal1", "orderId": "MRCH124", "transactionId": "TXN0011113211_18OCT05", "referenceNumber": "457143042016", "paymentMode": "DQR", "amount": 0, "status": "SUCCESS", "responseCode": "null", "paymentInstruments": [ { "type": "WALLET", "amount": 100 } ], "timestamp": 1729252209353 } } ``` -------------------------------- ### Initialize Podfile Source: https://developer.phonepe.com/payment-gateway/mobile-app-integration/standard-checkout-mobile/ios/sdk-setup Add this line to your Podfile under the target block to include the PhonePePayment SDK. ```ruby pod 'PhonePePayment' ``` -------------------------------- ### iOS Pod Install Source: https://developer.phonepe.com/payment-gateway/mobile-app-integration/standard-checkout-mobile/react-native/sdk-setup Install iOS dependencies using CocoaPods after adding the native configuration. ```bash cd ios pod install ```