Subscription API - Register payment

Register payment

POST *base*/subscription/payment Authentication : API Key

This will complete the subscription. Often called when user comes back to payment_url from /subscription/order. All GET/POST-params sent by the payment plugin needs to be attached to this call.

Parameters

id
string
required

The subscription ID from :doc: Create Subscription

payment
string
required

URI of payment plugin to be used. Needs to be set up before as a payment plugin for the store.

all provider GET/POST params
any
required

Attach all GET/POST parameters sent from the payment provider to the payment_url from :doc: Create Subscription. These will be used to validate if the payment was successful.

Request example

POST <base>/subscription/payment HTTP/1.1
Content-Type: application/x-www-form-urlencoded

id=3&payment=nets&[+all GET/POST params sent by payment provider]

Response

200 Content-type: application/json

status
string
required

ok if success, else a message explaining what went wrong.

id
int
required

The ID of the subscription that was created.

amount
decimal2 (0.00)
required

The total value of the subscription.

shipping
decimal2 (0.00)
optional

The shipping value for the first order of the subscription.

itemCount
int
optional

The total amount of products in the subscription.

currency
string
optional

The currency that the subscription was registered with, SEK, USD, EUR, etc.

address
object
optional

An address object with the customer information.

firstName lastName
string
optional

The name of the customer.

address coaddress city state zipcode phoneNumber
string
optional

The customer's address information.

country
string
optional

The country of the customer. ISO-Alpha-2 (SE, US, GB etc)

createdAt
string
optional

The date in Y-m-d H-i-s format when the subscription was created.

startDate
string
optional

The date in Y-m-d format when the subscription starts.

nextOrderDate
string
optional

The date in Y-m-d format when the subscription has next shipping.

interval
int
optional

The interval between each subscription. Depending on intervaltype it will be months or days.

intervalType
string
optional

The type of interval for the subscription

  • Month interval is in months.
  • Day interval is in days.
receipt
string
optional

Html snippet that contains a receipt for a subscription payment. Is not null for Klarna payments.

error
boolean
optional

If true, the payment was not successful. The status should contain information on why.

Response examples

HTTP/1.1 200 OK
Content-type: application/json

{
  "status": "ok",
  "id": 3,
  "amount": "900.00",
  "shipping": "20.00",
  "itemCount": 2,
  "currency": "SEK",
  "address": {
    "firstName": "Kalle",
    "lastName": "Anka",
    "phoneNumber": "+4687203333",
    "address1": "Malarvarvsbacken 8",
    "address2": "c/o Young Skilled AB",
    "zipCode": "11733",
    "city": "Stockholm",
    "state": "",
    "country": "SE"
  },
  "createdAt": "2020-05-05 15:00:00",
  "startDate": "2020-05-05",
  "nextOrderDate": "2020-05-06",
  "interval": 14,
  "intervalType": "Day",
  "receipt": "<div>...</div>"
}

Error example

HTTP/1.1 200 OK
Content-type: application/json

{
  "status": "Could not register customer",
  "error": true
}