Menu

Accept crypto payments in Django
📰

Accept crypto payments in Django

DEV Community: django·Moonvex News·1 day ago
#OYre9rZN
#devtodjango#devto#dev#order#import
Reading 0:00
15s threshold

How to accept crypto in a Django project: a view creates a Moonvex checkout and sends the customer there to pick the coin and network, and a separate view receives the webhook, verifies the signature over request.body and marks the order paid 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 server as MOONVEX_SECRET_KEY. On the same page add a webhook pointing to an https URL on your server and store its signing secret as MOONVEX_WEBHOOK_SECRET. In Django keep them in settings, read from environment variables. A ProcessedEvent model keyed by event_id protects against double processing.

# settings.py import os

MOONVEX_SECRET_KEY = os . environ [ "MOONVEX_SECRET_KEY" ] # sk_live_... MOONVEX_WEBHOOK_SECRET = os . environ [ "MOONVEX_WEBHOOK_SECRET" ] # whsec_...

# shop/models.py from django . db import models

class Order ( models . Model ) : class Status ( models .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.