Open nodirbekrajaboff opened 1 year ago
No matter how many times I try, I get the same error. I also added the API address and webhook secret API. But every time the webhook is called, the same error occurs.
import { Router } from "express"; import coinbase from "coinbase-commerce-node"; const router = Router(); const client = coinbase.Client; const resources = coinbase.resources; const webhook = coinbase.Webhook; client.init(process.env.COINBASE_API_KEY as string); router.post("/coinbase/checkout", async (req, res) => { const { amount, currency } = req.body; try { const charge = await resources.Charge.create({ name: "Test", description: "Test", pricing_type: "fixed_price", local_price: { amount, currency }, metadata: { customer_id: "123456789", }, }); res.json({ charge }); } catch (err) { res.status(500).json({ error: err, }); } }); router.post("/coinbase/webhook", (req, res) => { try { const rawBody = req.rawBody; const signature = req.headers["x-cc-webhook-signature"] as string; const webhookSecret = process.env.COINBASE_WEBHOOK_SECRET as string; const event = webhook.verifyEventBody(rawBody, signature, webhookSecret); res.send(event.id); } catch (err) { console.log(err); res.status(400).send("failed"); } }); export default router;
SignatureVerificationError: No signatures found matching the expected signature 1a5db1b818054c2ff092855e432e133d4e35da54d3e7a8931ae181eb35f7269a for payload {"attempt_number":1,"event":{"api_version":"2018-03-22","created_at":"2023-08-13T18:52:49Z","data":{"id":"58b3fd8b-dcd8-4da8-ad34-704722beebd0","code":"RF68JNYX","name":"Test","utxo":false,"pricing":{"local":{"amount":"1.00","currency":"USD"},"tether":{"amount":"1.000796","currency":"USDT"}},"fee_rate":0.01,"logo_url":"","metadata":{"customer_id":"123456789"},"payments":[],"resource":"charge","timeline":[{"time":"2023-08-13T18:52:49Z","status":"NEW"}],"addresses":{"tether":"0x583e89ba1b7e3478923dca71e3eb7ae14f945896"},"pwcb_only":false,"created_at":"2023-08-13T18:52:49Z","expires_at":"2023-08-13T19:52:49Z","hosted_url":"https://commerce.coinbase.com/charges/RF68JNYX","brand_color":"#122332","description":"Test","fees_settled":true,"pricing_type":"fixed_price","support_email":"xxxxxx@gmail.com","brand_logo_url":"","exchange_rates":{"USDT-USD":"0.999205"},"offchain_eligible":false,"organization_name":"XXXXXX","payment_threshold":{"overpayment_absolute_threshold":{"amount":"5.00","currency":"USD"},"overpayment_relative_threshold":"0.005","underpayment_absolute_threshold":{"amount":"5.00","currency":"USD"},"underpayment_relative_threshold":"0.005"},"local_exchange_rates":{"USDT-USD":"0.999205"},"coinbase_managed_merchant":false},"id":"09aafcd9-180b-4ae8-8ef3-dbe832d2d83a","resource":"event","type":"charge:created"},"id":"c65b10e9-764b-41b4-a62c-b58f3690d8a9","scheduled_for":"2023-08-13T18:52:49Z"} at Object.verifySigHeader (xxxxxx\node_modules\coinbase-commerce-node\lib\Webhook.js:36:10) at Object.verifyEventBody (xxxxxx\node_modules\coinbase-commerce-node\lib\Webhook.js:23:8) at xxxxxx\src\routes\coinbase.ts:36:27 at Layer.handle [as handle_request] (xxxxxx\node_modules\express\lib\router\layer.js:95:5) at next (xxxxxx\node_modules\express\lib\router\route.js:144:13) at Route.dispatch (xxxxxx\node_modules\express\lib\router\route.js:114:3) at Layer.handle [as handle_request] (xxxxxx\node_modules\express\lib\router\layer.js:95:5) at xxxxxx\node_modules\express\lib\router\index.js:284:15 at Function.process_params (xxxxxx\node_modules\express\lib\router\index.js:346:12) at next (xxxxxx\node_modules\express\lib\router\index.js:280:10)
Assign this to me. I was just working with webhooks and I was facing the same issue. I might be able to help you
No matter how many times I try, I get the same error. I also added the API address and webhook secret API. But every time the webhook is called, the same error occurs.
My Codes:
Error:
SignatureVerificationError: No signatures found matching the expected signature 1a5db1b818054c2ff092855e432e133d4e35da54d3e7a8931ae181eb35f7269a for payload {"attempt_number":1,"event":{"api_version":"2018-03-22","created_at":"2023-08-13T18:52:49Z","data":{"id":"58b3fd8b-dcd8-4da8-ad34-704722beebd0","code":"RF68JNYX","name":"Test","utxo":false,"pricing":{"local":{"amount":"1.00","currency":"USD"},"tether":{"amount":"1.000796","currency":"USDT"}},"fee_rate":0.01,"logo_url":"","metadata":{"customer_id":"123456789"},"payments":[],"resource":"charge","timeline":[{"time":"2023-08-13T18:52:49Z","status":"NEW"}],"addresses":{"tether":"0x583e89ba1b7e3478923dca71e3eb7ae14f945896"},"pwcb_only":false,"created_at":"2023-08-13T18:52:49Z","expires_at":"2023-08-13T19:52:49Z","hosted_url":"https://commerce.coinbase.com/charges/RF68JNYX","brand_color":"#122332","description":"Test","fees_settled":true,"pricing_type":"fixed_price","support_email":"xxxxxx@gmail.com","brand_logo_url":"","exchange_rates":{"USDT-USD":"0.999205"},"offchain_eligible":false,"organization_name":"XXXXXX","payment_threshold":{"overpayment_absolute_threshold":{"amount":"5.00","currency":"USD"},"overpayment_relative_threshold":"0.005","underpayment_absolute_threshold":{"amount":"5.00","currency":"USD"},"underpayment_relative_threshold":"0.005"},"local_exchange_rates":{"USDT-USD":"0.999205"},"coinbase_managed_merchant":false},"id":"09aafcd9-180b-4ae8-8ef3-dbe832d2d83a","resource":"event","type":"charge:created"},"id":"c65b10e9-764b-41b4-a62c-b58f3690d8a9","scheduled_for":"2023-08-13T18:52:49Z"} at Object.verifySigHeader (xxxxxx\node_modules\coinbase-commerce-node\lib\Webhook.js:36:10)
at Object.verifyEventBody (xxxxxx\node_modules\coinbase-commerce-node\lib\Webhook.js:23:8)
at xxxxxx\src\routes\coinbase.ts:36:27 at Layer.handle [as handle_request] (xxxxxx\node_modules\express\lib\router\layer.js:95:5)
at next (xxxxxx\node_modules\express\lib\router\route.js:144:13) at Route.dispatch (xxxxxx\node_modules\express\lib\router\route.js:114:3) at Layer.handle [as handle_request] (xxxxxx\node_modules\express\lib\router\layer.js:95:5)
at xxxxxx\node_modules\express\lib\router\index.js:284:15 at Function.process_params (xxxxxx\node_modules\express\lib\router\index.js:346:12) at next (xxxxxx\node_modules\express\lib\router\index.js:280:10)