Search…
Subscribe!
Want to let your customers subscribe for your thing? Easy Peasy.

How We Do Subscriptions

TL;DR. First a plan is made, then it is subscribed to.
We have two concepts of how a Subscription works; either users can change the thing they're paying to get each month, or they can't. You don't change what you get on your Twitch, Netflix or HBO subscription. You just pay and you get the content. Products or services like these would use our Standard Plans to base their Subscriptions on.

Standard Subscriptions

As an example, let's say we're making Gamefly, a company that gives you access to video games for a monthly fee. Here's what we'll do:
    1.
    Create a User
    2.
    Create a Standard Plan
    3.
    Create a Subscription
    4.
    Set up Payment

Create a User

Gamefly wants to let theirs users sign in online, which will create a user through our API. To just create a new user, call the /users endpoint with a JWT. Thereafter, that will log in the existing user.
Parameters
Request
Response
Argument
Type
Description
first_name
string
First name of the user.
last_name
string
Last name of the user.
salutation
string
Title of the user.
email
string
E-mail of the user.
mobile_phone_number
string
Phone number of the user.
addresses
array
An array of Addresses associated with the user.
billing_address
object
Billing Address of the user.
bio
string
Biographical note about the user.
tags
array
List of tags associated with the user.
note
string
Additional notes regarding the user.
1
POST /users HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOi
4
IxMjM0NTY3ODkwIiwibGFzdF9uYW1lIjoiRG9lIiwiZmlyc3RfbmFtZSI6IkpvaG4iLCJ
5
pYXQiOjE1MTYyMzkwMjJ9.YEqWlNmcheENbeSTjXhA-LMfULwa7t_Ab71tDmLGUxA
6
X-Builton-Api-Key: <builton-api-key>
7
Host: api.builton.dev
8
9
{
10
"first_name": "John",
11
"last_name": "McClane",
12
"email": "[email protected]",
13
"mobile_phone_number": "+4712345678",
14
"addresses": [{
15
"city":"Danielsen",
16
"service":"google",
17
"alias":"",
18
"country":"Paraguay",
19
"zip_code":"0556",
20
"state":"Oslo",
21
"street_name":"Streetname 7"
22
}]
23
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"roles": ["user"],
6
"tags": [],
7
"auth0_id": "some-id",
8
"mobile_phone_number": "+4712345678",
9
"billing_address":
10
{"service": "google",
11
"alias": " "},
12
"voucher": {"uuid": "b498e02b-2031-4d84-b55b-b460d22f44b4",
13
"consumed": 0,
14
"initial_quantity": 0,
15
"created": {"$date": 1512383756277},
16
"expires": {"$date": 1543919756277}},
17
"_cls": "User",
18
"created": {"$date": 1512383756277},
19
"addresses":
20
[{"zip_code": "0556",
21
"city": "Danielsen",
22
"street_name": "Streetname 7",
23
"country": "Paraguay",
24
"alias": " ",
25
"service": "google"}],
26
"company": {"$oid": "57ee9c71d76d431f8511142f"},
27
"email": "[email protected]",
28
"national_id": "1234567890",
29
"modified": {"$date": 1512383756279},
30
"avatar": " ",
31
"bio": " ",
32
"stripe_customer_id": " ",
33
"note": " ",
34
"first_name": "John",
35
"_id": {"$oid": "5a25250cd57ba213edcba515"},
36
"new_customer": true,
37
"last_name": "McClane",
38
"last_login": {"$date": 1512383756278},
39
"deleted": false,
40
"voucher": {}
41
}
Copied!

Create a Standard Plan

You create Plans in the dashboard (for now). Under Subscriptions, you'll see Plans. Near the top will be New plan +. Enter the the basic parameters; name, delivery interval, billing interval and price. For Gamefly, maybe the first plan we'd make would be a basic plan. In the plan's details, we can add a description and fill in a few other fields. Easy.

Create a Subscription

Now that the Plan is created, your users can subscribe to it.
Note: start_now must be set to true for the subscription to start automatically after creation. An associated payment_method must be in the request data.
Parameters
Request
Response
Argument
Type
Description
plan
string
ID of the Plan associated with the subscription.
subscription_method
string
Name of subscription method. Must be license.
note
string
A short description.
start_now
boolean
If true, the subscription will start now.
1
POST /subscriptions HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
6
7
{
8
"plan": "5931697ed57ba271c0c7de66",
9
"subscription_method": "license"
10
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
{
4
"company": {"$oid": "57ee9c71d76d431f8511142f"},
5
"active": true,
6
"status": "CREATED",
7
"name": "LICENSE",
8
"method": "license",
9
"_id": {"$oid": "5964a0ead57ba2036750a3b4"},
10
"deleted": false,
11
"prorate_amount": 0.0,
12
"_cls": "SubscriptionMethod.LicenseSubscription",
13
"plan": {"$oid": "5931697ed57ba271c0c7de66"},
14
"payments": [],
15
"infinite": false,
16
"created": {"$date": 1499767018360},
17
"user": {"$oid": "57ee9c72d76d431f85111432"},
18
"updated": {"$date": 1499767018360}
Copied!

Get Paid

The fun part. Check out Payment Methods and Payments for all the parameters and related endpoints, as there are a few parts to getting paid. Here's the gist.

1. User adds a card

Your user will need to add a payment method, i.e. a credit or debit card, that they want to use to pay for their order.
Parameters
Request
Response
Attribute
Type
Description
payment_method
string
Must be stripe for triggering a STRIPE payment method.
payment_method_id
string
Payment Method created with the card details (number, expiration month, expiration year, cvc).
Stripe references:
1
POST /payment_methods HTTP/1.1
2
Content-Type: application/json
3
Authorization: Bearer <jwt>
4
X-Builton-Api-Key: <builton-api-key>
5
Host: api.builton.dev
6
7
{
8
"payment_method": "stripe",
9
"payment_method_id": "pm_1EzglsEeeXxFpLJtjuEvd123"
10
}
Copied!
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
4
{
5
"company": {
6
"$oid": "57ee9c71d76d431f8511142f"
7
},
8
"created": {
9
"$date": 1476118043580
10
},
11
"_id": {
12
"$oid": "<payment-method-id>"
13
},
14
"modified": {
15
"$date": 1476118043580
16
},
17
"deleted": false,
18
"user": {
19
"$oid": "57ee9c72d76d431f85111432"
20
},
21
"method": "stripe",
22
"name": "Stripe",
23
"customer_id": "cus_CJjTlT4Wci2P0u",
24
"payment_method_id": "pm_1EzglsEeeXxFpLJtjuEvd123",
25
"card": {
26
"object": "card",
27
"address_state": null,
28
"fingerprint": "npPw68vQg1usKUWb",
29
"metadata": {},
30
"exp_year": 2019,
31
"country": "US",
32
"last4": "4242",
33
"address_zip_check": null,
34
"address_zip": null,
35
"funding": "credit",
36
"cvc_check": "unchecked",
37
"id": "card_1Bv5yfEeeXxFpLJtPBVfQ1wZ",
38
"tokenization_method": null,
39
"address_line1": null,
40
"exp_month": 12,
41
"brand": "Visa",
42
"dynamic_last4": null,
43
"address_country": null,
44
"address_line2": null,
45
"address_line1_check": null,
46
"name": null,
47
"address_city": null
48
}
49
}
Copied!

2. Then They Pay You Automatically

And that's it. If the user has a payment method associated with them, it will get charged when the plan they've subscribed to says it should. And they get to game to their heart's content.
Last modified 1yr ago