Skip to content

Payments API

Create and manage customer payments.

The Payment Object

json
{
  "id": "payment-550e8400-e29b-41d4-a716-446655440000",
  "merchant_id": "merchant-abc123",
  "amount": 2500,
  "currency": "BSD",
  "status": "completed",
  "payment_mode": "DYNAMIC_PAY",
  "description": "Order #1234",
  "customer_id": "cust-xyz789",
  "transaction_id": "txn-def456",
  "hosted_url": "/checkout/payment-550e8400",
  "qr_payload": "dberi://pay/payment-550e8400",
  "success_url": "https://yourstore.com/success",
  "cancel_url": "https://yourstore.com/cart",
  "metadata": {
    "order_id": "1234",
    "customer_name": "John Smith"
  },
  "created_at": "2026-03-19T10:00:00Z",
  "updated_at": "2026-03-19T10:05:30Z",
  "completed_at": "2026-03-19T10:05:30Z",
  "expires_at": "2026-03-20T10:00:00Z"
}

Attributes

AttributeTypeDescription
idstringUnique payment identifier
merchant_idstringMerchant receiving payment
amountintegerAmount in cents (2500 = $25.00)
currencystringThree-letter ISO currency code (BSD)
statusstringPayment status (see statuses below)
payment_modestringType of payment (see modes)
descriptionstringHuman-readable description
customer_idstringCustomer who made payment
transaction_idstringAssociated transaction ID
hosted_urlstringCheckout page URL path
qr_payloadstringQR code data for mobile payments
success_urlstringRedirect URL after success
cancel_urlstringRedirect URL after cancellation
metadataobjectCustom key-value pairs
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp
completed_atstringISO 8601 timestamp (when completed)
expires_atstringISO 8601 timestamp (24h after creation)

Payment Statuses

StatusDescription
createdPayment session created, awaiting customer
pendingCustomer initiated payment, processing
requires_actionAdditional verification needed (PIN/Face ID)
processingPayment being processed
completedPayment successful
failedPayment failed
expiredPayment session expired (24h)
canceledPayment canceled by customer

Payment Modes

ModeDescription
DYNAMIC_PAYOne-time checkout (default)
STATIC_PAYReusable QR code for in-store
ORDER_PAYPayment with line items
INVOICE_PAYInvoiced payment with due date
REFERENCE_PAYPayment with custom reference

See Payment Modes for detailed usage.

Create a Payment

Creates a new payment session.

bash
POST /v1/payments

Parameters

ParameterTypeRequiredDescription
merchant_idstringYes*Merchant ID (dev mode only)
amountintegerYesAmount in cents
currencystringNoDefault: BSD
payment_modestringNoDefault: DYNAMIC_PAY
descriptionstringNoPayment description
success_urlstringNoRedirect URL after success
cancel_urlstringNoRedirect URL after cancel
metadataobjectNoCustom key-value pairs (max 20 keys)

*In production, merchant_id is derived from your API key.

Example Request

bash
curl -X POST https://api.dberi.com/v1/payments \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2500,
    "currency": "BSD",
    "description": "Premium Membership - Annual",
    "payment_mode": "DYNAMIC_PAY",
    "success_url": "https://yourstore.com/success",
    "cancel_url": "https://yourstore.com/cart",
    "metadata": {
      "user_id": "12345",
      "plan": "premium_annual"
    }
  }'

Example Response

json
{
  "id": "payment-abc123",
  "merchant_id": "merchant-your-id",
  "amount": 2500,
  "currency": "BSD",
  "status": "created",
  "payment_mode": "DYNAMIC_PAY",
  "description": "Premium Membership - Annual",
  "hosted_url": "/checkout/payment-abc123",
  "qr_payload": "dberi://pay/payment-abc123",
  "success_url": "https://yourstore.com/success",
  "cancel_url": "https://yourstore.com/cart",
  "metadata": {
    "user_id": "12345",
    "plan": "premium_annual"
  },
  "created_at": "2026-03-19T10:00:00Z",
  "expires_at": "2026-03-20T10:00:00Z"
}

Retrieve a Payment

Retrieves payment details and current status.

bash
GET /v1/payments/:id

Parameters

ParameterTypeRequiredDescription
idstringYesPayment ID

Example Request

bash
curl https://api.dberi.com/v1/payments/payment-abc123 \
  -H "Authorization: Bearer sk_live_your_api_key"

Example Response

json
{
  "id": "payment-abc123",
  "merchant_id": "merchant-your-id",
  "amount": 2500,
  "currency": "BSD",
  "status": "completed",
  "payment_mode": "DYNAMIC_PAY",
  "description": "Premium Membership - Annual",
  "customer_id": "cust-xyz789",
  "transaction_id": "txn-def456",
  "created_at": "2026-03-19T10:00:00Z",
  "completed_at": "2026-03-19T10:05:30Z"
}

List All Payments

Retrieves a list of payments for your merchant account.

bash
GET /v1/payments

Query Parameters

ParameterTypeDescription
limitintegerNumber of results (default: 20, max: 100)
offsetintegerPagination offset
statusstringFilter by status
start_datestringFilter by created_at (ISO 8601)
end_datestringFilter by created_at (ISO 8601)

Example Request

bash
curl "https://api.dberi.com/v1/payments?limit=10&status=completed" \
  -H "Authorization: Bearer sk_live_your_api_key"

Example Response

json
{
  "payments": [
    {
      "id": "payment-abc123",
      "amount": 2500,
      "status": "completed",
      "created_at": "2026-03-19T10:00:00Z"
    }
  ],
  "total": 42,
  "limit": 10,
  "offset": 0
}

Update a Payment

Updates payment metadata (limited fields).

bash
PATCH /v1/payments/:id

Parameters

ParameterTypeDescription
descriptionstringUpdate description
metadataobjectUpdate metadata

Limited Updates

You cannot change amount, merchant_id, or status after creation.

Example Request

bash
curl -X PATCH https://api.dberi.com/v1/payments/payment-abc123 \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {
      "internal_note": "Customer upgraded from basic plan"
    }
  }'

Cancel a Payment

Cancels a pending payment session.

bash
POST /v1/payments/:id/cancel

Cannot Cancel

You can only cancel payments with status created or pending. Completed payments require a refund.

Example Request

bash
curl -X POST https://api.dberi.com/v1/payments/payment-abc123/cancel \
  -H "Authorization: Bearer sk_live_your_api_key"

Example Response

json
{
  "id": "payment-abc123",
  "status": "canceled",
  "canceled_at": "2026-03-19T10:30:00Z"
}

Confirm Payment (Testing Only)

Simulates a successful payment for testing.

bash
POST /v1/payments/:id/confirm

Testing Only

This endpoint only works in development mode. Use webhooks to detect real payments in production.

Parameters

ParameterTypeRequiredDescription
customer_phonestringNoCustomer phone (creates test customer)

Example Request

bash
curl -X POST https://api.dberi.com/v1/payments/payment-abc123/confirm \
  -H "Content-Type: application/json" \
  -d '{
    "customer_phone": "+12425551234"
  }'

Example Response

json
{
  "id": "payment-abc123",
  "status": "completed",
  "customer_id": "cust-test123",
  "transaction_id": "txn-test456",
  "completed_at": "2026-03-19T10:35:00Z"
}

Refund a Payment

Issues a full or partial refund.

bash
POST /v1/payments/:id/refund

Parameters

ParameterTypeRequiredDescription
amountintegerNoRefund amount in cents (default: full refund)
reasonstringNoRefund reason

Example Request

bash
curl -X POST https://api.dberi.com/v1/payments/payment-abc123/refund \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "amount": 2500,
    "reason": "Customer requested cancellation"
  }'

Example Response

json
{
  "id": "refund-xyz789",
  "payment_id": "payment-abc123",
  "amount": 2500,
  "reason": "Customer requested cancellation",
  "status": "succeeded",
  "created_at": "2026-03-19T11:00:00Z"
}

Verification Requirements

Payments automatically require verification based on amount:

AmountVerification
≤ $2.00 (200 cents)None - instant approval
$2.01 - $50.00 (201-5000 cents)PIN (4-6 digits)
> $50.00 (5001+ cents)Face ID / Biometric

This is handled automatically by the Dberi checkout page.

Idempotency

Prevent duplicate payments by including an idempotency key:

bash
curl -X POST https://api.dberi.com/v1/payments \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-12345" \
  -d '{"amount": 2500}'

Same key = same response (no duplicate charge).

Expiration

Payment sessions expire after 24 hours by default. After expiration:

  • Checkout page shows "Payment Expired"
  • Status becomes expired
  • Customer must create new payment

Errors

CodeDescription
PAYMENT_NOT_FOUNDPayment ID doesn't exist
PAYMENT_EXPIREDPayment session has expired
PAYMENT_ALREADY_COMPLETEDPayment was already processed
PAYMENT_CANCELEDPayment was canceled
INSUFFICIENT_BALANCECustomer has insufficient funds
INVALID_PINCustomer entered wrong PIN
MERCHANT_NOT_FOUNDMerchant ID doesn't exist
INVALID_AMOUNTAmount must be positive integer

Webhooks

Subscribe to payment events:

payment.created
payment.completed
payment.failed
payment.refunded
payment.canceled

See Webhooks API for details.

Next Steps

Built for the Bahamas, powered by innovation