Subscription API - Create subscription
Create subscription
POST *base*/subscription/order
Authentication : API Key
Add a subscription with payment details, will not be completed/registered as a completed subscription until subscription/payment
has been called.
Parameters
First and last name of the customer
Customer e-mail
Address information for the customer
The language code for created customer.
The country of the customer. ISO-Alpha-2 (SE
, US
, GB
etc)
Array with Package IDs for each package you want in the subscription.
For example: package[]=3232&package[]=4344
URI of payment plugin to be used. Needs to be set up before as a payment plugin for the store.
There are only a few payment plugins that support subscription services. Please make sure the payment plugin you set up allows it.
A url where the customer should be redirected to when payment is completed.
The social security number for the user, used for some payment plugins to invoice the customer.
If the user opted in to a newsletter subscription.
Default today
. The date when the subscription should start. The first order will be created first after this date.
Default 14
. The interval between each subscription. Depending on intervaltype
it will be months or days.
Default D
. The type of interval for the subscription.
M
interval is in months.D
interval is in days.
A list of consents the customer agreed to. The key
of each item in the object is the key for the consent. If the consent key does not exists already, it will be added automatically.
For example like this: consent[newsletter_consent][consent_name]=boop
The name of the consent.
The description of the consent.
The version of the consent.
The language of the consent. No validation is made on this field for the formatting of the language code.
Request example
POST <base>/subscription/order HTTP/1.1
Content-Type: application/x-www-form-urlencoded
name=Kalle&sname=Anka&address=Paradisäppelvägen+9&
coaddress=&city=Ankeborg&state=&zipcode=12345&
country=SE&email=kalle.anka@example.com&package[]=1&package[]=3&
payment=nets[&pnr=880101-7845]&
language=SV
Example Request with consents:
POST <base>/subscription/order? HTTP/1.1
Content-Type: application/x-www-form-urlencoded
name=Kalle&sname=Anka&address=Paradisäppelvägen+9&coaddress=&
city=Ankeborg&state=&zipcode=12345&country=SE&
email=kalle.anka@example.com&package[]=1&package[]=3&
payment=nets[&payment_url=https://...][&pnr=880101-7845]&
language=SV&
consent[direct_marketing]=1&
consent_name[direct_marketing]=Direct%20Marketing&
consent_version[direct_marketing]=1.1&
consent[newsletter]=1&consent_name[newsletter]=Newsletter&
consent_version[newsletter]=v2&consent_language[newsletter]=sv_SE
Response
200
Content-type: application/json
ok
if success, else a message explaining what went wrong.
The ID of the subscription that was created.
A payment object with information on how finalize the payment.
A URL to redirect the user to. This could be to an external payment provider depending on the payment plugin.
The total value of the subscription.
The currency that the subscription was registered with, SEK
, USD
, EUR
, etc.
If status
returns no
, this value should send back a message why it failed.
Response examples
HTTP/1.1 200 OK
Content-type: application/json
{
"status": "ok",
"id": 3,
"payment": {
"url": "https://...",
"value": "123.50",
"currency": "SEK"
}
}
Error example
{
"status": "Could not register customer",
"error": true,
"errors": [
"email",
"payment"
]
}
Bad payment method:
{
"status": "Bad Payment Method",
"error": true,
"message": "Error message"
}