Subscriptions
A customer's saved cards
get/v1/customers/{id}/payment_methods
Parameters
idstring (uuid)in pathrequiredResponses
- 200OKobject
Show the fields
object"list"dataarray of PaymentMethodFields of data
idstring (uuid)object"payment_method"brandstring | nulllast4stringexp_monthintegerexp_yearintegercreated_atstring (date-time)has_moreboolean
curl https://sandbox.api.biftpay.com/v1/customers/{id}/payment_methods \
-H "Authorization: Bearer bp_test_..."{
"object": "list",
"data": [
{
"id": "…",
"object": "payment_method",
"last4": "…",
"exp_month": 1000,
"exp_year": 1000,
"created_at": "…"
}
]
}List subscriptions
get/v1/subscriptions
Parameters
customerstring (uuid)in queryOnly this customer's
statusactive | past_due | canceledin queryResponses
- 200OKobject
Show the fields
object"list"dataarray of SubscriptionFields of data
idstring (uuid)object"subscription"livemodebooleancustomerstring (uuid)payment_methodstring (uuid) | nullThe saved card it's paid from (null when by direct debit).
mandatestring (uuid) | nullThe direct debit mandate it's paid from (null when by card).
pending_paymentstring (uuid) | nullA direct debit for this period still at the bank (the payment), or null.
brandstring (uuid) | nulldescriptionstringamountintegerMinor units (kobo, cents).
at least 0
currencyNGN | USDintervalweekly | monthly | yearlystatusactive | past_due | cancelednext_charge_atstring (date-time)failed_attemptsintegerlatest_paymentstring (uuid) | nullcreated_atstring (date-time)canceled_atstring (date-time) | nullhas_moreboolean
curl https://sandbox.api.biftpay.com/v1/subscriptions \
-H "Authorization: Bearer bp_test_..."{
"object": "list",
"data": [
{
"id": "…",
"object": "subscription",
"livemode": true,
"customer": "…",
"payment_method": "…",
"mandate": "…",
"description": "…",
"amount": 0,
"currency": "NGN",
"interval": "weekly",
"status": "active",
"next_charge_at": "…",
"failed_attempts": 1000,
"created_at": "…"
}
]
}Charge a saved card or debit a mandate every week, month or year
post/v1/subscriptions
Paid from a saved card (payment_method: save it first with a payment that has save_payment_method true and a customer) or by scheduled direct debit (mandate: one that's active, or still pending; debits wait until it's active). The first charge happens at start_at (default now). A direct debit usually takes a while at the bank: the period's debit is finished before the next one starts (pending_payment).
Parameters
Idempotency-Keystringin headerrequiredA unique key per logical request, for example a UUID. Up to 255 characters.
up to 255 characters
Body
payment_methodstring (uuid)A saved card. Give this or mandate.
mandatestring (uuid)A direct debit mandate (naira). Give this or payment_method.
amountintegerrequiredat least 1
currencyNGN | USDintervalweekly | monthly | yearlyrequireddescriptionstringrequiredup to 200 characters
brandstring (uuid)start_atstring (date-time)Responses
- 201OKSubscription
Show the fields
idstring (uuid)object"subscription"livemodebooleancustomerstring (uuid)payment_methodstring (uuid) | nullThe saved card it's paid from (null when by direct debit).
mandatestring (uuid) | nullThe direct debit mandate it's paid from (null when by card).
pending_paymentstring (uuid) | nullA direct debit for this period still at the bank (the payment), or null.
brandstring (uuid) | nulldescriptionstringamountintegerMinor units (kobo, cents).
at least 0
currencyNGN | USDintervalweekly | monthly | yearlystatusactive | past_due | cancelednext_charge_atstring (date-time)failed_attemptsintegerlatest_paymentstring (uuid) | nullcreated_atstring (date-time)canceled_atstring (date-time) | null - 400Invalid request
- 422Idempotency-Key reused with a different request
curl -X POST https://sandbox.api.biftpay.com/v1/subscriptions \
-H "Authorization: Bearer bp_test_..." \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"amount": 1,
"interval": "weekly",
"description": "…"
}'{
"id": "…",
"object": "subscription",
"livemode": true,
"customer": "…",
"payment_method": "…",
"mandate": "…",
"description": "…",
"amount": 0,
"currency": "NGN",
"interval": "weekly",
"status": "active",
"next_charge_at": "…",
"failed_attempts": 1000,
"created_at": "…"
}Cancel a subscription
post/v1/subscriptions/{id}/cancel
Parameters
idstring (uuid)in pathrequiredIdempotency-Keystringin headerrequiredA unique key per logical request, for example a UUID. Up to 255 characters.
up to 255 characters
Responses
- 200OKSubscription
Show the fields
idstring (uuid)object"subscription"livemodebooleancustomerstring (uuid)payment_methodstring (uuid) | nullThe saved card it's paid from (null when by direct debit).
mandatestring (uuid) | nullThe direct debit mandate it's paid from (null when by card).
pending_paymentstring (uuid) | nullA direct debit for this period still at the bank (the payment), or null.
brandstring (uuid) | nulldescriptionstringamountintegerMinor units (kobo, cents).
at least 0
currencyNGN | USDintervalweekly | monthly | yearlystatusactive | past_due | cancelednext_charge_atstring (date-time)failed_attemptsintegerlatest_paymentstring (uuid) | nullcreated_atstring (date-time)canceled_atstring (date-time) | null - 404Not found, or not visible to this key
curl -X POST https://sandbox.api.biftpay.com/v1/subscriptions/{id}/cancel \
-H "Authorization: Bearer bp_test_..." \
-H "Idempotency-Key: $(uuidgen)"{
"id": "…",
"object": "subscription",
"livemode": true,
"customer": "…",
"payment_method": "…",
"mandate": "…",
"description": "…",
"amount": 0,
"currency": "NGN",
"interval": "weekly",
"status": "active",
"next_charge_at": "…",
"failed_attempts": 1000,
"created_at": "…"
}