One subscription per customer
How Flex Malipo stops a customer from holding the same subscription twice.
A customer cannot hold two open subscriptions to the same product with you. You can also allow only one open subscription for each brand, whatever the product of that brand.
An open subscription is one with the status trialing, active or past_due. A subscription that is incomplete,
canceled or expired does not count. Test and live mode are separate, so a live subscription does not count in test
mode.
Rules
| Rule | When it applies |
|---|---|
| One open subscription per customer and product | Always. |
| One open subscription per customer and brand | When oneSubscriptionPerCustomer is true in your billing settings. It is false by default. |
To turn the second rule on, call Update billing settings
with oneSubscriptionPerCustomer set to true. The call replaces all your settings, and a field you leave out takes its
default, so retrieve the settings first and send
every field back. Settings are kept per mode.
An upgrade or a renewal changes a subscription the customer already has. It is not a new subscription and is not checked.
When you create a checkout session
Create a checkout session with mode subscription
for a customer who breaks a rule is refused with 409 and the code subscription_exists. The message names the open
subscription:
{
"error": {
"type": "invalid_request_error",
"code": "subscription_exists",
"message": "Customer 4f1d7c2e-8a3b-4c5d-9e6f-0a1b2c3d4e5f already has an open subscription 9b2e6a40-1c3d-4e5f-8a7b-6c5d4e3f2a1b to this product.",
"requestId": "req_0123456789abcdef0123456789abcdef"
}
}Do not retry it unchanged. Send the customer to the subscription they hold, or change it.
When the payment completes
Two sessions for the same customer and product can be open at once, and both can be paid. Flex Malipo checks the rules again when a payment completes. A second paid session creates no second subscription. The subscription it was meant to start expires, and the money becomes the customer's refundable credit.
You get invoice.overpaid without an invoiceId. Its subscriptionId is the subscription the customer already holds,
and a customer.balance.updated event follows. To give the money back, refund the payment.