Skip to main content

RazCrypto Gateway — Python SDK

Official Python client for RazCrypto Gateway, the non-custodial crypto payment gateway.

  • PyPI: razcrypto (import name razcrypto)
  • Requires: Python ≥ 3.9
  • Dependencies: standard library only
  • Types: typed (py.typed)
  • License: MIT
pip install razcrypto

Upgrading

This major version is the SDK for the new RazCrypto Gateway: initialise with only your secret key (Dashboard → API apps) and use the new /v1 API. Pin the previous major version only if you still use the old gateway.

Create a payment

import os
from razcrypto import RazCrypto

rc = RazCrypto(os.environ["RAZCRYPTO_SECRET_KEY"])  # sk_test_… or sk_live_…

payment = rc.payments.create(
    amount="49.00",
    currency="USD",
    reference_id=order.id,
    redirect_url="https://shop.example/thanks",
    idempotency_key=order.id,  # safe to retry
)
return redirect(payment["checkout_url"])

API

Area Methods
Payments rc.payments.create(**params, idempotency_key=…), retrieve(id), list(**params), auto_paging_iter(**params), methods(id), quote(id, chain, coin), cancel(id), simulate(id, outcome) (test mode)
Payment links rc.payment_links.create(...), retrieve, list, update, deactivate
Others rc.chains(), rc.rates(["USDT", "BNB"], "USD"), rc.merchant(), rc.event(id)

Errors:

  • API errors raise razcrypto.ApiError with status, code, param and request_id.
  • Network problems raise razcrypto.ConnectionError_.
  • The client retries network errors, 429 and 5xx.

Options: RazCrypto(key, timeout=30.0, max_retries=2). The client talks to https://razcryptogateway.com by default; api_base (or env RAZCRYPTO_API_BASE) is only for staging or a self-hosted gateway.

Verify webhooks (Standard Webhooks)

from flask import Flask, request
from razcrypto import webhooks, SignatureVerificationError

@app.post("/webhooks/razcrypto")
def razcrypto_webhook():
    try:
        event = webhooks.verify(request.get_data(), request.headers, os.environ["RAZCRYPTO_WEBHOOK_SECRET"])  # whsec_…
    except SignatureVerificationError:
        return "", 400
    if event["type"] == "payment.paid":
        mark_order_paid(event["data"]["reference_id"])
    return "", 200

Django: webhooks.verify(request.body, request.headers, secret).

Verify the checkout signature

from razcrypto import is_valid_checkout_signature

# Redirect query: ?payment_id=…&reference_id=…&status=…&signature=…
if not is_valid_checkout_signature(request.args, os.environ["RAZCRYPTO_WEBHOOK_SECRET"]):
    ...  # do not trust it — wait for the webhook

Test mode

  • Use sk_test_… keys.
  • rc.payments.simulate(payment_id, "paid") runs the full flow, webhooks included.

Tests: python -m unittest discover -s tests. They also run the shared vectors in ../test-vectors.json.

Metadata

Release files for razcrypto 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for razcrypto 2.0.0
File Size Uploaded Provenance Actions
razcrypto-2.0.0.tar.gz 10.1 kB Without provenance Details for razcrypto-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for razcrypto 2.0.0
File Interpreter ABI Platform Actions
razcrypto-2.0.0-py3-none-any.whl Python 3 none any Details for razcrypto-2.0.0-py3-none-any.whl

Total release size: 19.6 kB

Release files / razcrypto-2.0.0.tar.gz

Download URL razcrypto-2.0.0.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ce96778b3886999a93e30e88ede852979031c98f3b6eec52c86c0ad15d7c72ad
BLAKE2b-256 checksum
How to use checksums
03f4a281979dc3e2e6e3984c52327964524f33299e88487a977ccbcb393d91c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / razcrypto-2.0.0-py3-none-any.whl

Download URL razcrypto-2.0.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b382c1699bc983c7bbeddbf1b8cf244fb2c723cada02985b8a819e1ce0c03bb0
BLAKE2b-256 checksum
How to use checksums
5e98dee39f89e75f9e7d724cc476da2ab2358f110e655537733c7fb7e222f017
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for razcrypto 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page