Developer Docs

Developer Docs

  • Getting Started
  • SubscriptionJS
  • REST API
  • Webhooks
  • Code Samples
  • UseCases
  • Request a Demo

›Methods

SubscriptionJS

  • Overview
  • Initial Setup
  • Signup
  • Portal
  • Payments
  • Coupons
  • Synchronization
  • Going Live

Reference

    Methods

    • Payment
    • Signup
    • Portal
    • General
  • Types
  • Callbacks

Embeddable Elements

  • Available Elements
  • Payment Form IFrame

    • Introduction
    • Configuration
    • Appearance
    • Reference

SubscriptionJS.Portal

  • SubscriptionJS.Portal(selfServiceToken)
  • upgradePaySync(orderId, success, error)
  • upgradePayInteractive(subscriptionJSPayment, secretPaymentData, order, success, error)
  • upgradePayInteractive(null, paymentForm, order, success, error)
  • invoicePdfDownloadUrl(invoice)
  • contractDetails(success, error)
  • contractCancel(success, error)
  • customerChange(customerData, success, error)
  • paymentChange(subscriptionJSPayment, secretPaymentData, success, error)
  • paymentChange(null, paymentForm, success, error)

SubscriptionJS.Portal(selfServiceToken)

Constructor. Creates an instance of SubscriptionJS.Portal.

PropertyTypeDescription
selfServiceTokenstringA token to identify and authenticate a customer. You can request this token from the API via GET /api/v1/contracts/{contractId}/selfServiceToken.

upgradePaySync(orderId, success, error)

Allows the customer to pay for an upgrade using the currently active payment method in a 'synchronous' fashion, i.e. the success method will be called only after the call to the PSP has finished. This method is non-interactive, the user can't change the active payment method using this call. Also note that this does not require to load client-side payment libraries.

PropertyTypeDescription
orderIdstringId of an order to pay for. The order must have been created before using a backend API call.

upgradePaySync success

{
  "OrderId": "5ca5d0fd12a50c79c94f46f0",
  "ContractId": "5ca4b04a50abb730802f9e78",
  "CustomerId": "5ca4b04a50abb730802f9e77",
  "GrossTotal": 387.6,
  "OrderStatus": "PaymentPending"
}

upgradePaySync error


upgradePayInteractive(subscriptionJSPayment, secretPaymentData, order, success, error)

Allows the customer to pay for an upgrade using new payment data. This method is interactive. Forward user to PSP page if URL is returned.

PropertyTypeDescription
subscriptionJSPaymentSubscriptionJS.PaymentAn instance of SubscriptionJS.Payment.
secretPaymentDatasecretPaymentDataThe potentially secret payment information entered by the customer to pay for the order.
orderorderAn order object previously created either via SubscriptionJS.Signup.createOrder() or via a backend call or via the billwerk user interface. Must look like { OrderId : "(id)", GrossTotal : 23.4, Currency : "EUR" }

upgradePayInteractive success

{ "OrderId": "5ca4af02bb573feacc9f7b55", "ContractId": "5ca4af0250abb730802f9e3e", "CustomerId": "5ca4af0250abb730802f9e3d", "GrossTotal": 89.25, "Currency": "EUR", "OrderStatus": "InProgress" }

upgradePayInteractive error


upgradePayInteractive(null, paymentForm, order, success, error)

[paymentForm EXCLUSIVE]
Behaves like upgradePayInteractive, except subscriptionJsPayment is not necessary and paymentForm is submitted instead of secretPaymentData.


invoicePdfDownloadUrl(invoice)

Creates a download url for a PDF document. The URL will point to billwerk, so using this method makes billwerk 'visible' to your customers. If you want to avoid this, you will have to route requests through your server or mirror the PDFs proactively. To get a list of invoices for a contract please use the function contractDetails(...).

PropertyTypeDescription
invoicestring or invoice objectEither the id of the invoice or an invoice object that has an 'Id' field. A URL string to download the PDF, including the selfServiceToken that is required for authentication.

contractDetails(success, error)

Returns details about the current contract, customer, and payment method. It also lists up to 50 recent invoices.


contractCancel(success, error)

Cancels the contract regularly, so that it ends at the next possible point in time given by the cancellation period and minimum contract duration settings.


customerChange(customerData, success, error)

Changes a customer's data such as name, address or VAT id.

It will be possible to prohibit this method call under Settings -> SubscriptionJS in case you don't want users to be able to change their data without prior verification, or if you want to allow data changes only in your system.

Caution! Changing customer data affects all contracts of the customer.

PropertyTypeDescription
customerDatacustomerDataAn object containing the new customer data. If a field in this object is unset, it will be unset in the customer, too, so this has PUT semantics, not PATCH semantics.

paymentChange(subscriptionJSPayment, secretPaymentData, success, error)

Sets up a new payment method for the contract.

PropertyTypeDescription
subscriptionJSPaymentSubscriptionJS.PaymentAn instance of SubscriptionJS.Payment that will be used to talk to the payment service provider. At present, the instance must be ready before calling this method.
secretPaymentDataSecretPaymentDataPotentially secret payment data required for the respective payment method, e.g. credit card or direct debit information.

paymentChange(null, paymentForm, success, error)

[paymentForm EXCLUSIVE]
Behaves like paymentChange, except subscriptionJsPayment is not necessary and paymentForm is submitted instead of secretPaymentData.

Last updated on 3/30/2021 by AxelDuenninger
← SignupGeneral →
Docs
Getting StartedAPI Reference
Resource
Help CenterSupportBlogTutorials
Start with billwerk
Test for free
Request a Demo
Already started?
billwerk Sandboxbillwerk Production
billwerk GmbH
© Made with ❤ in Germany for Europe by billwerk GmbH | 2022
Imprint
|
Data Privacy Rules
|
Disclaimer