Adding contract for existing customer

To create a contract for an existing customer a somewhat different process is required than creating a new customer altogether, because we have no way of identifying, authenticating or authorizing your customers. Hence, to create a contract for an existing customer, the request must go through your server's backend to the billwerk REST API.

However, that separation makes sense because the workflow is usually quite different from an end-user perspective. Re-entering a lot of information seems useless, and the order process usually doesn't involve the public website's checkout process.

Create order

Sample request

POST /Orders

{
  "TriggerInterimBilling": false,
  "CustomerId": "5e5361659cc9ba118cccc630",
  "Cart": {
    "PlanVariantId": "5e5361659cc9ba118cccc620",
    "InheritStartDate": false,
    "ComponentSubscriptions": [
      {
        "ComponentId": "5e5361659cc9ba118cccc61e",
        "Quantity": 2.0
      }
    ]
  },
  "PreviewAfterTrial": false
}

Sample response

{
  "Id": "5e5361659cc9ba118cccc631",
  "AllowWithoutPaymentData": true,
  "ComponentSubscriptions": [
    {
      "ComponentType": "QuantityBased",
      "PreventModification": false,
      "VatPercentage": 19.0,
      "TotalNet": 2.0,
      "TotalVat": 0.38,
      "IsQuantityBased": false,
      "ComponentId": "5e5361659cc9ba118cccc61e",
      "Quantity": 2.0
    }
  ],
  "Total": 7.0,
  "TotalVat": 1.33,
  "TotalGross": 0.0,
  "NextTotalGross": 0.0,
  "IsTrial": false,
  "TrialEndPolicy": "NoTrial",
  "Status": "InProgress",
  "OrderType": "Signup",
  "TriggerInterimBilling": false,
  "CustomerId": "5e5361659cc9ba118cccc632",
  "ContractId": "5e5361659cc9ba118cccc605",
  "PreviewAfterTrial": false
}

Commit the order through a payment

The details depend on your payment requirements. If the customer only pays on account, or you let him sign up without payment data, you can also use an API call. In the more common use case where you need to (or at least want to have the option to) collect payment data, we're facing the interactive payment process implemented in SubscriptionJS again.

SubscriptionJS offers a method paySignupInteractive(subscriptionJSPayment, secretPaymentData, order, success, error) that you can use to perform the interactive payment for an order. This method is internally called by SubscriptionJS's subscribe(), too. However, subscribe() also creates the order via JS. Creating orders is one of the few processes that can be performed both via JS and via the REST API.