On-demand billing

Subscriptions can also be used as recurring payment agreements where there is no automatic billing.

This functionality can for example be used in a scenario where a customer pays a bill and then sign-up for automatic payment. E.g. an auto refill scenario where a customer uses credits from some account.

To use this functionality a subscription plan with manual billing cycle must be used. The plan can either have zero amount or it can have some fixed amount. Invoices can be created on-demand for the subscription either with automatic handling like dunning management as if it was created by Reepay, or the invoice can be set to fail instantly if it cannot be paid, allowing instant feedback on the success or failure.

When the customer signs-up for automatic payment a subscription is created for a manual plan. The subscription can be seen as a recurring payment agreement. When a bill is subsequently generated in the merchant system it is created as an invoice in Reepay and Reepay handles potential dunning etc.

Using recurring payment agreements can be divided into a number of steps described below.

Creating agreement

You the merchant has a bill to be paid. The customer is prompted with a sign-up for automatic payment and with an option to either use an existing payment method, or to create a new one using our Reepay Checkout or Reepay Token Solution .

A subscription is then created using the source argument where the value is either a stored customer payment method or a short-term card token.

curl -X POST \
-u 'priv_12051dfac75143fc827cf63a87f46df3:' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
  "handle": "cust-4234-refill-13",
  "plan": "refill",
  "customer": "cust-4234",
  "source": "ca_e4926c46be444fcbbc809be06abfd706"
}' \
https://api.reepay.com/v1/subscription

On-demand billing

To create the first bill an invoice for the subscription must be created. See here.

The amount for the invoice can either be taken from the plan using the plan_manual flag or a number of given order_lines, or a combination. A refill agreement might have a fixed amount to refill with, in which case the plan amount is suitable, or it can be more custom in which case an order line can be defined. Below an example with order line provided an no plan amount.

curl -X POST \
-u 'priv_12051dfac75143fc827cf63a87f46df3:' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
  "handle": "invoice-007",
  "instant": false,
  "plan_manual": false,
  "order_lines": [
    {
      "ordertext": "Refill of account",
      "amount": 29900,
      "vat": 0.25,
      "quantity": 1,
    }
  ]
}' \
https://api.reepay.com/v1/subscription/cust-4234-refill-13/invoice

An invoice will now be created and handled by Reepay. Potentially going through dunning management. Alternatively the flag instant can be used to indicate that the invoice should be processed instantly and either be returned as settled or failed. This way you the merchant will instantly know the result. The transactions in the invoice object can be used to determine why the payment failed.

When a new bill is generated by the merchant system it is again created as an invoice in Reepay.