Migrating code from the Coinbase Commerce Charges API
Code written for the Coinbase Commerce Charges API cannot be patched, because Coinbase retired api.commerce.coinbase.com with the rest of Commerce on March 31, 2026. Moving that code to the CoinStack API comes down to 5 changes. POST /charges becomes POST /checkouts, the X-CC-Api-Key header becomes a Bearer key, the timeline array becomes one status field, charge:confirmed becomes checkout.completed, and the X-CC-Webhook-Signature check gains a timestamp.
What happened to the Charges API?
Coinbase set March 31, 2026 as the end date. Its help page said the Commerce portal would then "become permanently inaccessible" and that merchants would "no longer be able to create charges or access the Commerce dashboard."
The field names below come from the Commerce developer docs as they stood in July 2025, mainly the pages on creating a charge, webhook fields and payment status.
The client libraries are frozen too. The coinbase-commerce-node repository is archived, was last pushed on October 20, 2023, and opens with "Note: This repository is not actively maintained."
Coinbase's own successor is a rewrite as well. The same help page tells API merchants to use "JWT-based auth instead of your legacy Commerce API keys" with the Coinbase Business Payment Link API, and Coinbase's docs now ask those users to move again to the Checkouts API. Who can open a Coinbase Business account is covered in CoinStack vs Coinbase Business. This article maps the old calls to the CoinStack API. The non-code parts of a move, such as history and open invoices, are in how to migrate from Coinbase Commerce to CoinStack.
How do the two APIs line up?
| Coinbase Commerce Charges API | CoinStack API | |
|---|---|---|
| Base URL | https://api.commerce.coinbase.com | https://coinstack.net/api/v1 |
| Auth header | X-CC-Api-Key | Authorization: Bearer sk_... |
| Create | POST /charges | POST /checkouts |
| Amount | local_price.amount, local_price.currency, pricing_type | amount, currency |
| Text and labels | name, description | description, reference |
| Return links | redirect_url, cancel_url | success_url, cancel_url |
| Your own data | metadata | metadata, reference |
| Response wrapper | data | success, response.checkout |
| Identifier | id, code | checkout_id |
| Payment page | hosted_url | url |
| Read one | GET /charges/{id} | GET /checkouts/{checkout_id} |
| Status | Last entry of timeline | status |
| Paid event | charge:confirmed | checkout.completed |
| Signature header | X-CC-Webhook-Signature | CoinStack-Signature |
| Settlement | USDC | USDC on the network and at the address you choose |
Both products create a hosted payment page and settle in USDC, so the shape of an integration stays the same: create, redirect, wait for a signed webhook.
The create call, before and after
This is a typical Charges API request. The official clients, including Coinbase's WooCommerce plugin, also sent an X-CC-Version header and read the charge from a data wrapper.
// Before: Coinbase Commerce
const response = await fetch("https://api.commerce.coinbase.com/charges/", {
method: "POST",
headers: {
"X-CC-Api-Key": process.env.COINBASE_COMMERCE_API_KEY,
"X-CC-Version": "2018-03-22",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Order #1042",
description: "1 x Pro plan",
pricing_type: "fixed_price",
local_price: { amount: "25.00", currency: "USD" },
metadata: { order_id: "1042" },
redirect_url: "https://example.com/orders/1042/thanks",
cancel_url: "https://example.com/cart",
}),
});
const { data: charge } = await response.json();
// Store charge.id, then send the customer to charge.hosted_url.The same order as a CoinStack checkout, following the API reference:
// After: CoinStack
const response = await fetch("https://coinstack.net/api/v1/checkouts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COINSTACK_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: "25.00",
currency: "USD",
reference: "order-1042",
description: "1 x Pro plan",
metadata: { order_id: "1042" },
success_url: "https://example.com/orders/1042/thanks",
cancel_url: "https://example.com/cart",
}),
});
const body = await response.json();
if (!body.success) {
throw new Error(body.response);
}
const checkout = body.response.checkout;
// Store checkout.checkout_id, then send the customer to checkout.url.The differences that tend to break a port:
- The amount is flat.
amountis a string andcurrencyis one of 146 supported codes, andpricing_typeis dropped. Every checkout has a fixed amount worth between 1 and 1,000,000 US dollars, and for an oldno_pricecharge, where the customer chose the amount, your server creates a checkout for the amount the customer enters on your site. namehas no counterpart. Put customer-facing text indescription, which is shown on the checkout page and can be up to 1,000 characters. Put your order number inreference, up to 200 characters, and you can find the checkout later withGET /checkouts?reference=order-1042.- Metadata values must be strings. You can send up to 50 pairs, with keys up to 40 characters and values up to 500. A number such as
order_id: 1042is rejected. - Return links are links. A Commerce charge carried a
will_redirect_after_successfield. A CoinStack checkout showssuccess_urlas a Return to merchant button once it is completed, andcancel_urlbefore payment and after expiry. Either URL can carry{CHECKOUT_ID}, which is swapped for the checkout's ID. - Expiry is yours to set. The sample charge in Coinbase's docs expired 2 days after it was created. A checkout stays open for 24 hours unless you send
expires_at, which can be 10 minutes to 365 days ahead. - A retry creates a second checkout. If a create request times out, list checkouts by the
referenceyou sent before trying again.
How do charge statuses map to checkout statuses?
A charge kept its history in a timeline array, and the last entry was the current state. A checkout has one status field and 3 flags.
// Before
const paid = charge.timeline.at(-1).status === "COMPLETED";
// After
const paid = checkout.status === "completed" || checkout.status === "resolved";| Charge status | Checkout status | Note |
|---|---|---|
NEW | pending | Nothing has been paid |
SIGNED | None | Customers send to an address, so there is no wallet signature step |
PENDING | confirming | The meaning differs, as explained below |
COMPLETED | completed | Fulfill the order here |
EXPIRED | expired | Check the underpaid flag |
FAILED | None | A payment that cannot be processed is returned to the sender |
| None | partial | Less than the full amount arrived and the checkout is still open |
| None | resolved | You accepted an underpaid checkout. Treat it as paid |
Two of these rows change behavior.
Coinbase defined PENDING as "Transaction detected on the blockchain and funds are received in the merchant wallet", and its payment status page said "merchants can choose to deliver goods when orders are PENDING." CoinStack's confirming is earlier than that. It means a payment was detected and is being processed, and the USDC has not reached your wallet yet. The checkouts guide says to fulfill an order when its checkout is completed. If your handler shipped on the pending event, move that logic to the completed one.
The other change is how amounts are handled. Coinbase's FAQ said "charges cannot be underpaid or overpaid." With CoinStack the customer sends from their own wallet or exchange, so the API reports each case with a clear status or flag:
- A shortfall inside your allowance (0.5% of the total by default) still completes the checkout, with
underpaidset totrueif it was short by a cent or more. - A larger shortfall gives
partial. The customer can send the rest to the same address. - A checkout that expires partly paid becomes
expiredwithunderpaidset totrue, and the USDC from the part payment is already in your wallet. Accept it withPOST /checkouts/{checkout_id}/resolveor refund it from your own wallet. - A payment more than 2% over sets
overpaid. A payment that completes the checkout afterexpires_atsetslate, so decide what happens when a completed event arrives for an order you already cancelled.
Each case is explained in checkout and payment statuses, explained and in underpaid crypto payments.
Which webhook events replace charge:confirmed and the rest?
| Commerce event | CoinStack event |
|---|---|
charge:created | None. The create response is your record |
charge:pending | checkout.confirming |
charge:confirmed | checkout.completed |
charge:failed | checkout.expired, or payment.refunded when a payment is returned |
| None | checkout.partial, checkout.resolved, payment.pending, payment.completed |
The body is flatter than the Commerce one, which nested the charge under event.data inside a delivery wrapper.
| What you read | Commerce | CoinStack |
|---|---|---|
| Event type | event.type | kind |
| Event ID | event.id | event_id |
| The object | event.data | data.checkout |
| Your order ID | event.data.metadata.order_id | data.checkout.reference or data.checkout.metadata.order_id |
| Current status | Last entry of event.data.timeline | data.checkout.status |
Delivery rules differ as well. Commerce asked for a 200 response and, per its webhooks page, would "retry with an exponential backoff for up to three days." CoinStack accepts any 2xx within 10 seconds and retries after 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 8 hours and 8 hours. After the last attempt you can resend any event from the dashboard or with POST /events/{event_id}/resend.
If your endpoint is down for longer than a day, resend the missed events from the dashboard, and add a job that lists recent checkouts and compares them with your orders so nothing slips through. The same event_id is sent on every retry, which makes duplicates easy to skip. Both habits are described in reliable payment webhooks.
You register the endpoint under Developers in the dashboard or with POST /webhooks. The signing secret starts with whsec_ and is shown once.
Signature verification, before and after
Commerce put a hex HMAC-SHA256 of the raw request body in X-CC-Webhook-Signature, keyed with your webhook shared secret. This is what the archived Node library computed:
import crypto from "node:crypto";
// Before: X-CC-Webhook-Signature
function verifyCommerce(rawBody, signature, sharedSecret) {
const expected = Buffer.from(
crypto.createHmac("sha256", sharedSecret).update(rawBody, "utf8").digest("hex"),
);
const given = Buffer.from(String(signature));
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
}CoinStack also uses HMAC-SHA256, with 3 differences. The header carries a timestamp and a signature, as in CoinStack-Signature: t=1796228678,v1=0e64.... The signed string is the timestamp, a period and the raw body. And a request whose timestamp is more than five minutes old should be rejected.
import crypto from "node:crypto";
import express from "express";
const app = express();
const secret = process.env.COINSTACK_WEBHOOK_SECRET;
// After: CoinStack-Signature
function verifyCoinStack(rawBody, header) {
const parts = Object.fromEntries(
String(header).split(",").map((part) => part.split("=")),
);
const expected = Buffer.from(
crypto.createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex"),
);
const given = Buffer.from(String(parts.v1));
return (
given.length === expected.length &&
crypto.timingSafeEqual(given, expected) &&
Math.abs(Date.now() / 1000 - Number(parts.t)) <= 300
);
}
app.post(
"/webhooks/coinstack",
express.raw({ type: "application/json" }),
(request, response) => {
const body = request.body.toString("utf8");
if (!verifyCoinStack(body, request.get("CoinStack-Signature"))) {
return response.status(400).send("Invalid signature");
}
const event = JSON.parse(body);
if (event.kind === "checkout.completed") {
// Mark the order for event.data.checkout.checkout_id as paid.
// Skip any event.event_id you have already handled.
}
response.sendStatus(200);
},
);
app.listen(3000);The secret is the whole string, including the whsec_ prefix. As before, verify against the body exactly as it arrived, because JSON that has been parsed and written out again may not match byte for byte. Python and PHP versions are in the webhooks guide, and the reasoning behind each step is in how to verify payment webhooks.
What else changes in day-to-day work?
- Calls from your code. Every request is plain HTTPS with a Bearer key and a JSON body, so the built-in
fetchin Node.js is enough, as in the examples above. The docs give samples in cURL, Node.js, Python and PHP, and publish an OpenAPI 3.1 file you can feed to a client generator if you want typed methods. - Your records of a checkout. Nothing is sent when you create one, so store
checkout_idfrom the create response before you redirect the customer. - Money movement. Withdrawals are made from the dashboard and refunds are sent from your own wallet, so neither needs code in your integration.
You also gain payment methods the old integration never offered. Coinbase's FAQ listed "Eth Mainnet, Polygon, or Base" and said Bitcoin from self-custodial wallets or other exchanges was not supported. A CoinStack checkout accepts 10 tokens on 11 networks, including BTC and USDT on TRON, with no change to your code.
A cutover order that does not drop payments
- Create an API key with Read and write access under Developers in the dashboard, and keep it on your server.
- Add a
checkout_idcolumn beside the one that held the chargeidorcode. Keep the old values. Coinbase said Commerce history would not transfer to Coinbase Business, and the portal that held it is closed. - Swap the create call and redirect to
url. - Add the webhook route at a new path, subscribe to
checkout.completedandcheckout.expired, and press Send test. - Add the branches for
partial,resolvedand thelateflag, even if they only raise an alert at first. - Pay one real checkout of a few dollars from start to finish, following how to test a crypto checkout before launch.
- Delete the old webhook route, the shared secret and the Commerce API key from your configuration. Nothing will call them again.
If your Commerce integration was the WooCommerce plugin and not your own code, skip all of this and read replacing the Coinbase Commerce WooCommerce plugin. For custom code, the quickstart covers the same flow in 4 steps.
Frequently asked questions
Is the Coinbase Commerce API still working?
No. Coinbase said charges could not be created after March 31, 2026, and that the Commerce portal would "become permanently inaccessible" from that date. Code that still calls api.commerce.coinbase.com cannot be repaired with a config change or a library update. The only fix is to replace the integration, which on CoinStack means the 5 changes described above.
What replaces the charge:confirmed webhook?
checkout.completed. It is sent when a checkout has been paid in full, and its body carries the checkout under data.checkout with status set to completed. Verify the CoinStack-Signature header, match checkout_id or reference to your order, and fulfill it. If you accept underpaid checkouts by resolving them, treat checkout.resolved as paid too.
Can I still fulfill orders on the pending event?
Not safely. Coinbase's docs said a PENDING charge meant funds were received in the merchant wallet. CoinStack's checkout.confirming only means a payment was detected and is being processed. The checkout moves to completed once it is paid in full, usually seconds to a few minutes later depending on the network, and that is the event to act on.
How do I replace a Commerce charge where the customer chose the amount?
A Commerce no_price charge let the payer type any figure, while every CoinStack checkout is created for a fixed amount between 1 and 1,000,000 US dollars. Add an amount field to your donation or top-up form, validate it on your server, then call POST /checkouts with that amount and redirect to the returned url.
Do my old Commerce API keys work with Coinbase Business?
No. Coinbase's transition page told API merchants to create a new Coinbase Business API key and use "JWT-based auth instead of your legacy Commerce API keys". The endpoints, request schema and webhook names changed as well, and Coinbase has since asked Payment Link API users to move to its Checkouts API.