createCheckout
Decodes and accepts one provider-neutral checkout creation command.
Acceptance retains the selected commercial terms and idempotency identity before provider creation. Retrying the same command returns the original creation receipt; reusing its idempotency key for different material fails.
Declaration
Section titled “Declaration”const createCheckout: SapaOperation<CheckoutCreateResult, CheckoutCreateError>;input
Untrusted input decoded with CheckoutCommand.
Returns
Section titled “Returns”An Effect yielding CheckoutCreateResult, or a sanitized CheckoutCreateError in the error channel.
Example
Section titled “Example”import { createCheckout } from "@byfungsi/sapa";
const checkout = yield* createCheckout({ type: "offer", offerKey: "team.monthly", offerRevision: 1, quantity: null, provider: "midtrans", customer: { externalId: "customer-42", email: "customer@example.com", name: "Example Customer", }, successUrl: "https://example.com/billing/success", cancelUrl: "https://example.com/billing/canceled", clientIp: null, idempotencyKey: "checkout-customer-42-team-monthly",});