Mixing products
There can be a number of situations where the customer will combine the purchase of a subscription and a one-off payment.
A common use case:
- You sell a physical product, and at the same time, people sign up for a subscription.
- Example: A customer buys a new mobile phone and signs up for a new mobile subscription.
In these situations, the one-off order should be paid independently of the subscription.
Billwerk+ Checkout can be used to solve this use-case by following the following steps:
- Create a Billwerk+ Checkout charge session with the recurring flag.
- Present a Checkout window to your customers for purchase and sign-up.
- Create subscriptions.
1️⃣/3️⃣ Checkout charge session
Create a charge session with the recurring flag set to true
. The recurring flag indicates that in addition to making a payment, the payment method should also be returned and stored for the customer.
curl -X POST \
--url https://checkout-api.reepay.com/v1/session/charge \
-u 'priv_11118ec111dc1a7faaa192cef2226917e:' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"recurring":true,
"order": {
"handle": "order-id-221",
"currency": "DKK",
"customer": {
"handle":"c-1",
"email": "[email protected]",
"phone": "+2313123123",
"first_name": "John",
"last_name": "Doe"
},
"currency": "USD,
"amount": 20000
}
}'
The customer will be created, if the customer does not already exist. A reference to an existing customer can also be provided in the parameter customer_handle
instead. For details on creating a charge session, see: Billwerk+ Checkout.
2️⃣/3️⃣ Customer payment in Checkout
After a successful payment, the parameter payment_method
will be returned, among other return parameters. The parameter is a reference to a saved customer payment method that can be used when creating a subscription or making one-off payments.
3️⃣/3️⃣ Create subscription
A subscription is created with an API call where the customer handle and payment method reference from the previous step is used.
curl -X POST \
-u 'priv_12051dfac75143fc827cf63a87f46df3:' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"handle": "s-101",
"plan": "gold",
"signup_method": "source",
"customer": "c-1",
"source": "<payment method>"
}' \
https://api.reepay.com/v1/subscription
For full details on the create subscription operation, see: Create subscription.
A subscription exists now for the customer. The handle for the subscription is the reference for the subscription that can be stored in your system.
Note
We recommend using a supplied handle, but it is also possible to use the argument
generate_handle=true
instead ofhandle
to let Billwerk+ Payments generate a handle.
Updated 9 months ago