Single endpoint to create customer (or link an existing one), subscription and invoice
Please note that the subscription you create through this method will pick up the configurations that you have done in the Payments Flow app. Please go to the following link to setup your configurations:
Settings > Web Checkout Settings (https://{{domain_name}}.subscriptionflow.com/en/apps/paymentsflow/hosted-pages)
Subscription Configurations:
On this page, follow these steps to set your subscription configurations:
- Click the ⚙️ icon to open Settings, then Web Checkout Settings under Customization.
- Open the Configurations tab.
- Under Basic Configurations, set the subscription type and term settings.
- You can create a configuration for all your plans or choose a specific plan and save a configuration accordingly.
Once you have these setup you can now use the API to create subscriptions which will follow the configurations you have just done.
API Details for Subscription Creation:
Following are the API details and examples you can follow:
End Point Details:
https:// {{domain_name}}.subscriptionflow.com/api/v1/subscriptions/checkout
Complete API Docs:
https://{{domain_name}}.subscriptionflow.com/api/documentation
Complete CURL example:
-
If customer does not exist:
curl --location 'https:// reliablepbx.subscriptionflow.com/api/v1/subscriptions/checkout' \
--header 'Authorization: Bearer {{token}}' \
--form 'first_name="John"' \
--form 'last_name="Doe"' \
--form 'mailto:email="dummyemail@sf.com"' \
--form 'line_items[0][product_id]="04d9bb5f-23ef-41be-aa1a-d19245758bcd"' \
--form 'line_items[0][plan_id]="6abc1bda-004a-4ab2-b6fe-e6472fc420dc"' \
-
If customer already exists:
curl --location 'https://test.subscriptionflow.com/api/v1/subscriptions/checkout' \
--header 'Authorization: Bearer {{token}}' \
--form 'line_items[0][product_id]="04d9bb5f-23ef-41be-aa1a-d19245758bcd"' \
--form 'line_items[0][plan_id]="6abc1bda-004a-4ab2-b6fe-e6472fc420dc"' \
--form 'customer_id="aeca5e0a-555e-4c60-be6d-72be57ac3510"
Get your Auth Tokens
Request for getting Bearer Token can be made after getting the client ID and client secret from your account by going to the link here.
curl --location 'https://{{your_domain}}.subscriptionflow.com/oauth/token' \
--form 'client_id="{{your_client_id}}"' \
--form 'client_secret="{{your_client_secret}}"' \
--form 'grant_type="client_credentials"'
How to get Product and Plan ID’s
Please follow the steps to fetch Product and Plan ID
Step 1: Open Products and click the product.
Step 2: The highlighted part of the URL is the product ID. It's also shown as Internal ID in the Products Overview card.
Step 3: To get the plan ID, open the plan from Plans (or click the plan's name on the product).
Step 4: Highlighted text in the URL is the plan ID
Test Cases Details
Case 1: missing param line Items → Passed
Case 2: missing value line Items: → Passed
Case 3: With params → Passed
Case 4: Passing ID instead of username and email → Passed
Case 5: Passing customer ID with name and email. → Passed
Case 6: Passing wrong email with full name and customer ID → Passed
Test Response
If you want to view the response of these tests please click here to download the json file:
Conversion Tracking Configurations:
Conversion Tracking is used to redirect your customer after they have successfully subscribed.
Please note that the subscription you create through this method will pick up the configurations that you have done in the Payments Flow app. Please go to the following link to setup your configurations:
Settings > Web Checkout Settings > Configurations > Advance Configurations
On this page, follow these steps to set your conversion tracking configurations:
- Open Advance Configurations, then Conversion Tracking:
- Please read the instructions for the redirect flow and add the links you want your customer to redirect to incase of successful, pending and failed payments. You can also redirect them in case of a trial subscription or a pending subscription (usually in cases where you take offline payments or future payments, pending subscriptions are created.)
If you have any questions feel free to reach out to us at support@subscriptionflow.com and our team will be happy to assist you in setting up.
Comments
0 comments
Please sign in to leave a comment.