Skip to main content

Welcome to our Dev Docs!

Overview

SubscriptionJS offers a lightweight, easy-to-use JavaScript Library to provide self-service functionality to customers seamlessly in your own website. This includes functions like orders, customer / contract data view and modification, downloading invoices, ... SubscriptionJS weighs in at only a few kB, and doesn't meddle with your DOM (except for loading PSP-specific javascript, if required). Essentially, it's a Javascript SDK for billwerk that hides cross-origin complexity.

Because of its design, SubscriptionJS is compatible with any frontend framework such as ReactJS, Vue.js, Angular or simply jQuery.

Essentially, SubscriptionJS consists of these three modules:

Signup

Handles the initial order of new customers. These operations can be performed for anonymous users and consequently, don't require any form of identification or authentication. Signup also provides functionality to calculate a detailed pricing information based on the cart and customer data (tax depends on country and vat id). A signup includes registration of the new customer and the subscription (contract) in billwerk.

Notice

For data security reasons the publicly accessible signup does not check for existence of a customer.

Consequently, all subsequent subscriptions of a single customer will create a new customer object. If you want to allow customers to subscribe several times you have to provide a separate order process from within your customer's authenticated account. Currently, SubscriptionJS does not provide a corresponding helper method. Please take a look at our Use Cases section on how to create such an order. The rest of the order process is covered in SubscriptionJS.Introduction

Details

Portal

Contains methods that help you creating a portal for your customers:

  • View current plan

  • Modify personal data: name, address, ...

  • Change payment data: provide new CC, change payment method, ...

  • Up-/Downgrade: SubscriptionJS provides helpers to commit an up-/downgrade order. The order has to be created using the billwerk API

  • Order additional components (in conjunction with up-/downgrades)

  • Cancel a contract

  • Download invoices

Details

Since these methods allow fetching/modifying contract information and personal data, they require a selfServiceToken that you have to acquire through a regular API call from your backend. The token has a limited lifetime.

Notice

Please note all functions are contract based. You need to acquire a separate token for each contract. A description on how to retrieve an access token can be found here.

Payment

Puts an abstraction on payment service providers. While this is the most complex module internally, it also has the simplest API. Usually, all you need to do is construct this object and pass it to corresponding functions that require payment.