Urgent.News

What's breaking now, across thousands of outlets.

Tech

Accept crypto payments in Express

A Moonvex integration for an Express app with no extra dependencies: the built-in fetch creates payments, node:crypto verifies webhook signatures, and a PostgreSQL transaction marks each order paid exactly once. Step by step 1. Get an API key and a webhook secret In the Moonvex dashboard go to “Integration” → “Create key” → type “Secret” (sk_live_…). The key is shown only once: store it on your…

To incorporate crypto payments in an Express app, follow these steps:

1. Obtain an API key and webhook secret from the Moonvex dashboard. Store the key and webhook secret as `MOONVEX_SECRET_KEY` and `MOONVEX_WEBHOOK_SECRET` respectively in a `.env` file.

2. Install the required dependencies using `npm install express pg`. Create a `.env` file to store server-specific secrets such as `MOONVEX_SECRET_KEY`, `MOONVEX_WEBHOOK_SECRET`, and `DATABASE_URL`.

3. Set up the server with Express by importing necessary modules and creating an instance of Express. Define an asynchronous function `createPayment` to send a POST request to Moonvex API with required headers and payload. Handle errors and return the payment object if successful.

4. Define the Express route for `/orders/:id/pay` to handle payment requests. Retrieve the order details from the database using the `orderId` parameter. If the order exists, call the `createPayment` function to generate a payment and redirect the customer to the `paymentUrl` provided by Moonvex.

5. Implement a webhook endpoint to process incoming Moonvex webhooks. Verify the signature of the webhook using the provided secret and compare it with the received signature in constant time. Ensure the webhook event is received within the last 5 minutes. If valid, mark the order as paid in the database using a function like `markOrderPaidOnce`.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

This story

This is one outlet's version. Read the fullest account.

Read the original at dev.to →

More in Tech

MCP Is a Great Start — But Multi-Agent Production Needs More

The Model Context Protocol has transformed how we connect AI to tools. But connecting agents to tools is only half the battle — connecting agents to each other is where the real challenge begins.

  • MCP revolutionizes AI tool connection but fails in multi-agent coordination
  • State coordination issue: simultaneous writes overwrite each other's work
  • Network-AI solves coordination with atomic state updates and audit trail

More from Thursday 12 November →