Subscription plans
A subscription plan instructs E-XEZINE PSP Core how often and how much to charge a customer. Merchants are free to create an unlimited number of subscription plans for their shops.
Each plan has a unique ID which should be submitted in requests.
Create a plan
Request
To create a subscription plan, send a POST request to https://api.e-xezine.az/plans with the following parameters:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Example of the requests for creating a plan with infinite billing cycles
curl https://api.e-xezine.az/plans \
-X POST -u shop_id:secret_key \
-H "Content-Type: application/json" \
-d \
'
{
"test": true,
"title": "Basic plan",
"currency": "USD",
"plan": {
"amount": 20,
"interval": 20,
"interval_unit": "day"
},
"trial": {
"amount": 10,
"interval": 10,
"interval_unit": "hour"
},
"visible_fields": ["first_name", "last_name"],
"language": "en",
"infinite": true,
"billing_cycles": null,
"number_payment_attempts": 3,
}
'
Example of the requests for creating a plan with finite billing cycles
{
"test": true,
"title": "Basic plan",
"currency": "USD",
"plan": {
"amount": 20,
"interval": 20,
"interval_unit": "day"
},
"trial": {
"amount": 10,
"interval": 10,
"interval_unit": "hour"
},
"language": "en",
"infinite": false,
"billing_cycles": 12,
"number_payment_attempts": 3
}
Response
If credentials and parameters are valid, E-XEZINE PSP Core will return 201 HTTP status code and a new plan object with all the relevant details. Otherwise, E-XEZINE PSP Core will return 422 HTTP status code and an error message.
Response example
{
"id": "pln_a134847c902551de",
"title": "Basic plan",
"currency": "USD",
"language": "en",
"plan": {
"amount": 20,
"interval": 20,
"interval_unit": "day"
},
"trial": {
"amount": 10,
"interval": 10,
"interval_unit": "hour"
},
"number_payment_attempts": 3,
"test": true
}
Example of the response to the request when a parameter is invalid or not included
{
"errors": {
"title": [
"can't be blank"
]
},
"message": "Title can't be blank"
}
Get a payment link for a plan
To get a payment for a plan, route the customer's browser via a GET or POST request to https://api.e-xezine.az/plans/{plan_id}/pay, where {plan_id} stands for the identifier of the plan.
Get subscription plan details
To get details of a subscription plan, send a GET request to https://api.e-xezine.az/plans/{plan_id}, where {plan_id} stands for the identifier of the plan.
If the plan ID exists, E-XEZINE PSP Core will return 200 HTTP status code and the plan details.
Example of the request to get details of the plan with the ID pln_a134847c902551de
curl -u shop_id:secret \
https://api.e-xezine.az/plans/pln_a134847c902551de
Response example
{
"id": "pln_a134847c902551de",
"title": "Basic plan",
"currency": "USD",
"language": "en",
"plan": {
"amount": 20,
"interval": 20,
"interval_unit": "day"
},
"trial": {
"amount": 10,
"interval": 10,
"interval_unit": "hour"
},
"number_payment_attempts": 3,
"test": true
}
Get a list of plans
To get a list of all plans, send a GET request to https://api.e-xezine.az/plans.
If there are plans, E-XEZINE PSP Core will return 200 HTTP status code and an array of plans.
Example of the request with a list of plans
curl -u shop_id:secret \
https://api.e-xezine.az/plans
Response example
[
{
"id": "pln_2b0c211f50deb72c",
"title": "Basic plan",
"currency": "USD",
"language": "en",
"plan": {
"amount": 20,
"interval": 7,
"interval_unit": "day"
},
"trial": {
"amount": 10,
"interval": 40,
"interval_unit": "hour"
},
"number_payment_attempts": 3,
"test": true
},
{
"id": "pln_75eca73bfdcf143a",
"title": "Pro plan",
"currency": "USD",
"language": "fr",
"plan": {
"amount": 30,
"interval": 7,
"interval_unit": "day"
},
"trial": {
"amount": 10,
"interval": 40,
"interval_unit": "hour"
},
"number_payment_attempts": 5,
"test": true
}
]