npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-coinbase-commerce

v0.3.3

Published

Node Coinbase Commerce API client

Downloads

42

Readme

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: "[email protected]", // 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,
);