hyperswitch-funcdiff / prs /pr_10015.json
SirajRLX's picture
Add files using upload-large-folder tool
cd3e498 verified
{
"number": 10015,
"title": "feat(subscriptions): add support to pause, resume and cancel subscription",
"description": "## Type of Change\r\n<!-- Put an `x` in the boxes that apply -->\r\n\r\n- [ ] Bugfix\r\n- [ ] New feature\r\n- [X] Enhancement\r\n- [ ] Refactoring\r\n- [ ] Dependency updates\r\n- [ ] Documentation\r\n- [ ] CI/CD\r\n\r\n## Description\r\n<!-- Describe your changes in detail -->\r\n\r\n1. Add support in subscriptions module to pause, resume, and cancel a subscription\r\n2. Update openapi ref for the newly added flows\r\n\r\n\r\n### Additional Changes\r\n\r\n- [ ] This PR modifies the API contract\r\n- [ ] This PR modifies the database schema\r\n- [ ] This PR modifies application configuration/environment variables\r\n\r\n<!--\r\nProvide links to the files with corresponding changes.\r\n\r\nFollowing are the paths where you can find config files:\r\n1. `config`\r\n3. `crates/router/src/configs`\r\n4. `loadtest/config`\r\n-->\r\n\r\n\r\n## Motivation and Context\r\n<!--\r\nWhy is this change required? What problem does it solve?\r\nIf it fixes an open issue, please link to the issue here.\r\n\r\nIf you don't have an issue, we'd recommend starting with one first so the PR\r\ncan focus on the implementation (unless it is an obvious bug or documentation fix\r\nthat will have little conversation).\r\n-->\r\n#10016 \r\n\r\n## How did you test it?\r\n<!--\r\nDid you write an integration/unit/API test to verify the code changes?\r\nOr did you test this change manually (provide relevant screenshots)?\r\n-->\r\n<details>\r\n<summary>1. Create customer</summary>\r\n\r\nRequest\r\n```\r\ncurl --location 'http://localhost:8080/customers' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept: application/json' \\\r\n--header 'X-tenant-id: public' \\\r\n--header 'api-key: dev_AyM2dBHmwN0PfdX1kCLjYGhrcntGszAZPn806ysy83s4DJ6bVjrZ8C3yUl6rbinR' \\\r\n--data '{\r\n \"email\": \"guest@example.com\",\r\n \"name\": \"John Doe\",\r\n \"phone\": \"999999999\",\r\n \"phone_country_code\": \"+65\",\r\n \"description\": \"First customer\",\r\n \"metadata\": {\r\n \"udf1\": \"value1\",\r\n \"new_customer\": \"true\",\r\n \"login_date\": \"2019-09-10T10:11:12Z\"\r\n },\r\n \"billing\": {\r\n \"address\": {\r\n \"line1\": \"1467\",\r\n \"line2\": \"Harrison Street\",\r\n \"line3\": \"Harrison Street\",\r\n \"city\": \"San Fransico\",\r\n \"state\": \"California\",\r\n \"zip\": \"94122\",\r\n \"country\": \"IN\",\r\n \"first_name\": \"joseph\",\r\n \"last_name\": \"Doe\"\r\n },\r\n \"phone\": {\r\n \"number\": \"123456789\",\r\n \"country_code\": \"+1\"\r\n }\r\n }\r\n}'\r\n```\r\n\r\nResponse\r\n```\r\n{\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"name\": \"John Doe\",\r\n \"email\": \"guest@example.com\",\r\n \"phone\": \"999999999\",\r\n \"phone_country_code\": \"+65\",\r\n \"description\": \"First customer\",\r\n \"address\": null,\r\n \"created_at\": \"2025-10-27T11:45:28.328Z\",\r\n \"metadata\": {\r\n \"udf1\": \"value1\",\r\n \"new_customer\": \"true\",\r\n \"login_date\": \"2019-09-10T10:11:12Z\"\r\n },\r\n \"default_payment_method_id\": null,\r\n \"tax_registration_id\": null\r\n}\r\n```\r\n</details>\r\n\r\n<details>\r\n<summary>2. Subscription create</summary>\r\n\r\nRequest\r\n```\r\ncurl --location 'http://localhost:8080/subscriptions/create' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'X-Profile-Id: pro_hrjhbsMiSK5HrwNkbXo3' \\\r\n--header 'api-key: dev_AyM2dBHmwN0PfdX1kCLjYGhrcntGszAZPn806ysy83s4DJ6bVjrZ8C3yUl6rbinR' \\\r\n--header 'Accept: */*' \\\r\n--data '{\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"item_price_id\": \"standard-plan-USD-Monthly\",\r\n \"amount\": 1200,\r\n \"currency\": \"USD\",\r\n \"payment_details\": {\r\n \"authentication_type\": \"no_three_ds\",\r\n \"setup_future_usage\": \"off_session\",\r\n \"capture_method\": \"automatic\",\r\n \"return_url\": \"https://google.com\"\r\n }\r\n}'\r\n```\r\n\r\nResponse\r\n```\r\n{\r\n \"id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"merchant_reference_id\": null,\r\n \"status\": \"created\",\r\n \"plan_id\": null,\r\n \"item_price_id\": \"standard-plan-USD-Monthly\",\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"client_secret\": \"sub_nVjcfvzeicw3JVrIxIXy_secret_OWTmjNW6rPB6W3WUKY5k\",\r\n \"merchant_id\": \"merchant_1761554619\",\r\n \"coupon_code\": null,\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"payment\": {\r\n \"payment_id\": \"pay_GIcDFItj8ui2jv7rKOPt\",\r\n \"status\": \"requires_payment_method\",\r\n \"amount\": 1200,\r\n \"currency\": \"USD\",\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"connector\": null,\r\n \"payment_method_id\": null,\r\n \"return_url\": \"https://google.com/\",\r\n \"next_action\": null,\r\n \"payment_experience\": null,\r\n \"error_code\": null,\r\n \"error_message\": null,\r\n \"payment_method_type\": null,\r\n \"client_secret\": \"pay_GIcDFItj8ui2jv7rKOPt_secret_N7Bz65Mwf5GLWA7rcSyP\",\r\n \"billing\": null,\r\n \"shipping\": null,\r\n \"payment_type\": null\r\n },\r\n \"invoice\": {\r\n \"id\": \"invoice_pgSvJ8vQHi2LZ90KAUaa\",\r\n \"subscription_id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"merchant_id\": \"merchant_1761554619\",\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"merchant_connector_id\": \"mca_iCf5VJbWivFZqiFJ2Vyb\",\r\n \"payment_intent_id\": \"pay_GIcDFItj8ui2jv7rKOPt\",\r\n \"payment_method_id\": null,\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"amount\": 1200,\r\n \"currency\": \"USD\",\r\n \"status\": \"invoice_created\"\r\n }\r\n}\r\n```\r\n</details>\r\n\r\n<details>\r\n<summary>3. Subscription confirm</summary>\r\n\r\nRequest\r\n```\r\ncurl --location 'http://localhost:8080/subscriptions/sub_nVjcfvzeicw3JVrIxIXy/confirm' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept: application/json' \\\r\n--header 'X-Profile-Id: pro_hrjhbsMiSK5HrwNkbXo3' \\\r\n--header 'api-key: dev_AyM2dBHmwN0PfdX1kCLjYGhrcntGszAZPn806ysy83s4DJ6bVjrZ8C3yUl6rbinR' \\\r\n--data '{\r\n \"payment_details\": {\r\n \"shipping\": {\r\n \"address\": {\r\n \"state\": \"zsaasdas\",\r\n \"city\": \"Banglore\",\r\n \"country\": \"US\",\r\n \"line1\": \"sdsdfsdf\",\r\n \"line2\": \"hsgdbhd\",\r\n \"line3\": \"alsksoe\",\r\n \"zip\": \"571201\",\r\n \"first_name\": \"joseph\",\r\n \"last_name\": \"doe\"\r\n },\r\n \"phone\": {\r\n \"number\": \"123456789\",\r\n \"country_code\": \"+1\"\r\n }\r\n },\r\n \"billing\": {\r\n \"address\": {\r\n \"line1\": \"1467\",\r\n \"line2\": \"Harrison Street\",\r\n \"line3\": \"Harrison Street\",\r\n \"city\": \"San Fransico\",\r\n \"state\": \"California\",\r\n \"zip\": \"94122\",\r\n \"country\": \"US\",\r\n \"first_name\": \"joseph\",\r\n \"last_name\": \"Doe\"\r\n },\r\n \"phone\": {\r\n \"number\": \"123456789\",\r\n \"country_code\": \"+1\"\r\n }\r\n },\r\n \"payment_method\": \"card\",\r\n \"payment_method_type\": \"credit\",\r\n \"payment_method_data\": {\r\n \"card\": {\r\n \"card_number\": \"4111111111111111\",\r\n \"card_exp_month\": \"03\",\r\n \"card_exp_year\": \"2030\",\r\n \"card_holder_name\": \"CLBRW dffdg\",\r\n \"card_cvc\": \"737\"\r\n }\r\n },\r\n \"customer_acceptance\": {\r\n \"acceptance_type\": \"online\",\r\n \"accepted_at\": \"1963-05-03T04:07:52.723Z\",\r\n \"online\": {\r\n \"ip_address\": \"127.0.0.1\",\r\n \"user_agent\": \"amet irure esse\"\r\n }\r\n }\r\n }\r\n}'\r\n```\r\n\r\nResponse\r\n```\r\n{\r\n \"id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"merchant_reference_id\": null,\r\n \"status\": \"active\",\r\n \"plan_id\": null,\r\n \"item_price_id\": \"standard-plan-USD-Monthly\",\r\n \"coupon\": null,\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"payment\": {\r\n \"payment_id\": \"pay_GIcDFItj8ui2jv7rKOPt\",\r\n \"status\": \"succeeded\",\r\n \"amount\": 1200,\r\n \"currency\": \"USD\",\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"connector\": \"stripe\",\r\n \"payment_method_id\": \"pm_IhGYfzsgspMpxwkzRsYL\",\r\n \"return_url\": \"https://google.com/\",\r\n \"next_action\": null,\r\n \"payment_experience\": null,\r\n \"error_code\": null,\r\n \"error_message\": null,\r\n \"payment_method_type\": \"credit\",\r\n \"client_secret\": \"pay_GIcDFItj8ui2jv7rKOPt_secret_N7Bz65Mwf5GLWA7rcSyP\",\r\n \"billing\": {\r\n \"address\": {\r\n \"city\": \"San Fransico\",\r\n \"country\": \"US\",\r\n \"line1\": \"1467\",\r\n \"line2\": \"Harrison Street\",\r\n \"line3\": \"Harrison Street\",\r\n \"zip\": \"94122\",\r\n \"state\": \"California\",\r\n \"first_name\": \"joseph\",\r\n \"last_name\": \"Doe\",\r\n \"origin_zip\": null\r\n },\r\n \"phone\": {\r\n \"number\": \"123456789\",\r\n \"country_code\": \"+1\"\r\n },\r\n \"email\": null\r\n },\r\n \"shipping\": {\r\n \"address\": {\r\n \"city\": \"Banglore\",\r\n \"country\": \"US\",\r\n \"line1\": \"sdsdfsdf\",\r\n \"line2\": \"hsgdbhd\",\r\n \"line3\": \"alsksoe\",\r\n \"zip\": \"571201\",\r\n \"state\": \"zsaasdas\",\r\n \"first_name\": \"joseph\",\r\n \"last_name\": \"doe\",\r\n \"origin_zip\": null\r\n },\r\n \"phone\": {\r\n \"number\": \"123456789\",\r\n \"country_code\": \"+1\"\r\n },\r\n \"email\": null\r\n },\r\n \"payment_type\": null\r\n },\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"invoice\": {\r\n \"id\": \"invoice_pgSvJ8vQHi2LZ90KAUaa\",\r\n \"subscription_id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"merchant_id\": \"merchant_1761554619\",\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"merchant_connector_id\": \"mca_iCf5VJbWivFZqiFJ2Vyb\",\r\n \"payment_intent_id\": \"pay_GIcDFItj8ui2jv7rKOPt\",\r\n \"payment_method_id\": \"pm_IhGYfzsgspMpxwkzRsYL\",\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"amount\": 1200,\r\n \"currency\": \"USD\",\r\n \"status\": \"payment_pending\"\r\n },\r\n \"billing_processor_subscription_id\": \"sub_nVjcfvzeicw3JVrIxIXy\"\r\n}\r\n```\r\n</details>\r\n\r\n<details>\r\n<summary>4. Get Subscription</summary>\r\n\r\nRequest\r\n```\r\ncurl --location 'http://localhost:8080/subscriptions/sub_nVjcfvzeicw3JVrIxIXy' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept: application/json' \\\r\n--header 'X-Profile-Id: pro_hrjhbsMiSK5HrwNkbXo3' \\\r\n--header 'api-key: dev_AyM2dBHmwN0PfdX1kCLjYGhrcntGszAZPn806ysy83s4DJ6bVjrZ8C3yUl6rbinR'\r\n```\r\n\r\nResponse\r\n```\r\n{\r\n \"id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"merchant_reference_id\": null,\r\n \"status\": \"active\",\r\n \"plan_id\": null,\r\n \"item_price_id\": \"standard-plan-USD-Monthly\",\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"client_secret\": \"sub_nVjcfvzeicw3JVrIxIXy_secret_OWTmjNW6rPB6W3WUKY5k\",\r\n \"merchant_id\": \"merchant_1761554619\",\r\n \"coupon_code\": null,\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"payment\": null,\r\n \"invoice\": null\r\n}\r\n```\r\n</details>\r\n\r\n<details>\r\n<summary>5. Pause Subscription</summary>\r\n\r\nRequest\r\n```\r\ncurl --location 'http://localhost:8080/subscriptions/sub_nVjcfvzeicw3JVrIxIXy/pause' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept: application/json' \\\r\n--header 'X-Profile-Id: pro_hrjhbsMiSK5HrwNkbXo3' \\\r\n--header 'api-key: dev_AyM2dBHmwN0PfdX1kCLjYGhrcntGszAZPn806ysy83s4DJ6bVjrZ8C3yUl6rbinR' \\\r\n--data '{\r\n \"pause_option\": \"immediately\"\r\n}'\r\n```\r\n\r\nResponse\r\n```\r\n{\r\n \"id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"status\": \"paused\",\r\n \"merchant_reference_id\": null,\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"merchant_id\": \"merchant_1761554619\",\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"paused_at\": \"2025-08-01 11:32:32.0\"\r\n}\r\n```\r\n</details>\r\n<img width=\"1299\" height=\"133\" alt=\"Screenshot 2025-10-27 at 5 16 25\u202fPM\" src=\"https://github.com/user-attachments/assets/c451cb97-1fa1-4678-9d49-ef7f6eadbd86\" />\r\n\r\n\r\n<details>\r\n<summary>6. Resume Subscription</summary>\r\n\r\nRequest\r\n```\r\ncurl --location 'http://localhost:8080/subscriptions/sub_nVjcfvzeicw3JVrIxIXy/resume' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept: application/json' \\\r\n--header 'X-Profile-Id: pro_hrjhbsMiSK5HrwNkbXo3' \\\r\n--header 'api-key: dev_AyM2dBHmwN0PfdX1kCLjYGhrcntGszAZPn806ysy83s4DJ6bVjrZ8C3yUl6rbinR' \\\r\n--data '{\r\n \"resume_option\": \"immediately\",\r\n \"unpaid_invoices_handling\": \"schedule_payment_collection\" \r\n}'\r\n```\r\n\r\nResponse\r\n```\r\n{\r\n \"id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"status\": \"active\",\r\n \"merchant_reference_id\": null,\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"merchant_id\": \"merchant_1761554619\",\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"next_billing_at\": \"2025-09-01 11:31:55.0\"\r\n}\r\n```\r\n</details>\r\n<img width=\"1322\" height=\"123\" alt=\"Screenshot 2025-10-27 at 5 16 40\u202fPM\" src=\"https://github.com/user-attachments/assets/6ad28146-e095-462a-b374-6b0e28320e8c\" />\r\n\r\n\r\n<details>\r\n<summary>7. Cancel Subscription</summary>\r\n\r\nRequest\r\n```\r\ncurl --location 'http://localhost:8080/subscriptions/sub_nVjcfvzeicw3JVrIxIXy/cancel' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept: application/json' \\\r\n--header 'X-Profile-Id: pro_hrjhbsMiSK5HrwNkbXo3' \\\r\n--header 'api-key: dev_AyM2dBHmwN0PfdX1kCLjYGhrcntGszAZPn806ysy83s4DJ6bVjrZ8C3yUl6rbinR' \\\r\n--data '{\r\n \"cancel_option\": \"immediately\",\r\n \"unbilled_charges_option\": \"invoice\",\r\n \"credit_option_for_current_term_charges\": \"prorate\",\r\n \"refundable_credits_handling\": \"schedule_refund\"\r\n}'\r\n```\r\n\r\nResponse\r\n```\r\n{\r\n \"id\": \"sub_nVjcfvzeicw3JVrIxIXy\",\r\n \"status\": \"cancelled\",\r\n \"merchant_reference_id\": null,\r\n \"profile_id\": \"pro_hrjhbsMiSK5HrwNkbXo3\",\r\n \"merchant_id\": \"merchant_1761554619\",\r\n \"customer_id\": \"cus_aAUHFICmJVr0QdGGpcVA\",\r\n \"cancelled_at\": \"2025-08-01 11:53:47.0\"\r\n}\r\n```\r\n</details>\r\n<img width=\"1383\" height=\"135\" alt=\"Screenshot 2025-10-27 at 5 37 42\u202fPM\" src=\"https://github.com/user-attachments/assets/a8d601b3-c6b0-46e5-b05f-b4e8d9a975e2\" />\r\n\r\nUpdated API ref also\r\n<img width=\"1608\" height=\"1037\" alt=\"Screenshot 2025-10-27 at 5 52 35\u202fPM\" src=\"https://github.com/user-attachments/assets/d0fada2b-563b-407d-a40b-7061dd4202fe\" />\r\n\r\n\r\n## Checklist\r\n<!-- Put an `x` in the boxes that apply -->\r\n\r\n- [ ] I formatted the code `cargo +nightly fmt --all`\r\n- [ ] I addressed lints thrown by `cargo clippy`\r\n- [ ] I reviewed the submitted code\r\n- [ ] I added unit tests for my changes where possible\r\n",
"author": "jagan-jaya",
"created_at": "2025-10-27T12:30:04+00:00",
"merged_at": "2025-11-03T08:23:41+00:00",
"base_branch": "main",
"labels": [
"M-api-contract-changes"
],
"url": "https://github.com/juspay/hyperswitch/pull/10015",
"commits": [
{
"sha": "2a6e9c44d2ccc560eec643b963cc03b6d008faa7",
"message": "feat(subscriptions): add support to pause, resume and cancel subscription",
"author": "Jagan Elavarasan",
"date": "2025-10-27T12:27:04+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/2a6e9c44d2ccc560eec643b963cc03b6d008faa7"
},
{
"sha": "8a9a4b0a57c3cd8567d326c270d2b4669b5a2c7c",
"message": "chore: run formatter",
"author": "hyperswitch-bot[bot]",
"date": "2025-10-27T12:30:55+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/8a9a4b0a57c3cd8567d326c270d2b4669b5a2c7c"
},
{
"sha": "d9fc61f76eda295ec521eacfb1fb5ef39cac335d",
"message": "fix clippy warnings",
"author": "Jagan Elavarasan",
"date": "2025-10-27T13:44:52+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/d9fc61f76eda295ec521eacfb1fb5ef39cac335d"
},
{
"sha": "3825e060dc660ec60d016e6c1af936efb7b7cfd5",
"message": "Merge branch 'subscription-actions' of https://github.com/juspay/hyperswitch into subscription-actions",
"author": "Jagan Elavarasan",
"date": "2025-10-27T13:45:13+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/3825e060dc660ec60d016e6c1af936efb7b7cfd5"
},
{
"sha": "4fd2c0124a4f1322155eedd14cdff6944cf27bcd",
"message": "chore: run formatter",
"author": "hyperswitch-bot[bot]",
"date": "2025-10-27T13:46:30+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/4fd2c0124a4f1322155eedd14cdff6944cf27bcd"
},
{
"sha": "941dd24187ef3be4dc38873c00cb169bd50f6d22",
"message": "fix typos",
"author": "Jagan Elavarasan",
"date": "2025-10-28T05:05:04+00:00",
"url": "https://github.com/juspay/hyperswitch/commit/941dd24187ef3be4dc38873c00cb169bd50f6d22"
}
]
}