payra-sdk 1.2.3__py3-none-any.whl → 1.2.4__py3-none-any.whl
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.
- payra_sdk/utils.py +3 -3
- {payra_sdk-1.2.3.dist-info → payra_sdk-1.2.4.dist-info}/METADATA +41 -29
- {payra_sdk-1.2.3.dist-info → payra_sdk-1.2.4.dist-info}/RECORD +6 -6
- {payra_sdk-1.2.3.dist-info → payra_sdk-1.2.4.dist-info}/WHEEL +0 -0
- {payra_sdk-1.2.3.dist-info → payra_sdk-1.2.4.dist-info}/licenses/LICENSE +0 -0
- {payra_sdk-1.2.3.dist-info → payra_sdk-1.2.4.dist-info}/top_level.txt +0 -0
payra_sdk/utils.py
CHANGED
|
@@ -84,11 +84,11 @@ class PayraUtils:
|
|
|
84
84
|
Default cache time: 720 minutes (12 hours).
|
|
85
85
|
"""
|
|
86
86
|
|
|
87
|
-
api_key = os.getenv("
|
|
87
|
+
api_key = os.getenv("PAYRA_EXCHANGE_RATE_API_KEY")
|
|
88
88
|
if not api_key:
|
|
89
|
-
raise InvalidArgumentError("
|
|
89
|
+
raise InvalidArgumentError("PAYRA_EXCHANGE_RATE_API_KEY is not set in .env")
|
|
90
90
|
|
|
91
|
-
cache_minutes = int(os.getenv("
|
|
91
|
+
cache_minutes = int(os.getenv("PAYRA_EXCHANGE_RATE_CACHE_TIME", 720))
|
|
92
92
|
cache_ttl = cache_minutes * 60
|
|
93
93
|
|
|
94
94
|
api_url = f"https://v6.exchangerate-api.com/v6/{api_key}/latest/USD"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: payra_sdk
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.4
|
|
4
4
|
Summary: Python SDK for Payra payment signature generation (backend)
|
|
5
5
|
Author: Your Name
|
|
6
6
|
Author-email: Wraith <contact@payra.cash>
|
|
@@ -26,7 +26,7 @@ Dynamic: license-file
|
|
|
26
26
|
|
|
27
27
|
# Payra Python SDK
|
|
28
28
|
|
|
29
|
-
Official Python SDK for integrating **Payra's on-chain payment system** into your backend applications.
|
|
29
|
+
Official **Python SDK** for integrating **Payra's on-chain payment system** into your backend applications.
|
|
30
30
|
|
|
31
31
|
This SDK provides:
|
|
32
32
|
- Secure generation of **ECDSA signatures** compatible with the Payra smart contract — used for order payment verification.
|
|
@@ -36,38 +36,38 @@ This SDK provides:
|
|
|
36
36
|
|
|
37
37
|
The typical flow for signing and verifying a Payra transaction:
|
|
38
38
|
|
|
39
|
-
1.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
5. The **frontend** calls the Payra smart contract (`payOrder`) with all parameters **plus** the signature.
|
|
39
|
+
1. The **frontend** prepares all required payment parameters:
|
|
40
|
+
- **Network** – blockchain name (e.g. Polygon, Linea)
|
|
41
|
+
- **Token address** – ERC-20 token contract address
|
|
42
|
+
- **Order ID** – unique order identifier
|
|
43
|
+
- **Amount Wei** – already converted to the smallest unit (e.g. wei, 10⁶)
|
|
44
|
+
- **Timestamp** – Unix timestamp of the order
|
|
45
|
+
- **Payer wallet address** – the wallet address from which the user will make the on-chain payment
|
|
46
|
+
2. The frontend sends these parameters to your **backend**.
|
|
47
|
+
3. The **backend** uses this SDK to generate a cryptographic **ECDSA signature** with its private key (performed **offline**).
|
|
48
|
+
4. The backend returns the generated signature to the frontend.
|
|
49
|
+
5. The **frontend** calls the Payra smart contract (`payOrder`) with all parameters **plus** the signature.
|
|
51
50
|
|
|
52
51
|
This process ensures full compatibility between your backend and Payra’s on-chain verification logic.
|
|
53
52
|
|
|
54
53
|
## Features
|
|
55
54
|
|
|
56
|
-
- Generates **Ethereum ECDSA signatures** using the `secp256k1` curve.
|
|
55
|
+
- Generates **Ethereum ECDSA signatures** using the `secp256k1` curve.
|
|
57
56
|
- Fully compatible with **Payra's Solidity smart contracts** (`ERC-1155` payment verification).
|
|
58
|
-
- Includes built-in **ABI encoding and decoding** via
|
|
59
|
-
- Supports
|
|
57
|
+
- Includes built-in **ABI encoding and decoding** via `web3.php`.
|
|
58
|
+
- Supports `.env` and `config/payra.php` configuration for multiple blockchain networks.
|
|
59
|
+
- Laravel IoC container integration (easy dependency injection)
|
|
60
60
|
- Verifies **order payment status directly on-chain** via RPC or blockchain explorer API.
|
|
61
|
-
- Provides **secure backend integration**
|
|
61
|
+
- Provides **secure backend integration** for signing and verifying transactions.
|
|
62
62
|
- Includes optional utility helpers for:
|
|
63
|
-
- **Currency conversion** (via [ExchangeRate API](https://www.exchangerate-api.com/))
|
|
64
|
-
- **USD ⇄ WEI** conversion for token precision handling.
|
|
63
|
+
- **Currency conversion** (via [ExchangeRate API](https://www.exchangerate-api.com/))
|
|
64
|
+
- **USD ⇄ WEI** conversion for token precision handling.
|
|
65
65
|
|
|
66
66
|
## Setup
|
|
67
67
|
|
|
68
68
|
Before installing this package, make sure you have an active **Payra** account:
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
[https://payra.cash](https://payra.cash)
|
|
71
71
|
|
|
72
72
|
You will need:
|
|
73
73
|
|
|
@@ -118,13 +118,13 @@ This SDK requires:
|
|
|
118
118
|
|
|
119
119
|
## Environment Configuration
|
|
120
120
|
|
|
121
|
-
Create a
|
|
121
|
+
Create a `.env` file in your project root (you can copy from example):
|
|
122
122
|
|
|
123
123
|
```bash
|
|
124
124
|
cp .env.example .env
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
This file stores your **private configuration** and connection settings for all supported networks. Never commit
|
|
127
|
+
This file stores your **private configuration** and connection settings for all supported networks. Never commit `.env` to version control.
|
|
128
128
|
|
|
129
129
|
### Required Variables
|
|
130
130
|
|
|
@@ -133,8 +133,9 @@ This file stores your **private configuration** and connection settings for all
|
|
|
133
133
|
Used for automatic fiat → USD conversions via the built-in Payra utilities.
|
|
134
134
|
|
|
135
135
|
```bash
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
# Optional — only needed if you want to use the built-in currency conversion helper
|
|
137
|
+
PAYRA_EXCHANGE_RATE_API_KEY= # Your ExchangeRate API key (from exchangerate-api.com)
|
|
138
|
+
PAYRA_EXCHANGE_RATE_CACHE_TIME=720 # Cache duration in minutes (default: 720 = 12h)
|
|
138
139
|
|
|
139
140
|
PAYRA_POLYGON_CORE_FORWARD_CONTRACT_ADDRESS=0xf30070da76B55E5cB5750517E4DECBD6Cc5ce5a8
|
|
140
141
|
PAYRA_POLYGON_PRIVATE_KEY=
|
|
@@ -158,7 +159,7 @@ PAYRA_LINEA_RPC_URL_2=
|
|
|
158
159
|
#### Important Notes
|
|
159
160
|
|
|
160
161
|
- The cache automatically refreshes when it expires.
|
|
161
|
-
- You can adjust the cache duration by setting `
|
|
162
|
+
- You can adjust the cache duration by setting `PAYRA_EXCHANGE_RATE_CACHE_TIME`:
|
|
162
163
|
- `5` → cache for 5 minutes
|
|
163
164
|
- `60` → cache for 1 hour
|
|
164
165
|
- `720` → cache for 12 hours (default)
|
|
@@ -208,10 +209,21 @@ except Exception as e:
|
|
|
208
209
|
print(f"Unexpected error: {e}")
|
|
209
210
|
```
|
|
210
211
|
|
|
212
|
+
#### Input Parameters
|
|
213
|
+
|
|
214
|
+
| Field | Type | Description |
|
|
215
|
+
|--------------|----------|----------------------------------------------|
|
|
216
|
+
| **`network`** | `string` | Selected network name |
|
|
217
|
+
| **`tokenAddress`** | `string` | ERC20 token contract address |
|
|
218
|
+
| **`orderId`** | `string` | Unique order reference (e.g. ORDER-123) |
|
|
219
|
+
| **`amountWei`** | `string` or `integer` | Token amount in smallest unit (e.g. wei) |
|
|
220
|
+
| **`timestamp`** | `number` | Unix timestamp of signature creation |
|
|
221
|
+
| **`payerAddress`** | `string` | Payer Wallet Address
|
|
222
|
+
|
|
211
223
|
#### Behind the Scenes
|
|
212
224
|
|
|
213
225
|
1. The backend converts the amount to the smallest blockchain unit (e.g. wei).
|
|
214
|
-
3. A `PayraSignatureGenerator` instance is created using your private key from
|
|
226
|
+
3. A `PayraSignatureGenerator` instance is created using your private key from `.env`
|
|
215
227
|
4. It generates an ECDSA signature that is fully verifiable on-chain by the Payra smart contract.
|
|
216
228
|
5. The resulting signature should be sent to the **frontend**, which must call `payOrder(...)` using the same parameters (`timestamp`, `orderId`, `amount`, `tokenAddress`, etc.) that were used to generate the signature.
|
|
217
229
|
|
|
@@ -305,11 +317,11 @@ python3 example_order_verification.py
|
|
|
305
317
|
python3 example_utils.py
|
|
306
318
|
```
|
|
307
319
|
|
|
308
|
-
Make sure your
|
|
320
|
+
Make sure your `.env` file contains correct values for the `network` being used.
|
|
309
321
|
|
|
310
322
|
### Tips
|
|
311
323
|
|
|
312
|
-
- Always verify your
|
|
324
|
+
- Always verify your `.env` configuration before running any signing or on-chain verification examples.
|
|
313
325
|
- The SDK examples are safe to run — they use **read-only RPC calls** (no real transactions are broadcast).
|
|
314
326
|
- You can modify `example_signature.py` to test custom token addresses or order parameters.
|
|
315
327
|
|
|
@@ -2,9 +2,9 @@ payra_sdk/__init__.py,sha256=VMmHadXy0RLCjEPZhW_hCc3hg34pkmrL4VhTjqmVBiI,422
|
|
|
2
2
|
payra_sdk/exceptions.py,sha256=Dr8dy0RohAYII_-YeSu_doPJSr0EsJPcp6Oj02sio9Q,425
|
|
3
3
|
payra_sdk/order_verification.py,sha256=IWKV4V6gZRyrtJtXsDRPflUcSsuN5D1kFZn5QVTPi5Q,3379
|
|
4
4
|
payra_sdk/signature.py,sha256=Vn85w4DAGzHK1y9h3hMETij_-Qa4aSNz0KwnzwCyFQw,8613
|
|
5
|
-
payra_sdk/utils.py,sha256=
|
|
6
|
-
payra_sdk-1.2.
|
|
7
|
-
payra_sdk-1.2.
|
|
8
|
-
payra_sdk-1.2.
|
|
9
|
-
payra_sdk-1.2.
|
|
10
|
-
payra_sdk-1.2.
|
|
5
|
+
payra_sdk/utils.py,sha256=gIQZX9N97Eneh5ScJ-YWY8_8wRqxBe0h5lDAVFYV8CE,4854
|
|
6
|
+
payra_sdk-1.2.4.dist-info/licenses/LICENSE,sha256=mnnujAcvHr1ULEDD2l0ZT6lrpeTv_9bG3n8sngv7ew8,120
|
|
7
|
+
payra_sdk-1.2.4.dist-info/METADATA,sha256=BF0bsVhP4ycHdUfzYPG1q6c6zR_z5aG2i2toHAGRW2c,12574
|
|
8
|
+
payra_sdk-1.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
payra_sdk-1.2.4.dist-info/top_level.txt,sha256=oC4dhGzjcpDRRwyU9JjtLu56Uc5moaa76utQGYsPL-g,10
|
|
10
|
+
payra_sdk-1.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|