Payment Services

POST /product

Requires authentication with server access token.

Create a new product, a subscription or a bundle. All of these are technically products, so which one you end up depends on the data you pass when creating it.

Subscriptions

To create a subscription, set the type parameter to 2. You must also specify the subscriptionPeriod, which is required for subscriptions. Additionally, you may provide any or all of the optional parameters:

  • subscriptionRenewPrice
  • subscriptionRenewPeriod
  • subscriptionAutoRenew
  • subscriptionAutoRenewLockPeriod
  • subscriptionAutoRenewDisabled
  • subscriptionGracePeriod
  • subscriptionEmailReceiptLimit
  • subscriptionFinalEndDate
  • subscriptionSurveyUrl

The bundle parameter may not be used with subscriptions.

Bundles

Set the bundle parameter to 1 or 2 to make the product a bundle. When doing so, type may not be set to subscription. When creating bundles, you may optionally provide the hideItems parameter. When set to 1, the bundle will be communicated as one product, and the individual products in the bundle will not be highlighted in any way.

Products

Most of the time, you want to set type to 1 when creating plain products.

Request

POST /api/2/product

code

required

Client-defined product code. More easily recognizable than the numeric ID. Must be between 3 and 20 characters long.

name

required

The product name. Cannot be longer than 64 characters.

price

required

Price, in cents

vat

required

VAT, fraction × 10000. For instance, 25% would be 2500

paymentOptions

required

A payment options bitmask

type

required

The product type

currency

required

The price and VAT currency

bundle

optional

If the product is of type bundle, this field decides what bundle type. Bundle type 0: Not a bundle, 1: Dynamic bundle, 2: One-off bundle

hideItems

optional

If the product is a bundle, this field decides if the bundle items should be hidden ("1") in communications.

status

optional

The product status

parentProductId

optional

ID of the parent product, if any

description

optional

Product description. Must be between 3 and 255 characters long.

url

optional

Link to the product. Must be between 3 and 1024 characters long.

quantityLimit

optional

If there is a limited supply for this product

saleStart

optional

Provide if there is a sale of some sort

saleStop

optional

Provide if there is a sale of some sort

availableStart

optional

The time from when the product is available for sale (date time)

availableStop

optional

The time when the product is no longer available for sale (date time)

allowMultiSales

optional

"1" if a user is allowed to purchase this product multiple times, "0" otherwise

subscriptionPeriod

optional

The duration of a subscription period, as a timestamp in seconds

subscriptionRenewPrice

optional

Price of subscription renewals, in cents

subscriptionRenewPeriod

optional

The duration of a renewal

subscriptionAutoRenew

optional

"1" if the subscription should automatically renew, "0" otherwise

subscriptionAutoRenewLockPeriod

optional

The duration of the initial period where auto renewal cannot be changed

subscriptionAutoRenewDisabled

optional

"1" if automatic renewals should not be available, "0" if they should

subscriptionEmailReceiptLimit

optional

If set to anything not null, will prevent emails from being sent on purchase/renewal of this subscription

subscriptionFinalEndDate

optional

A date from when this product is no longer for sale

subscriptionSurveyUrl

optional

URL to a survey for when people terminate a subscription for this product.

filters

optional
merchant
Show all results within the current merchant rather than the current client

Example request

cURL
Minimal example
curl https://login.schibsted.com/api/2/product \
   -X POST \
   -d "oauth_token=[access token]" \
   -d "code=ipad" \
   -d "name=John Doe" \
   -d "price=400" \
   -d "vat=96" \
   -d "paymentOptions=2" \
   -d "type=discount" \
   -d "currency=NOK"
With all parameters
curl https://login.schibsted.com/api/2/product \
   -X POST \
   -d "oauth_token=[access token]" \
   -d "code=ipad" \
   -d "name=John Doe" \
   -d "price=400" \
   -d "vat=96" \
   -d "paymentOptions=2" \
   -d "type=discount" \
   -d "currency=NOK" \
   -d "bundle=2" \
   -d "hideItems=1" \
   -d "status=0" \
   -d "parentProductId=44" \
   -d "description=Some information" \
   -d "url=http://example.com" \
   -d "quantityLimit=10" \
   -d "saleStart=2016-06-01" \
   -d "saleStop=2014-07-01" \
   -d "availableStart=2014-01-01" \
   -d "availableStop=2016-06-01" \
   -d "allowMultiSales=1" \
   -d "subscriptionPeriod=12000" \
   -d "subscriptionRenewPrice=59" \
   -d "subscriptionRenewPeriod=12000" \
   -d "subscriptionAutoRenew=1" \
   -d "subscriptionAutoRenewLockPeriod=12000" \
   -d "subscriptionAutoRenewDisabled=1" \
   -d "subscriptionEmailReceiptLimit=0" \
   -d "subscriptionFinalEndDate=2014-12-31" \
   -d "subscriptionSurveyUrl=http://survey.example.com"
Java
Minimal example
Map<String, String> params = new HashMap<>() {{
    put("code", "ipad");,
    put("name", "John Doe");,
    put("price", "400");,
    put("vat", "96");,
    put("paymentOptions", "2");,
    put("type", "discount");,
    put("currency", "NOK");
}};

SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
    POST(token, "/product", params).
    getResponseBody();
With all parameters
Map<String, String> params = new HashMap<>() {{
    put("code", "ipad");,
    put("name", "John Doe");,
    put("price", "400");,
    put("vat", "96");,
    put("paymentOptions", "2");,
    put("type", "discount");,
    put("currency", "NOK");,
    put("bundle", "2");,
    put("hideItems", "1");,
    put("status", "0");,
    put("parentProductId", "44");,
    put("description", "Some information");,
    put("url", "http://example.com");,
    put("quantityLimit", "10");,
    put("saleStart", "2016-06-01");,
    put("saleStop", "2014-07-01");,
    put("availableStart", "2014-01-01");,
    put("availableStop", "2016-06-01");,
    put("allowMultiSales", "1");,
    put("subscriptionPeriod", "12000");,
    put("subscriptionRenewPrice", "59");,
    put("subscriptionRenewPeriod", "12000");,
    put("subscriptionAutoRenew", "1");,
    put("subscriptionAutoRenewLockPeriod", "12000");,
    put("subscriptionAutoRenewDisabled", "1");,
    put("subscriptionEmailReceiptLimit", "0");,
    put("subscriptionFinalEndDate", "2014-12-31");,
    put("subscriptionSurveyUrl", "http://survey.example.com");
}};

SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
    POST(token, "/product", params).
    getResponseBody();

This example is an excerpt, see a full example

PHP
Minimal example
<?php
$params = array(
    "code" => "ipad",
    "name" => "John Doe",
    "price" => "400",
    "vat" => "96",
    "paymentOptions" => "2",
    "type" => "discount",
    "currency" => "NOK"
);

$client->auth();
echo var_dump($client->api("/product", "POST", $params));
With all parameters
<?php
$params = array(
    "code" => "ipad",
    "name" => "John Doe",
    "price" => "400",
    "vat" => "96",
    "paymentOptions" => "2",
    "type" => "discount",
    "currency" => "NOK",
    "bundle" => "2",
    "hideItems" => "1",
    "status" => "0",
    "parentProductId" => "44",
    "description" => "Some information",
    "url" => "http://example.com",
    "quantityLimit" => "10",
    "saleStart" => "2016-06-01",
    "saleStop" => "2014-07-01",
    "availableStart" => "2014-01-01",
    "availableStop" => "2016-06-01",
    "allowMultiSales" => "1",
    "subscriptionPeriod" => "12000",
    "subscriptionRenewPrice" => "59",
    "subscriptionRenewPeriod" => "12000",
    "subscriptionAutoRenew" => "1",
    "subscriptionAutoRenewLockPeriod" => "12000",
    "subscriptionAutoRenewDisabled" => "1",
    "subscriptionEmailReceiptLimit" => "0",
    "subscriptionFinalEndDate" => "2014-12-31",
    "subscriptionSurveyUrl" => "http://survey.example.com"
);

$client->auth();
echo var_dump($client->api("/product", "POST", $params));

This example is an excerpt, see a full example

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

(let [client (spid/create-client "[client-id]" "[secret]")
      token (spid/create-server-token client)]
  (spid/POST client token "/product" {"code" "ipad"
                                      "name" "John Doe"
                                      "price" "400"
                                      "vat" "96"
                                      "paymentOptions" "2"
                                      "type" "discount"
                                      "currency" "NOK"}))
With all parameters
(ns example
  (:require [spid-client-clojure.core :as spid]))

(let [client (spid/create-client "[client-id]" "[secret]")
      token (spid/create-server-token client)]
  (spid/POST client token "/product" {"code" "ipad"
                                      "name" "John Doe"
                                      "price" "400"
                                      "vat" "96"
                                      "paymentOptions" "2"
                                      "type" "discount"
                                      "currency" "NOK"
                                      "bundle" "2"
                                      "hideItems" "1"
                                      "status" "0"
                                      "parentProductId" "44"
                                      "description" "Some information"
                                      "url" "http://example.com"
                                      "quantityLimit" "10"
                                      "saleStart" "2016-06-01"
                                      "saleStop" "2014-07-01"
                                      "availableStart" "2014-01-01"
                                      "availableStop" "2016-06-01"
                                      "allowMultiSales" "1"
                                      "subscriptionPeriod" "12000"
                                      "subscriptionRenewPrice" "59"
                                      "subscriptionRenewPeriod" "12000"
                                      "subscriptionAutoRenew" "1"
                                      "subscriptionAutoRenewLockPeriod" "12000"
                                      "subscriptionAutoRenewDisabled" "1"
                                      "subscriptionEmailReceiptLimit" "0"
                                      "subscriptionFinalEndDate" "2014-12-31"
                                      "subscriptionSurveyUrl" "http://survey.example.com"}))

Response

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

Success: 201 Created

Returns the newly created product

Product

productId

integer (as string)

Unique product ID

parentProductId

integer (as string)

ID of the parent product, if any

clientId

string

Your client ID

type

Product type

bundle

Bundle type

code

string

name

string

Product display name

description

string

A detailed description of the product

url

URL (string)

price

price

vat

integer (as string)

VAT, fraction × 10000. For instance, 25% would be 2500

currency

string

Price and VAT currency

paymentOptions

Payment options

Available payment options for this product

quantityLimit

integer (as string)

Maximum available sales for this product.

quantityCount

integer (as string)

Number of sales for this product so far

saleStart

datetime

Start of a sale for this product (i.e. reduced price or with additional benefits)

saleStop

datetime

End of a sale

availableStart

datetime

When this product is available for purchase

availableStop

datetime

When this product is no longer available for purchase

subscriptionPeriod

timestamp, in seconds

The subscription period

subscriptionRenewPrice

price

Price of subscription renewal

subscriptionRenewPeriod

timestamp, in seconds

For how long a renewal is valid

subscriptionAutoRenew

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

If "1", the subscription automatically renews

subscriptionAutoRenewLockPeriod

timestamp, in seconds

The initial period during which auto renew cannot be changed

subscriptionAutoRenewDisabled

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

If "1", auto renew is not available

subscriptionGracePeriod

integer (as string)

The period after a failed renewal charge the subscription will stay active

subscriptionEmailReceiptLimit

integer (as string)

The maximum number of email receipts

subscriptionFinalEndDate

datetime

By this date, the subscription is no longer for sale

allowMultiSales

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

If "1", users can purchase this product multiple times

status

Product status

changedBy

integer (as string)

ID of the user that made the last change

changed

datetime

createdBy

integer (as string)

ID of the user that created this product

created

datetime

purchaseUri

URL (string)

A URI where the product may be purchased

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

Product status

An enum, with the following possible values:

"-1"

Deleted

"0"

Not available

"1"

Available, but not visible

"2"

Available, but not selectable

"3"

Available

Payment options

Payment options can be provided as a bit mask.

Bitmask format is the default format. If payment options are not provided, the default value is 2 (bank card with PayEx).

Examples: 2 means credit card, 4 means SMS, while 6 means both credit card and SMS.

An enum, with the following possible values:

"1"

Masterpass

"2"

Credit card

"4"

SMS

"8"

PayEx Invoice

"16"

Voucher

"32"

Klarna Invoice

"64"

Klarna Mobile

"128"

Wallet

Bundle type

An enum, with the following possible values:

"0"

Not a bundle

"1"

Dynamic bundle

"2"

Onetime bundle

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.

  • 400 Bad Request Missing one or more required parameters
  • 400 Bad Request Failed to create or update product
  • 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
{
  "subscriptionSurveyUrl": null,
  "status": "1",
  "purchaseUri": "https://identity-pre.schibsted.com/auth/start?client_id\u003d52f8e3d9efd04bb749000000\u0026flow\u003dpayment\u0026product_id\u003d301696",
  "changedBy": null,
  "subscriptionAutoRenewLockPeriod": "0",
  "vat": "2500",
  "clientId": "[Your client ID]",
  "guardian": "0",
  "currency": "NOK",
  "subscriptionFinalEndDate": null,
  "quantityCount": "0",
  "createdBy": "[ID of admin user, or client]",
  "name": "VG+",
  "parentProductId": "301696",
  "changed": "2014-08-05 11:59:05",
  "saleStart": null,
  "subscriptionGracePeriod": "0",
  "subscriptionPeriod": "2592000",
  "availableStop": null,
  "subscriptionAutoRenew": "0",
  "productId": "301696",
  "code": "vg+",
  "saleStop": null,
  "bundle": "0",
  "url": null,
  "subscriptionEmailReceiptLimit": null,
  "created": "2014-08-05 11:59:05",
  "subscriptionRenewPeriod": null,
  "type": "2",
  "subscriptionAutoRenewDisabled": "0",
  "subscriptionRenewPrice": null,
  "hideItems": "0",
  "paymentOptions": "2",
  "price": "9900",
  "allowMultiSales": "0",
  "description": null,
  "quantityLimit": null,
  "autopay": "0",
  "availableStart": null
}
JSON-P
callback({
  "subscriptionSurveyUrl": null,
  "status": "1",
  "purchaseUri": "https://identity-pre.schibsted.com/auth/start?client_id\u003d52f8e3d9efd04bb749000000\u0026flow\u003dpayment\u0026product_id\u003d301696",
  "changedBy": null,
  "subscriptionAutoRenewLockPeriod": "0",
  "vat": "2500",
  "clientId": "[Your client ID]",
  "guardian": "0",
  "currency": "NOK",
  "subscriptionFinalEndDate": null,
  "quantityCount": "0",
  "createdBy": "[ID of admin user, or client]",
  "name": "VG+",
  "parentProductId": "301696",
  "changed": "2014-08-05 11:59:05",
  "saleStart": null,
  "subscriptionGracePeriod": "0",
  "subscriptionPeriod": "2592000",
  "availableStop": null,
  "subscriptionAutoRenew": "0",
  "productId": "301696",
  "code": "vg+",
  "saleStop": null,
  "bundle": "0",
  "url": null,
  "subscriptionEmailReceiptLimit": null,
  "created": "2014-08-05 11:59:05",
  "subscriptionRenewPeriod": null,
  "type": "2",
  "subscriptionAutoRenewDisabled": "0",
  "subscriptionRenewPrice": null,
  "hideItems": "0",
  "paymentOptions": "2",
  "price": "9900",
  "allowMultiSales": "0",
  "description": null,
  "quantityLimit": null,
  "autopay": "0",
  "availableStart": null
});

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.