Basics - SubscriptionJS
Overview
SubscriptionJS offers a lightweight, easy-to-use JavaScript Library to provide self-service functionality to customers seamlessly on your website. This includes functions like orders, customer/contract data view and modification, downloading invoices, and more. SubscriptionJS is minimalistic, only a few kB in size, and doesn't interfere with your DOM (except for loading PSP-specific JavaScript, if required). In essence, it's a JavaScript SDK for billwerk that abstracts cross-origin complexities.
Thanks to its design, SubscriptionJS is compatible with any frontend framework, ReactJS, Vue.js, Angular, or even jQuery.
SubscriptionJS primarily consists of four modules:
Signup
Handles the initial order of new customers. These operations can be performed for anonymous users and, as such, don't require any form of identification or authentication. Signup also provides functionality to calculate detailed pricing information based on the cart and customer data (since tax depends on the country and VAT ID). Signup includes the registration of the new customer and the subscription (contract) in billwerk.
Note: For data security reasons, the publicly accessible signup does not check for the existence of a customer. Therefore, all subsequent subscriptions of a single customer will create a new customer object. If you wish to allow customers to subscribe multiple times, you must provide a separate order process from within your customer's authenticated account. Currently, SubscriptionJS does not offer a corresponding helper method. Refer to our Use Cases section on creating such an order. The rest of the order process is covered in SubscriptionJS.
Portal
This module contains methods that assist in creating a portal for your customers, allowing them to:
- View their current plan
- Modify personal data such as name, address, etc.
- Change payment data, including providing a new credit card or changing the payment method
- Up-/Downgrade (SubscriptionJS offers helpers to commit an up-/downgrade order, but the order must be created using the billwerk API)
- Order additional components (in conjunction with up-/downgrades)
- Cancel a contract
- Download invoices
Important: Since these methods allow fetching/modifying contract information and personal data, they require a
selfServiceToken
that you must acquire through a regular API call from your backend. This token has a limited lifetime. All functions are contract-based, meaning you need a separate token for each contract. Instructions on retrieving an access token are available.
Payment
This module abstracts payment service providers. Although it's the most intricate module internally, it boasts the most straightforward API. Typically, all you need to do is construct this object and pass it to the corresponding functions that require payment.
Payment Form Iframe
Dealing with PCI DSS compliance can cause a real headache. Billwerk+ Transform, therefore, provides an easy way to be compliant without the hustle of dealing with it yourself for your business. You'll find further information about our paymentForm
here.
Updated 9 months ago