Skip to main content
Bachs is a hosted-checkout-first payments and billing platform for African internet businesses selling globally (docs.bachs.io).

Setup

Required env vars:
The key’s prefix decides sandbox vs live, and overrides isSandbox if the two disagree.

Creating a checkout

Products (and their prices) live in your Bachs product catalog. item_id is a Bachs product_id. Bachs resolves the amount/currency from the product itself, so you don’t pass either:
If prod_abc123 has a billing_cycle configured on Bachs, completing this same checkout creates a subscription automatically. You’ll get both a payment.succeeded and a subscription.created webhook.

Creating a payment directly

Same underlying flow, mapped onto Payment. Needs success_url in provider_metadata since Bachs still redirects the customer even for a direct payment:
payment.id (and checkout.id) is Bachs’ checkout_id for the lifetime of the payment. Keep using this same checkout_id for paykit.payments.retrieve and paykit.refunds.create.

Safe retries

paykit.checkouts.create and paykit.payments.create each make two calls under the hood: create the session, then fetch it back to resolve pricing. If your own code might retry the whole call, pass a stable idempotencyKey (your own order ID works well) so a retry returns the original session instead of creating a duplicate:
paykit.refunds.create supports the same option.

Customers

Full support except delete, Bachs has no endpoint for it:

Subscriptions

Bachs has no direct way to create a subscription. Create one by calling paykit.checkouts.create with a recurring-configured product instead. Retrieve, update, and cancel work directly:

Refunds

The payment must have actually succeeded. Refunding a checkout that hasn’t been paid throws ResourceNotFoundError.

Webhooks

Add a webhook endpoint from your Bachs Developer Portal and pass its signing secret to webhookSecret:

Raw Bachs events

Opt into any native Bachs event type, typed against Bachs’ payload:
All available raw events and their PayKit mappings: