This guide assumes you have already set up your subscription plan with one of the integrated payment providers. Currently, integrations with Stripe, Braintree, and Recurly are available.
The process is similar for all providers. First, we need to create a consumer if one doesn't exist already, and then we are going to create a subscription for that consumer.
Creating a new consumer
If the consumer doesn't already exist on Zype, we need to create a consumer before we create the subscription. This step is the same for all providers and is also necessary for purchases, rentals, and any other entitlement types.
To create the consumer we use the Create Consumer endpoint.
curl --request POST \
--url https://api.zype.com/consumers \
In the payload, email is the only required field, and this must be unique. In our example, we'll also add a name.
"name": "John Smith"
As a result of the POST request, we will get a consumer object. We need to save the `id` of the consumer, which is required to create the subscription.
"_id": "5fb003109906dd00012ca4b6", <= This is the id we need
"name": "John Smith",
Creating the subscription
Now that we have the conumser_id, we need a payment token or nonce code to be used as payment, these are created client-side and they can be created in different ways using the payment provider tools. By doing this we avoid having the credit card information going to your server.
Once we have the token or nonce we have all we need to create the subscription. To do so, we use the Create Subscription endpoint.
curl --request POST \
The parameters in the payload will change depending on the provider, but all require the following:
- consumer_id - The id of the consumer we got on the previous step
- plan_id - The id of the subscription plan we are going to use to create the subscription
- payment token/nonce
The payload for a new Stripe subscription will look like this:
That's it, now our consumer has a subscription in Zype and a subscription was created in your payment provider. Any change made directly on the provider will be updated on Zype using the webhook.
Was this article helpful?
Articles in this section
- How to Request a Video Player
- How to Merge a New Video Import to an Existing Video Using the API
- Importing a Single Video from a URL
- Ad Timings with the API
- Using the Upload API Endpoint
- Assigning Categories to Videos Using the API
- Creating New Subscriptions with the API
- Create zobjects with custom attributes using the API