Skip to main content

Crate bachs_sdk

Crate bachs_sdk 

Source
Expand description

Unofficial Rust SDK for the Bachs API — payments and billing for internet businesses.

This is a community client, not published or endorsed by Bachs.

§Quickstart

use bachs_sdk::{Bachs, customers::CreateCustomerRequest};

// Reads a sandbox (sk_sandbox_...) or live (sk_live_...) key and infers
// the right base URL from the prefix.
let bachs = Bachs::new(std::env::var("BACHS_API_KEY").unwrap())?;

let customer = bachs
    .customers()
    .create(&CreateCustomerRequest::new("jane@example.com").name("Jane Doe"))
    .await?;

println!("created {}", customer.customer_id);

§Conventions carried over from the API

  • Money is always a decimal string at the currency’s precision (e.g. "29.00"), paired with an ISO 4217 currency code — never minor units.
  • Sandbox vs. production are different hosts entirely (sandbox-api.bachs.io / api.bachs.io) with different key prefixes (sk_sandbox_... / sk_live_...). Bachs::new infers which one you mean from the key; going live is a key swap.
  • Webhooks are the source of truth for fulfilment — see the webhooks module — not client-side checkout redirects.
  • Subscriptions are created by completing a checkout session against a recurring product. There’s no direct create-subscription call.
  • Resource IDs carry type prefixes (cust_, prod_, sub_, chk_, inv_, ref_, …).

§A note on coverage

This SDK is built from Bachs’ public documentation, not an internal schema dump. The customers and checkout_sessions resources follow a fully-specified OpenAPI schema and are typed strictly. Several other resources (subscriptions, payments, refunds, transfers, connected accounts, …) are typed against the fields the docs and examples confirm, with an extra: FlexObject catch-all on each response so additional fields your API version returns are preserved rather than causing a deserialization error. If you hit a mismatch, please open an issue.

Re-exports§

pub use client::Bachs;
pub use client::BachsBuilder;
pub use client::Environment;
pub use client::RequestOptions;
pub use common::Address;
pub use common::ListParams;
pub use common::ListResponse;
pub use common::Metadata;
pub use common::Money;
pub use common::Pagination;
pub use common::Timestamp;
pub use error::ApiErrorBody;
pub use error::BachsError;
pub use error::BachsResult;
pub use error::FieldError;
pub use resources::accounts;
pub use resources::checkout_sessions;
pub use resources::connected_accounts;
pub use resources::customer_sessions;
pub use resources::customers;
pub use resources::media;
pub use resources::payment_rails;
pub use resources::payments;
pub use resources::products;
pub use resources::refunds;
pub use resources::subscriptions;
pub use resources::transfers;

Modules§

client
common
error
resources
webhooks
Webhook signature verification.