Nombaone.PaymentMethods (Nomba One v0.1.0)

View Source

Payment methods — cards (via hosted checkout), direct-debit mandates (see Nombaone.Mandates), and virtual accounts for the transfer rail.

Every function returns {:ok, result} or {:error, %Nombaone.Error{}} and has a raising ! variant.

Summary

Functions

Issue a dedicated virtual account (NUBAN) so the customer can pay by bank transfer. Bank transfer is a push rail: collection completes when the transfer arrives and reconciles — never treat it as instantly final.

List payment methods, newest first. Optional filters: :customer_ref (note the wire name), :limit, :cursor.

Detach a payment method. Subscriptions still billing against it will need a replacement (SUBSCRIPTION_PAYMENT_METHOD_REQUIRED at next charge otherwise).

Retrieve a payment method by id. Common errors: 404 PAYMENT_METHOD_NOT_FOUND.

Make this the customer's default payment method.

Start a hosted-checkout card capture. Card entry happens on the PCI hosted page — no card data ever touches your servers. The method appears as setup_pending until the customer completes checkout. Redirect them to the returned checkout_link.

Functions

create_virtual_account(client, params, opts \\ [])

@spec create_virtual_account(Nombaone.Client.t(), map(), keyword()) ::
  {:ok, Nombaone.VirtualAccount.t()} | {:error, Nombaone.Error.t()}

Issue a dedicated virtual account (NUBAN) so the customer can pay by bank transfer. Bank transfer is a push rail: collection completes when the transfer arrives and reconciles — never treat it as instantly final.

create_virtual_account!(client, params, opts \\ [])

@spec create_virtual_account!(Nombaone.Client.t(), map(), keyword()) ::
  Nombaone.VirtualAccount.t()

Raising variant of create_virtual_account/3.

list(client, params \\ %{}, opts \\ [])

@spec list(Nombaone.Client.t(), map(), keyword()) ::
  {:ok, Nombaone.Page.t()} | {:error, Nombaone.Error.t()}

List payment methods, newest first. Optional filters: :customer_ref (note the wire name), :limit, :cursor.

list!(client, params \\ %{}, opts \\ [])

@spec list!(Nombaone.Client.t(), map(), keyword()) :: Nombaone.Page.t()

Raising variant of list/3.

remove(client, id, opts \\ [])

@spec remove(Nombaone.Client.t(), String.t(), keyword()) ::
  {:ok, Nombaone.PaymentMethod.t()} | {:error, Nombaone.Error.t()}

Detach a payment method. Subscriptions still billing against it will need a replacement (SUBSCRIPTION_PAYMENT_METHOD_REQUIRED at next charge otherwise).

remove!(client, id, opts \\ [])

Raising variant of remove/3.

retrieve(client, id, opts \\ [])

@spec retrieve(Nombaone.Client.t(), String.t(), keyword()) ::
  {:ok, Nombaone.PaymentMethod.t()} | {:error, Nombaone.Error.t()}

Retrieve a payment method by id. Common errors: 404 PAYMENT_METHOD_NOT_FOUND.

retrieve!(client, id, opts \\ [])

Raising variant of retrieve/3.

set_default(client, id, opts \\ [])

@spec set_default(Nombaone.Client.t(), String.t(), keyword()) ::
  {:ok, Nombaone.PaymentMethod.t()} | {:error, Nombaone.Error.t()}

Make this the customer's default payment method.

set_default!(client, id, opts \\ [])

@spec set_default!(Nombaone.Client.t(), String.t(), keyword()) ::
  Nombaone.PaymentMethod.t()

Raising variant of set_default/3.

setup(client, params, opts \\ [])

@spec setup(Nombaone.Client.t(), map(), keyword()) ::
  {:ok, Nombaone.CheckoutSetup.t()} | {:error, Nombaone.Error.t()}

Start a hosted-checkout card capture. Card entry happens on the PCI hosted page — no card data ever touches your servers. The method appears as setup_pending until the customer completes checkout. Redirect them to the returned checkout_link.

Money is integer kobo

amount_in_kobo (the validation charge) is integer kobo (₦1.00 = 100).

Example

{:ok, setup} =
  Nombaone.PaymentMethods.setup(client, %{
    customer_ref: customer.id,
    amount_in_kobo: 5_000,
    callback_url: "https://example.com/billing/return"
  })

setup!(client, params, opts \\ [])

Raising variant of setup/3.