Payment Services

GET /user/{userId}/subscriptions

Requires authentication with server or user access token.

List all the user's subscriptions within this client.

Request

GET /api/2/user/{userId}/subscriptions

userId

required path parameter

The user's uuid or userId (not to be mistaken with the deprecated id).

Example request

cURL
curl https://login.schibsted.com/api/2/user/42/subscriptions -G \
   -d "oauth_token=[access token]"
Java
SpidOAuthToken token = spidClient.getUserToken(code);
String responseJSON = spidClient.
    GET(token, "/user/42/subscriptions").
    getResponseBody();

This example is an excerpt, see a full example

PHP
<?php
$client->auth();
echo var_dump($client->api("/user/42/subscriptions"));

This example is an excerpt, see a full example

Clojure
(ns example
  (:require [spid-client-clojure.core :as spid]))

(let [client (spid/create-client "[client-id]" "[secret]")
      token (spid/create-user-token client "[code]")]
  (spid/GET client token "/user/42/subscriptions"))

Response

This endpoint supports the JSON and JSON-P response formats.

Success: 200 OK

Retrieves all subscriptions for user.

Returns a collection of Subscriptions, as an object with subscriptionId for property names, and Subscriptions for values.

Subscription

subscriptionId

string

Unique ID of the subscription

originalSubscriptionId

string

Unique ID of the original subscription, if empty this is the first time user bought subscription for product

clientId

string

Your client ID

userId

string

User id who bought the subscription

productId

string

Unique product ID

parentProductId

string

ID of the parent product, if any

identifierId

string

ID of the payment identifier that will be used to renew the subscription

paymentType

Payment type

0 for SPiD Platform, 1 for Payment Platform

orderId

string

ID of the original order

startDate

datetime

From when the subscription is/was active

originalPurchaseDate

datetime

When the subscription was originally purchased

expires

datetime

When the subscription expires

autoRenew

string, "1" (true) or "0" (false)

If "1", the subscription will automatically renew on the expires date.

renewPrice

price

The price of renewal, in cents

currency

string

The renewal price currency

renewPeriod

timestamp, in seconds

Renewal period

autoRenewLockPeriod

timestamp, in seconds

Length of the initial period after activation during which it is not allowed to change the auto renew setting for the subscription.

stopRenewalAfterLock

string, "1" (true) or "0" (false)

When "1", the subscription's auto renew will be stoped after the lock period is over.

autoRenewDisabled

string, "1" (true) or "0" (false)

When "1", the subscription's auto renew cannot be changed.

gracePeriod

timestamp, in seconds

The length of the period the subscription stays active after charging for a renewal fails.

emailReceiptCount

integer (as string)

The number of receipts sent via email to the user

finalEndDate

datetime

If provided, this date denotes the time when the subscription will no longer be available for sale.

chargeRetryCount

integer (as string)

The number of times the previous charge has been retried

chargeLastRetry

datetime

Time of the last charge retry

status

Subscription status

The subscription's current status

statusChangeCode

Subscription status change code

A description of the last change to the subscription's status

statusChangeDate

datetime

The date of the last change to the subscription's status

updated

datetime

Date and time of last update to the subscription

created

datetime

Date and time when the subscription was created

product

Product

The product this subscription belongs to

The check mark indicates that the field always contains a valid non-empty value.

Subscription status

An enum, with the following possible values:

"-1"

Expired

"0"

Inactive

"1"

Active

Subscription status change code

An enum, with the following possible values:

"100"

Subscription expired via multiple failed payment method charge attempts

"110"

Subscription expired via API

"120"

Subscription expired passively (auto_renew is off)

"130"

Subscription expired by force

"140"

Subscription expired because it is no longer for sale

"150"

Subscription expired because it was renewed (i.e., a new subscription has been created)

"160"

Subscription expired because the user deleted their account

"170"

Subscription was paused

"180"

Expiry date was changed

"190"

Subscription expired because the user disabled auto renewal

Failure cases

Some HTTP response codes are used for multiple error situations. There is no consistent way to tell these apart, but the error object will contain a textual explanation of the reason for the error. For explanation on OAuth related failures and errors see OAuth authentication failures.

  • 401 Unauthorized You don't have administration rights for this client.
  • 401 Unauthorized Your client doesn't have administration rights for this client.
  • 403 Forbidden Client is not authorized to access this API endpoint. Contact SPiD to request access.
  • 403 Forbidden Requesting IP is not whitelisted
  • 403 Forbidden Access token rejected
  • 404 Not Found Unknown client ID
  • 404 Not Found Client ID mismatch. The client making the request is no the owner of this resource, and does not have administrative privileges for it.
  • 420 Request Ratelimit exceeded

Sample response

JSON
{
    "165937": {
        "subscriptionId": "165937",
        "clientId": "4e8463569caf7ca019000007",
        "userId": "2200090",
        "productId": "10012",
        "parentProductId": "10010",
        "identifierId": "0",
        "orderId": "10722405",
        "startDate": "2012-01-24 15:09:46",
        "originalPurchaseDate": "2012-01-24 10:38:39",
        "expires": "2012-04-23 11:39:22",
        "autoRenew": "1",
        "renewPrice": "2900",
        "currency": "SEK",
        "renewPeriod": "2592000",
        "autoRenewLockPeriod": "0",
        "autoRenewDisabled": "0",
        "gracePeriod": "777600",
        "emailReceiptCount": "0",
        "finalEndDate": null,
        "chargeRetryCount": "0",
        "chargeLastRetry": null,
        "status": "1",
        "statusChangeCode": null,
        "statusChangeDate": null,
        "updated": "2012-01-27 18:35:30",
        "created": "2012-01-24 15:09:46",
        "product": {
            "productId": "10012",
            "parentProductId": "10010",
            "clientId": "4e8463569caf7ca019000007",
            "type": "2",
            "code": "10012-PLUS1M",
            "name": "Plus månadsprenumeration",
            "description": "Plus 1 mån, därefter 29 kr/mån",
            "url": null,
            "price": "2900",
            "vat": "2500",
            "currency": "SEK",
            "paymentOptions": "6",
            "quantityLimit": null,
            "quantityCount": "3",
            "saleStart": "1970-01-01 00:00:00",
            "saleStop": "2040-01-01 00:00:00",
            "availableStart": null,
            "availableStop": null,
            "subscriptionPeriod": "2592000",
            "subscriptionRenewPrice": "2900",
            "subscriptionRenewPeriod": "2592000",
            "subscriptionAutoRenew": "1",
            "subscriptionAutoRenewLockPeriod": "0",
            "subscriptionAutoRenewDisabled": "0",
            "subscriptionGracePeriod": "777600",
            "subscriptionEmailReceiptLimit": "0",
            "subscriptionFinalEndDate": null,
            "allowMultiSales": "1",
            "status": "3",
            "changedBy": null,
            "changed": null,
            "createdBy": "admin",
            "created": "1970-01-01 00:00:00",
            "purchaseUri": "https://spp.dev/auth/start?client_id=4e8463569caf7ca019000007&flow=payment&product_id=10012"
        },
        "statusMsg": "Active"
    }
}
JSON-P
callback({
    "165937": {
        "subscriptionId": "165937",
        "clientId": "4e8463569caf7ca019000007",
        "userId": "2200090",
        "productId": "10012",
        "parentProductId": "10010",
        "identifierId": "0",
        "orderId": "10722405",
        "startDate": "2012-01-24 15:09:46",
        "originalPurchaseDate": "2012-01-24 10:38:39",
        "expires": "2012-04-23 11:39:22",
        "autoRenew": "1",
        "renewPrice": "2900",
        "currency": "SEK",
        "renewPeriod": "2592000",
        "autoRenewLockPeriod": "0",
        "autoRenewDisabled": "0",
        "gracePeriod": "777600",
        "emailReceiptCount": "0",
        "finalEndDate": null,
        "chargeRetryCount": "0",
        "chargeLastRetry": null,
        "status": "1",
        "statusChangeCode": null,
        "statusChangeDate": null,
        "updated": "2012-01-27 18:35:30",
        "created": "2012-01-24 15:09:46",
        "product": {
            "productId": "10012",
            "parentProductId": "10010",
            "clientId": "4e8463569caf7ca019000007",
            "type": "2",
            "code": "10012-PLUS1M",
            "name": "Plus månadsprenumeration",
            "description": "Plus 1 mån, därefter 29 kr/mån",
            "url": null,
            "price": "2900",
            "vat": "2500",
            "currency": "SEK",
            "paymentOptions": "6",
            "quantityLimit": null,
            "quantityCount": "3",
            "saleStart": "1970-01-01 00:00:00",
            "saleStop": "2040-01-01 00:00:00",
            "availableStart": null,
            "availableStop": null,
            "subscriptionPeriod": "2592000",
            "subscriptionRenewPrice": "2900",
            "subscriptionRenewPeriod": "2592000",
            "subscriptionAutoRenew": "1",
            "subscriptionAutoRenewLockPeriod": "0",
            "subscriptionAutoRenewDisabled": "0",
            "subscriptionGracePeriod": "777600",
            "subscriptionEmailReceiptLimit": "0",
            "subscriptionFinalEndDate": null,
            "allowMultiSales": "1",
            "status": "3",
            "changedBy": null,
            "changed": null,
            "createdBy": "admin",
            "created": "1970-01-01 00:00:00",
            "purchaseUri": "https://spp.dev/auth/start?client_id=4e8463569caf7ca019000007&flow=payment&product_id=10012"
        },
        "statusMsg": "Active"
    }
});

Comments/feedback

Do you have questions, or just want to contribute some newly gained insight? Want to share an example? Please leave a comment. SPiD reads and responds to every question. Additionally, your experience can help others using SPiD, and it can help us continuously improve our documentation.