Parts of the system:
In the browser there will be a Storefront, possibly including Billforward-JS which is a library designed to simplify the process of tokenising a card number and adding it to an account in the Billforward API.
A Store API will front the system in order to marshal calls to commercetools
commercetools
The Integration system
Billforward
Payment Service Provider (PSP)
Starting from the administration of the system:
Administrator will create a plan or contract type in the Billforward UI or using the Billforward API (the UI is just a cut-down front to the API)
Billforward will asynchronously create a change notification which will be used, either via a MQ or a WebHook to call the Integration in order to update products in commercetools.
Then a user buying products:
The user views products which are supplied by the Store API. Potentially cached or fetched from commercetools.
When a product is added to the basket, a call is made via the Store API to create a basket in commercetools.
Optionally, the Integration could perform a “Create Quote” operation on Billforward to ensure the exact prices are shown - for example if a customer sells items on a per-calendar-month basis and we’re part way through the month or the customer has already got a subscription for the item and they’re increasing volume.
The user enters their details and these are sent via the Store API to commercetools.
The integration sends the user details to Billforward, optionally looking up a BF account or simply creating a new one.
The user enters their credit card details which are sent directly to the PSP and a token is returned.
The returned token is directly added to the Billforward account and optionally set as the default payment method.
An order is created from the basket via the Store API in commercetools. The Integration picks up this order and creates the relevant subscriptions and/or one-off invoices for the items in the order.
Payment is made asynchronous by the PSP from Billforward
A notification is sent to the Integration so that the payments are added to Commercetools and the order is completed.
Notification can be sent to the end user that the order is complete.
For refunds
Refunds are initiated by an administrator and a request is sent to commercetools
The Integration picks up the request and requests Billforward to perform the refund using the relevant PSP
Information about the refund is returned to commercetools and the administrator.
For recurring payments
This is handled between Billforward and the PSP
If the customer wishes to track physical delivery and orders in commercetools, this will be done asynchronously via the Integration.
Stock control is not required by any current customers.
Cancellation
The user can cancel via the Store API or an administrator can request cancellation
The cancellation request is received by Billforward and the subscription is cancelled.