Dark Mode

Create Subscription Link API


The following endpoint creates a Subscription Link:

/subscriptions

Run in Postman

Request Attributes

name

String
Mandatory

The name associated with the Plan or Package Name

price

String
Mandatory

The price for a single subscription plan

qty

String
Mandatory

The quantity of subscription plan, total amount will be price * qty

started_at

String
Mandatory

The started_at associated with start date for subscription plan which should be current date or greater

charge_type

String
Mandatory

The charge_type can be manual or automatic (only available for credit card)

email

String
Mandatory

The email refers to customer email

mobile

String
Mandatory

The mobile refers to customer mobile

given_name

String
Mandatory

The given_name refers to customer first name

subscription_ref_id

String
Optional

The subscription_ref_id is upstream id from merchant

billing_period

String
Optional

The billing_period for subscription can be monthly/weekly/annually/daily, default value is monthly

billing_period_count

String
Optional

The billing_period_count for subscription.For example, If billing_period is set for Monthly and billing_period_count is set as 2, then charge will be made every 2 months, default value is 1

grace_period

String
Optional

The grace_period for subscription can be terminate/ignore/monthly/hourly/weekly/daily. default value is 24 hours . terminate if the subscription was not paid after the due date, the subscription will end immediately And ignore if the subscription was not paid after the due date, the subscription will continue and status remain active.Grace Period should be less than Billing period

grace_period_count

Integer
Optional

The grace_period for subscription has to be zero for grace_period terminate/ignore & non zero in case of grace_period as monthly/hourly/weekly/daily.for example, if grace_period is set for Monthly and grace_period_count is set as 2, then charge will be made every 2 months

billing_cycle_count

String
Optional

The billing_cycle_count refers number of cycle amount will be charged for fixed cycle. for forever subscription billing_cycle_count is zero default 0

notes

String
Optional

The note from the merchant

middle_name

String
Optional

The middle_name refers to customer middle name

sur_name

String
Optional

The sur_name refers to customer last name

Example
curl -X POST \
  https://api.durianpay.id/v1/subscriptions \
  -H 'authorization: [Base64({Your_Server_Key}:)]' \
  -H 'content-type: application/json' \
  -d '{"plan": 
      {
        "subscription_ref_id": "merchant_sub_ref_id",
        "name": "Plan/Package Name",
        "billing_period": "monthly",
        "billing_period_count": 1,
        "grace_period": "terminate",
        "grace_period_count": 0,
        "price": "20000",
        "qty": "2"
      },
      "customer": {
        "email": "jude.casper@durianpay.id",
        "mobile": "+628978678511",
        "given_name": "Jude",
        "middle_name": "",
        "sur_name": "Casper"
      },
      "billing_cycle_count": 10,
      "started_at": "2022-09-30T12:58:38.210535Z",
      "charge_type": "manual",
      "notes": "a long notes"
  }'

Response Code

200 - Success

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
    "data": {
        "id": "sub_7HAtpFqE7g0944",
        "plan": {
            "id": "sub_plan_HQYXw2LQlz3333",
            "name": "Plan/Package Name",
            "billing_period": "monthly",
            "billing_period_count": 1,
            "grace_period": "terminate",
            "grace_period_count": 0,
            "price": "20000",
            "qty": "2",
            "amount": "40000.00",
            "subscription_ref_id": "merchant_sub_ref_id"
        },
        "customer": {
            "id": "cus_g0tw6z7sDF4506",
            "email": "jude.casper@durianpay.i",
            "mobile": "+628978678511",
            "given_name": "Jude",
            "middle_name": "",
            "sur_name": "Casper"
        },
        "status": "wait_for_payment",
        "started_at": "2021-10-01T12:58:38.210535Z",
        "next_due_at": "2021-10-01T12:58:38.210535Z",
        "subscription_orders": [
            {
                "billing_period": 1,
                "order_id": "ord_A2xXH1YkMU7183",
                "status": "unpaid"
            }
        ],
        "charge_type": "manual",
        "link": "https://links.durianpay.id/subscription-link/b6hRzb"
    }
}

400 - Invalid Request

401 - Unauthorized Access

500 - Internal Server Error