An open API service indexing awesome lists of open source software.

https://github.com/gwop-io/gwop-node

The Node SDK for Gwop Checkout
https://github.com/gwop-io/gwop-node

agentic-ai agentic-commerce-protocol agentic-workflow gwop payments

Last synced: 3 months ago
JSON representation

The Node SDK for Gwop Checkout

Awesome Lists containing this project

README

          

# gwop-checkout

Node SDK for [Gwop Checkout](https://gwop.io) — accept USDC payments from AI agents.

Docs: [docs.gwop.io](https://docs.gwop.io)

## Install

```bash
npm install gwop-checkout
```
```bash
yarn add gwop-checkout
```
```bash
pnpm add gwop-checkout
```

TypeScript types included. Zero runtime dependencies. Node 18+.

## Quick example

```ts
import { GwopCheckout } from 'gwop-checkout';

const gwop = new GwopCheckout({
merchantApiKey: process.env.GWOP_CHECKOUT_API_KEY, // sk_m_...
});

// Create an invoice
const invoice = await gwop.invoices.create(
{
amount_usdc: 5_000_000, // $5.00 USDC
description: 'Pro plan — 1 month',
},
{ idempotencyKey: 'order_abc_v1' },
);

console.log(invoice.id); // 'inv_...'
console.log(invoice.status); // 'OPEN'
```

## Webhooks

Verify signatures and dispatch events when invoices are paid:

```ts
const event = gwop.webhooks.constructEvent(
rawBody, // raw request body
req.header('x-gwop-signature'), // signature header
process.env.GWOP_WEBHOOK_SECRET!, // whsec_...
);

await gwop.webhooks.dispatch(event, {
invoicePaid: async (evt) => {
console.log(`Paid: ${evt.data.invoice_id} on ${evt.data.payment_chain}`);
// Fulfill the order.
},
});
```

## API

| Method | Description |
|--------|-------------|
| `gwop.invoices.create(body, options?)` | Create a USDC invoice |
| `gwop.invoices.retrieve(id)` | Get invoice status (public, no auth) |
| `gwop.invoices.list(params?)` | List your invoices |
| `gwop.invoices.cancel(id)` | Cancel an open invoice |
| `gwop.invoices.waitForStatus(id, status, options?)` | Poll until status reached |
| `gwop.webhooks.constructEvent(payload, sig, secret)` | Verify webhook signature |
| `gwop.webhooks.dispatch(event, handlers)` | Route event to typed handlers |

## Links

- [Documentation](https://docs.gwop.io)
- [Merchant Dashboard](https://merchant.gwop.io)
- [Example server](./examples/merchant-basic)
- [npm](https://www.npmjs.com/package/gwop-checkout)

## License

[MIT](./LICENSE)