# Payment Orchestrator JS SDK

This package provides a modern ESM + TypeScript module that you can install directly into React, Next.js, Vite, or any other bundler stack.

## Installation

```bash
npm install @usmanayub/orchestrator-sdk
# or
yarn add @usmanayub/orchestrator-sdk
```

## Usage

```ts
import { Orchestrator } from '@usmanayub/orchestrator-sdk';

const orchestrator = new Orchestrator({
  publicKey: 'pk_test_123',
  apiBaseUrl: 'https://pay.atheronlabs.com'
});

async function handleCheckout() {
  // 1) Create a payment session
  const session = await orchestrator.createPaymentSession({
    amount: 1099, // equals $10.99 
    currency: 'USD',
    customerId: 'cust_123',
    reference: 'ORDER-1001',
    metadata: { cartId: 'cart_abc' }
  });

  // 2) Mount the provider-agnostic card form
  await orchestrator.mountCardForm('#card-element');

  // 3) Confirm the payment (tokenizes + POSTs to /api/payments/confirm)
  const result = await orchestrator.confirmPayment();
  console.log('Payment result:', result);
}
```

### Security Notes

- `publicKey` identifies the merchant’s storefront and is safe to embed in the browser.

### Compatibility

- ESM-only package (`"type": "module"`). Works out of the box with Vite, Next.js, Remix, Create React App (>=5), Angular, SvelteKit, etc.
- Ships TypeScript declarations (`dist/index.d.ts`) so editors and TS builds get full IntelliSense.
- No default export; use the named export `Orchestrator`.

## Development

```bash
npm install
```
