Introduction to Autopay


Managing recurring payments can be a hassle – PhonePe simplifies the process by providing  an easy and secure solution with autopay feature, helping you streamline your billing processes. With a one-time authorization from your customer, you can schedule automatic deductions at specified periods, eliminating the need for the customer’s repeated involvement. This approach is particularly useful for services like OTT subscriptions, insurance premiums, and memberships, where regular payments are expected.

To set up Autopay transactions, you will integrate with PhonePe’s API framework, which involves two main APIs setup and also to help enhance and support the autopay feature, we have other APIs.

The following user journey illustrates the complete payment lifecycle to help you understand the integration flow clearly.

Before you start the integration process, ensure you have:

  • Access to PhonePe PG’s UAT (User Acceptance Testing) and production environments
  • API credentials, including the client ID and client secret
  • A basic understanding of HTTP methods (GET, POST) and JSON
  • A testing environment to simulate payment flows

Use the environment URLs provided below to integrate and test your API calls. The Sandbox environment is meant for testing purposes—it allows you to validate your integration and make sure everything is working correctly without affecting real users or data. Once your integration is fully tested and ready, use the Production environment for live transactions. Always remember to switch the base URL depending on whether you’re working in the Sandbox or Production environment.

EnvironmentAPI
Sandboxhttps://api-preprod.phonepe.com/apis/pg-sandbox/<Endpoint>
Productionhttps://api.phonepe.com/apis/pg/<Endpoint>

📘 Test Before Production!


To ensure a smooth integration, please integrate with the Test environment first and then move to production.

Here’s a quick reference to the key APIs involved in the Autopay flow. Each API plays a specific role—from initiating a transaction to handling refunds and fetching statuses. Use this table to understand which endpoint to call for each step in the Autopay payment lifecycle.

Endpoint Details:
APIMethodEndpoint
AuthorizationPOST/v1/oauth/token
Subscription SetupPOST/subscriptions/v2/setup
Subscription Order StatusGET/subscriptions/v2/order/{merchantOrderId}/status
Subscription StatusGET/subscriptions/v2/{merchantSubscriptionId}/status
Redemption – NotifyPOST/subscriptions/v2/notify
Redemption – ExecutePOST/subscriptions/v2/redeem
Redemption – Order StatusGET/subscriptions/v2/order/{merchantOrderId}/status
Subscription CancelPOST/subscriptions/v2/{merchantSubscriptionId}/cancel
RefundPOST/payments/v2/refund
Refund StatusGET/payments/v2/refund/{merchantRefundId}/status

Now that you are familiar with what Autopay feature offers, the next step is to look at the APIs that you will use to integrate them into your system to enable Autopay.

Is this article helpful?