razcrypto 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- razcrypto-1.0.0/PKG-INFO +18 -0
- razcrypto-1.0.0/README.md +54 -0
- razcrypto-1.0.0/razcrypto/__init__.py +4 -0
- razcrypto-1.0.0/razcrypto/client.py +32 -0
- razcrypto-1.0.0/razcrypto/resources/__init__.py +0 -0
- razcrypto-1.0.0/razcrypto/resources/payment.py +13 -0
- razcrypto-1.0.0/razcrypto/webhook.py +19 -0
- razcrypto-1.0.0/razcrypto.egg-info/PKG-INFO +18 -0
- razcrypto-1.0.0/razcrypto.egg-info/SOURCES.txt +12 -0
- razcrypto-1.0.0/razcrypto.egg-info/dependency_links.txt +1 -0
- razcrypto-1.0.0/razcrypto.egg-info/requires.txt +1 -0
- razcrypto-1.0.0/razcrypto.egg-info/top_level.txt +1 -0
- razcrypto-1.0.0/setup.cfg +4 -0
- razcrypto-1.0.0/setup.py +16 -0
razcrypto-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: razcrypto
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: RazCrypto Payment Gateway Python SDK
|
|
5
|
+
Author: RazCrypto
|
|
6
|
+
Keywords: razcrypto,payment,gateway,crypto,usdt
|
|
7
|
+
Requires-Python: >=3.6
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: requests
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: description
|
|
12
|
+
Dynamic: description-content-type
|
|
13
|
+
Dynamic: keywords
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
Accept cryptocurrency payments (USDT, USDC, DAI) on BSC and Ethereum chains with ease using the official RazCrypto Python SDK.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# RazCrypto Python SDK
|
|
2
|
+
|
|
3
|
+
Accept cryptocurrency payments (USDT, USDC, DAI) on BSC and Ethereum chains with ease using the official RazCrypto Python SDK.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install razcrypto
|
|
9
|
+
Quick Start
|
|
10
|
+
1. Initialize the Client
|
|
11
|
+
Python
|
|
12
|
+
from razcrypto import Client
|
|
13
|
+
|
|
14
|
+
client = Client("YOUR_GATEWAY_ID", "YOUR_SECRET_KEY")
|
|
15
|
+
2. Create a Payment
|
|
16
|
+
Python
|
|
17
|
+
try:
|
|
18
|
+
payment = client.payment.create({
|
|
19
|
+
"amount": 10.50,
|
|
20
|
+
"currency": "USDT",
|
|
21
|
+
"chain": "BSC",
|
|
22
|
+
"email": "customer@example.com",
|
|
23
|
+
"callback_url": "[https://yourwebsite.com/webhook](https://yourwebsite.com/webhook)",
|
|
24
|
+
"custom_data": {
|
|
25
|
+
"order_id": "ORD-12345"
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
print("Checkout URL:", payment.get("checkout_page"))
|
|
29
|
+
# Redirect your user to this URL
|
|
30
|
+
except Exception as e:
|
|
31
|
+
print("Error:", str(e))
|
|
32
|
+
3. Verify Webhook (Flask Example)
|
|
33
|
+
Always verify the webhook signature to ensure security.
|
|
34
|
+
|
|
35
|
+
Python
|
|
36
|
+
from flask import Flask, request, jsonify
|
|
37
|
+
from razcrypto import Webhook
|
|
38
|
+
|
|
39
|
+
app = Flask(__name__)
|
|
40
|
+
|
|
41
|
+
@app.route('/webhook', methods=['POST'])
|
|
42
|
+
def webhook():
|
|
43
|
+
signature = request.headers.get('X-RazCrypto-Signature', '')
|
|
44
|
+
raw_payload = request.get_data() # Ensure this is raw bytes
|
|
45
|
+
secret_key = "YOUR_SECRET_KEY"
|
|
46
|
+
|
|
47
|
+
if Webhook.verify_signature(raw_payload, signature, secret_key):
|
|
48
|
+
data = request.json
|
|
49
|
+
if data.get('event') == 'payment.completed':
|
|
50
|
+
order_id = data['custom_data'].get('order_id')
|
|
51
|
+
# TODO: Mark order as paid in database
|
|
52
|
+
return jsonify({"status": "ok"}), 200
|
|
53
|
+
else:
|
|
54
|
+
return jsonify({"error": "Invalid Signature"}), 401
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from .resources.payment import Payment
|
|
3
|
+
|
|
4
|
+
class Client:
|
|
5
|
+
def __init__(self, gateway_id, secret_key):
|
|
6
|
+
if not gateway_id or not secret_key:
|
|
7
|
+
raise ValueError("Gateway ID and Secret Key are required.")
|
|
8
|
+
self.gateway_id = gateway_id
|
|
9
|
+
self.secret_key = secret_key
|
|
10
|
+
self.base_url = "https://razcryptogateway.com/api/v2"
|
|
11
|
+
self.payment = Payment(self)
|
|
12
|
+
|
|
13
|
+
def request(self, method, path, data=None):
|
|
14
|
+
url = path if path.startswith("http") else f"{self.base_url}{path}"
|
|
15
|
+
headers = {
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
"Accept": "application/json",
|
|
18
|
+
"X-Gateway-Id": self.gateway_id,
|
|
19
|
+
"X-Secret-Key": self.secret_key
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
response = requests.request(method, url, json=data, headers=headers)
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
result = response.json()
|
|
26
|
+
except Exception:
|
|
27
|
+
raise Exception(f"Invalid JSON Response: {response.text}")
|
|
28
|
+
|
|
29
|
+
if response.status_code >= 400:
|
|
30
|
+
raise Exception(result.get("message", f"API Error: HTTP {response.status_code}"))
|
|
31
|
+
|
|
32
|
+
return result
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class Payment:
|
|
2
|
+
def __init__(self, client):
|
|
3
|
+
self.client = client
|
|
4
|
+
|
|
5
|
+
def create(self, params):
|
|
6
|
+
return self.client.request("POST", "/payments/create", params)
|
|
7
|
+
|
|
8
|
+
def fetch(self, payment_id):
|
|
9
|
+
full_url = f"https://razcryptogateway.com/api/v1/payments/status/{payment_id}"
|
|
10
|
+
return self.client.request("GET", full_url)
|
|
11
|
+
|
|
12
|
+
def webhook_status(self, payment_id, auth_key):
|
|
13
|
+
return self.client.request("GET", f"/webhooks/{payment_id}/status?auth_key={auth_key}")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import hmac
|
|
2
|
+
import hashlib
|
|
3
|
+
|
|
4
|
+
class Webhook:
|
|
5
|
+
@staticmethod
|
|
6
|
+
def verify_signature(raw_payload, signature, secret_key):
|
|
7
|
+
if isinstance(raw_payload, str):
|
|
8
|
+
raw_payload = raw_payload.encode('utf-8')
|
|
9
|
+
if isinstance(secret_key, str):
|
|
10
|
+
secret_key = secret_key.encode('utf-8')
|
|
11
|
+
|
|
12
|
+
expected_signature = hmac.new(
|
|
13
|
+
secret_key,
|
|
14
|
+
raw_payload,
|
|
15
|
+
hashlib.sha256
|
|
16
|
+
).hexdigest()
|
|
17
|
+
|
|
18
|
+
# Timing attack से बचने के लिए compare_digest का यूज़
|
|
19
|
+
return hmac.compare_digest(expected_signature, signature)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: razcrypto
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: RazCrypto Payment Gateway Python SDK
|
|
5
|
+
Author: RazCrypto
|
|
6
|
+
Keywords: razcrypto,payment,gateway,crypto,usdt
|
|
7
|
+
Requires-Python: >=3.6
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Requires-Dist: requests
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: description
|
|
12
|
+
Dynamic: description-content-type
|
|
13
|
+
Dynamic: keywords
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: requires-python
|
|
16
|
+
Dynamic: summary
|
|
17
|
+
|
|
18
|
+
Accept cryptocurrency payments (USDT, USDC, DAI) on BSC and Ethereum chains with ease using the official RazCrypto Python SDK.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
razcrypto/__init__.py
|
|
4
|
+
razcrypto/client.py
|
|
5
|
+
razcrypto/webhook.py
|
|
6
|
+
razcrypto.egg-info/PKG-INFO
|
|
7
|
+
razcrypto.egg-info/SOURCES.txt
|
|
8
|
+
razcrypto.egg-info/dependency_links.txt
|
|
9
|
+
razcrypto.egg-info/requires.txt
|
|
10
|
+
razcrypto.egg-info/top_level.txt
|
|
11
|
+
razcrypto/resources/__init__.py
|
|
12
|
+
razcrypto/resources/payment.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
razcrypto
|
razcrypto-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
setup(
|
|
4
|
+
name='razcrypto',
|
|
5
|
+
version='1.0.0',
|
|
6
|
+
description='RazCrypto Payment Gateway Python SDK',
|
|
7
|
+
long_description="Accept cryptocurrency payments (USDT, USDC, DAI) on BSC and Ethereum chains with ease using the official RazCrypto Python SDK.",
|
|
8
|
+
long_description_content_type='text/markdown',
|
|
9
|
+
author='RazCrypto',
|
|
10
|
+
packages=find_packages(),
|
|
11
|
+
install_requires=[
|
|
12
|
+
'requests'
|
|
13
|
+
],
|
|
14
|
+
keywords=['razcrypto', 'payment', 'gateway', 'crypto', 'usdt'],
|
|
15
|
+
python_requires='>=3.6',
|
|
16
|
+
)
|