🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

node-coinbase-commerce

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-coinbase-commerce

Node Coinbase Commerce API client

0.3.3
latest
npm
Version published
Weekly downloads
2
-91.3%
Maintainers
1
Weekly downloads
 
Created
Source

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,
);

Keywords

coinbase

FAQs

Package last updated on 07 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts