JWT Dynamic Paid Content API

Warning

This property has been removed in Connector Script 3.

It has been replaced with the new property In-Page Configuration Token.

JWT Dynamic Paid Content API allows you to publish new paid content without having to add a new Single Purchase or Price Point in Connector Admin Interface.

To enable this option for a page, a JSON web token (JWT) containing the required properties and signed with your secret API Key needs to be present in your article’s HTML source as a jwt_pc In-Page Configuration property.

Note

Your secret API Key can be retrieved from the “Developer” section in Merchant Backend. The URL that you use to access Merchant Backend depends on the region and enviroment of your integration. You can find the proper URL in section URLs of Merchant Backend.

JWT Object Properties

  • article_id (required) - a string consisting of letters, digits, hyphens and underscores no longer than 128 characters that is unique for the article being offered.

  • pricing (required) - an object with exactly one price. A price is an object that maps a currency code to a number of cents (cent being one hundredth of a currency unit) as an integer. Example pricing for an article priced at 1.29 € is {"EUR": 129} or for USD 0.39 {"USD": 39}. Prices in PPU model must be between 5 and 500 cents. Prices in SIS model must be between 149 and 14999 cents.

    The supported currency depends on the region of your integration. Read chapter Regions, Environments and Locales for more information.

  • model (optional) - Revenue model. "ppu" or "sis" string values are allowed. By default "ppu" is applied.

    • "ppu" - Pay later (formerly “Pay Per Use”): Users can agree to pay later for an article and get access to the article right away. The article will be added to their digital invoice which they’ll need to pay when it crosses 500 cents threshold.
    • "sis" - Pay now (formerly “Single Item Sale”): Users can buy access to the article after they pay for it using LaterPay.
  • page_structure (optional) - ID of the Template (formerly named “Page Structure”) that should be used for this article. Template must be defined in Connector Admin Interface. The ID can be obtained from the Template details page in Connector Admin Interface. If the ID is not provided, the first Template in the list will be used.

Note

An exp (Expiration Time) JWT claim can be included in the token payload and it will be validated by Connector i.e. expired tokens will be refused.

Impact of any caching mechanisms used by the website should be considered before including the exp claim.

If there is no exp claim set, the token will be valid virtually forever i.e. as long as your Merchant Account is active and the referenced Template exists.

Example

If your API Key is “test-secret” and you create a Page Structure with the ID “4da56fbc-def7-42e2-bbe1-10fd0ca0aae3”, a token can be created with following payload:

{
    "article_id": "my-article-1878",
    "pricing": {"EUR": 49},
    "model": "ppu",
    "page_structure": "4da56fbc-def7-42e2-bbe1-10fd0ca0aae3"
}

Using the HS256 algorithm and “test-secret” as your secret API Key results in the follwing JSON web token:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtb2RlbCI6InBwdSIsImFydGljbGVfaWQiOiJteS1hcnRpY2xlLTE4NzgiLCJwcmljaW5nIjp7IkVVUiI6NDl9LCJwYWdlX3N0cnVjdHVyZSI6IjRkYTU2ZmJjLWRlZjctNDJlMi1iYmUxLTEwZmQwY2EwYWFlMyJ9.PCqmzgQkCD1HJO0oy0ddAtYuTrv_aptiGKdmC5wX068

This token can be included in your page as In-Page Configuration property jwt_pc:

<meta property="laterpay:connector:jwt_pc" content="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtb2RlbCI6InBwdSIsImFydGljbGVfaWQiOiJteS1hcnRpY2xlLTE4NzgiLCJwcmljaW5nIjp7IkVVUiI6NDl9LCJwYWdlX3N0cnVjdHVyZSI6IjRkYTU2ZmJjLWRlZjctNDJlMi1iYmUxLTEwZmQwY2EwYWFlMyJ9.PCqmzgQkCD1HJO0oy0ddAtYuTrv_aptiGKdmC5wX068">