Setup
- Environment variables
- Direct config
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:
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 ontoPayment. 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 callingpaykit.checkouts.create with a recurring-configured
product instead. Retrieve, update, and cancel work directly:
Refunds
ResourceNotFoundError.
Webhooks
Add a webhook endpoint from your Bachs Developer Portal and pass its signing secret towebhookSecret: