0.3.3 • Published 1 year ago

node-coinbase-commerce v0.3.3

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Node.js Typescript Coinbase Commerce API

npm version npm downloads last commit

Node.js connector for the Coinbase Commerce API with Typescript.

  • Simple and unopiniated connector.
  • Actively maintained with a modern, promise-driven interface.
  • Strongly typed on all requests and responses.
  • Lightweight package and snappy DX.
  • Proxy support via axios integration.
  • Client samples, webhook samples and code snippet examples

Installation

npm install node-coinbase-commerce

Examples

Refer to the examples folder for implementation demos.

Usage

Create an API client

import { CoinbaseCommerceClient } from "node-coinbase-commerce";

export const client = new CoinbaseCommerceClient(API_KEY);

Charges

const charges = await client.listCharges();
const checkout = await client.createCharge({
	name: "Product name",
	description: "Product description",
	pricing_type: "fixed_price",
	local_price: {
		amount: 100,
		currency: "USDT", // BTC, ETH, USDT
	},
	metadata: {
		customer_id: "Customer id",
		customer_name: "Customer name",
	},
	redirect_url: "http://example.com/redirect_url",
	cancel_url: "http://example.com/cancel_url",
});
const charge = await client.showCharge({
	charge_code_or_charge_id: "XXX",
});
const charge = await client.cancelCharge({
	charge_code_or_charge_id: "XXX",
});
const charge = await client.resolveCharge({
	charge_code_or_charge_id: "XXX",
});

Checkouts

const checkouts = await client.listCheckouts();
const checkout = await client.createCheckout({
	name: "Product name",
	description: "Product description",
	requested_info: ["name", "email", "address", "phone"],
	pricing_type: "fixed_price",
	local_price: {
		amount: 100,
		currency: "USDT", // BTC, ETH, USDT
	},
});
const checkout = await client.showCheckout({
	checkout_id: "XXX",
});
const checkout = await client.updateCheckout({
	checkout_id: "XXX",
	name: "Product name",
	description: "Product description",
	requested_info: ["name", "email", "address", "phone"],
	pricing_type: "fixed_price",
	local_price: {
		amount: 100,
		currency: "USDT", // BTC, ETH, USDT
	},
});
await client.deleteCheckout({
	checkout_id: "XXX",
});

Invoices

const invoices = await client.listInvoices();
const invoice = await client.createInvoice({
	business_name: "XXX",
	customer_email: "xxx@xxx.xxx", // has to be email
	customer_name: "XXX",
	memo: "XXX",
	local_price: {
		amount: 100,
		currency: "USDT", // BTC, ETH, USDT
	};
})
const invoice = await client.showInvoice({
	invoice_code_or_invoice_id: "XXX",
});
const invoice = await client.voidInvoice({
	invoice_code_or_invoice_id: "XXX",
});
const invoice = await client.resolveInvoice({
	invoice_code_or_invoice_id: "XXX",
});

Events

const events = await client.listEvents();
const invoice = await client.showEvent({
	event_id: "XXX", // uuidv4
});

Webhooks

Verify a webhook

const { isVerified, error, typedBody } = verifyWebhook(
	req.body,
	req.headers["x-cc-webhook-signature"],
	WEBHOOK_SHARED_SECRET,
);
0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.12

1 year ago

0.1.10

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago