A customer's saved cards

get/v1/customers/{id}/payment_methods

Parameters

idstring (uuid)in pathrequired

Responses

  • 200OKobject
    Show the fields
    object"list"
    dataarray of PaymentMethod
    Fields of data
    idstring (uuid)
    object"payment_method"
    brandstring | null
    last4string
    exp_monthinteger
    exp_yearinteger
    created_atstring (date-time)
    has_moreboolean
bash
curl https://sandbox.api.biftpay.com/v1/customers/{id}/payment_methods \
  -H "Authorization: Bearer bp_test_..."
response
{
  "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 query

Only this customer's

statusactive | past_due | canceledin query

Responses

  • 200OKobject
    Show the fields
    object"list"
    dataarray of Subscription
    Fields of data
    idstring (uuid)
    object"subscription"
    livemodeboolean
    customerstring (uuid)
    payment_methodstring (uuid) | null

    The saved card it's paid from (null when by direct debit).

    mandatestring (uuid) | null

    The direct debit mandate it's paid from (null when by card).

    pending_paymentstring (uuid) | null

    A direct debit for this period still at the bank (the payment), or null.

    brandstring (uuid) | null
    descriptionstring
    amountinteger

    Minor units (kobo, cents).

    at least 0

    currencyNGN | USD
    intervalweekly | monthly | yearly
    statusactive | past_due | canceled
    next_charge_atstring (date-time)
    failed_attemptsinteger
    latest_paymentstring (uuid) | null
    created_atstring (date-time)
    canceled_atstring (date-time) | null
    has_moreboolean
bash
curl https://sandbox.api.biftpay.com/v1/subscriptions \
  -H "Authorization: Bearer bp_test_..."
response
{
  "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 headerrequired

A 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.

amountintegerrequired

at least 1

currencyNGN | USD
intervalweekly | monthly | yearlyrequired
descriptionstringrequired

up to 200 characters

brandstring (uuid)
start_atstring (date-time)

Responses

  • 201OKSubscription
    Show the fields
    idstring (uuid)
    object"subscription"
    livemodeboolean
    customerstring (uuid)
    payment_methodstring (uuid) | null

    The saved card it's paid from (null when by direct debit).

    mandatestring (uuid) | null

    The direct debit mandate it's paid from (null when by card).

    pending_paymentstring (uuid) | null

    A direct debit for this period still at the bank (the payment), or null.

    brandstring (uuid) | null
    descriptionstring
    amountinteger

    Minor units (kobo, cents).

    at least 0

    currencyNGN | USD
    intervalweekly | monthly | yearly
    statusactive | past_due | canceled
    next_charge_atstring (date-time)
    failed_attemptsinteger
    latest_paymentstring (uuid) | null
    created_atstring (date-time)
    canceled_atstring (date-time) | null
  • 400Invalid request
  • 422Idempotency-Key reused with a different request
bash
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": "…"
  }'
response
{
  "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 pathrequired
Idempotency-Keystringin headerrequired

A 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"
    livemodeboolean
    customerstring (uuid)
    payment_methodstring (uuid) | null

    The saved card it's paid from (null when by direct debit).

    mandatestring (uuid) | null

    The direct debit mandate it's paid from (null when by card).

    pending_paymentstring (uuid) | null

    A direct debit for this period still at the bank (the payment), or null.

    brandstring (uuid) | null
    descriptionstring
    amountinteger

    Minor units (kobo, cents).

    at least 0

    currencyNGN | USD
    intervalweekly | monthly | yearly
    statusactive | past_due | canceled
    next_charge_atstring (date-time)
    failed_attemptsinteger
    latest_paymentstring (uuid) | null
    created_atstring (date-time)
    canceled_atstring (date-time) | null
  • 404Not found, or not visible to this key
bash
curl -X POST https://sandbox.api.biftpay.com/v1/subscriptions/{id}/cancel \
  -H "Authorization: Bearer bp_test_..." \
  -H "Idempotency-Key: $(uuidgen)"
response
{
  "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": "…"
}