Accept cryptocurrency payments (USDT, USDC, DAI) on BSC and Ethereum chains with ease using the official RazCrypto Python SDK.
pip install razcrypto
Quick Start
1. Initialize the Client
Python
from razcrypto import Client
client = Client("YOUR_GATEWAY_ID", "YOUR_SECRET_KEY")
2. Create a Payment
Python
try:
payment = client.payment.create({
"amount": 10.50,
"currency": "USDT",
"chain": "BSC",
"email": "customer@example.com",
"callback_url": "[https://yourwebsite.com/webhook](https://yourwebsite.com/webhook)",
"custom_data": {
"order_id": "ORD-12345"
}
})
print("Checkout URL:", payment.get("checkout_page"))
# Redirect your user to this URL
except Exception as e:
print("Error:", str(e))
3. Verify Webhook (Flask Example)
Always verify the webhook signature to ensure security.
Python
from flask import Flask, request, jsonify
from razcrypto import Webhook
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def webhook():
signature = request.headers.get('X-RazCrypto-Signature', '')
raw_payload = request.get_data() # Ensure this is raw bytes
secret_key = "YOUR_SECRET_KEY"
if Webhook.verify_signature(raw_payload, signature, secret_key):
data = request.json
if data.get('event') == 'payment.completed':
order_id = data['custom_data'].get('order_id')
# TODO: Mark order as paid in database
return jsonify({"status": "ok"}), 200
else:
return jsonify({"error": "Invalid Signature"}), 401