payra-sdk 1.2.6__py3-none-any.whl → 1.2.7__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/__init__.py CHANGED
@@ -1,13 +1,13 @@
1
1
  # payra-sdk-python/payra_sdk/__init__.py
2
2
 
3
- from .signature import PayraSignatureGenerator
4
- from .order_verification import PayraOrderVerification
3
+ from .signature import PayraSignature
4
+ from .order_service import PayraOrderService
5
5
  from .exceptions import PayraSDKException, InvalidArgumentError, SignatureError
6
6
  from .utils import PayraUtils
7
7
 
8
8
  __all__ = [
9
- "PayraSignatureGenerator",
10
- "PayraOrderVerification",
9
+ "PayraSignature",
10
+ "PayraOrderService",
11
11
  "PayraSDKException",
12
12
  "InvalidArgumentError",
13
13
  "SignatureError",
@@ -11,7 +11,7 @@ from .exceptions import InvalidArgumentError, SignatureError
11
11
  # load env
12
12
  load_dotenv()
13
13
 
14
- class PayraOrderVerification:
14
+ class PayraOrderService:
15
15
  """
16
16
  SDK for verifying if an order has been paid using the Payra smart contract.
17
17
  """
@@ -22,7 +22,7 @@ class PayraOrderVerification:
22
22
 
23
23
  self.web3 = Web3(Web3.HTTPProvider(self.rpc_url))
24
24
  if not self.web3.is_connected():
25
- raise ConnectionError(f"Failed to connect to QuickNode RPC for {self.network}")
25
+ raise ConnectionError(f"Failed to connect to RPC for {self.network}")
26
26
 
27
27
  self.merchant_id = os.getenv(f"PAYRA_{self.network}_MERCHANT_ID")
28
28
  self.gateway_address = os.getenv(f"PAYRA_{self.network}_OCP_GATEWAY_CONTRACT_ADDRESS")
@@ -53,7 +53,7 @@ class PayraOrderVerification:
53
53
  # Return the actual contract responsible for order data
54
54
  return self.web3.eth.contract(address=user_data_address, abi=self.abi)
55
55
 
56
- def is_order_paid(self, order_id: str) -> dict:
56
+ def is_paid(self, order_id: str) -> dict:
57
57
  """
58
58
  Verify if an order is paid on Payra contract.
59
59
  """
@@ -76,7 +76,7 @@ class PayraOrderVerification:
76
76
  "error": str(e)
77
77
  }
78
78
 
79
- def get_order_status(self, order_id: str) -> dict:
79
+ def get_details(self, order_id: str) -> dict:
80
80
  """
81
81
  Detailed status of an order from Payra smart contract.
82
82
  Equivalent to getOrderDetails in Node.js version.
payra_sdk/signature.py CHANGED
@@ -12,7 +12,7 @@ from .exceptions import InvalidArgumentError, SignatureError
12
12
  # Load environment variables from .env file
13
13
  load_dotenv()
14
14
 
15
- class PayraSignatureGenerator:
15
+ class PayraSignature:
16
16
  """
17
17
  SDK for generating Payra payment signatures on the backend.
18
18
  This version assumes `amount_wei` is already in the token's smallest unit (e.g., wei)
@@ -22,10 +22,10 @@ class PayraSignatureGenerator:
22
22
  def __init__(self):
23
23
 
24
24
  """
25
- Initializes the PayraSignatureGenerator.
25
+ Initializes the PayraSignature.
26
26
  """
27
27
 
28
- def generate_signature(
28
+ def generate(
29
29
  self,
30
30
  network: str,
31
31
  token_address: str,
@@ -117,7 +117,7 @@ class PayraSignatureGenerator:
117
117
  raise SignatureError(f"Error generating signature: {e}")
118
118
 
119
119
  # Optional: Add a verification method if you ever need to verify a signature offline
120
- def verify_signature(
120
+ def verify(
121
121
  self,
122
122
  network: str,
123
123
  token_address: str,
@@ -168,7 +168,7 @@ class PayraSignatureGenerator:
168
168
  ) -> bytes:
169
169
  """
170
170
  Generates the raw Keccak256 hash of the ABI-encoded payment data.
171
- This is a helper for internal use, especially for `verify_signature`.
171
+ This is a helper for internal use, especially for `verify`.
172
172
  """
173
173
  checksum_token_address = to_checksum_address(token_address)
174
174
  checksum_payer_address = to_checksum_address(payer_address)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: payra_sdk
3
- Version: 1.2.6
3
+ Version: 1.2.7
4
4
  Summary: Python SDK for Payra payment signature generation (backend)
5
5
  Author: Your Name
6
6
  Author-email: Wraith <support@payra.cash>
@@ -28,8 +28,7 @@ Official **Python SDK** for integrating **Payra's on-chain payment system** into
28
28
 
29
29
  This SDK provides:
30
30
  - Secure generation of **ECDSA signatures** compatible with the Payra smart contract, used for order payment verification.
31
- - Simple methods for **checking the on-chain status of orders** to confirm completed payments.
32
-
31
+ - Simple methods for **checking the on-chain details of orders** to confirm completed payments.
33
32
 
34
33
  ## How It Works
35
34
 
@@ -48,20 +47,18 @@ The typical flow for signing and verifying a Payra transaction:
48
47
 
49
48
  This process ensures full compatibility between your backend and Payra’s on-chain verification logic.
50
49
 
51
-
52
50
  ## Features
53
51
 
54
52
  - Generates **Ethereum ECDSA signatures** using the `secp256k1` curve.
55
53
  - Fully compatible with **Payra's Solidity smart contracts** (`ERC-1155` payment verification).
56
54
  - Supports `.env` and `config/payra.php` configuration for multiple blockchain networks.
57
55
  - Laravel IoC container integration (easy dependency injection)
58
- - Verifies **order payment status directly on-chain** via RPC or blockchain explorer API.
56
+ - Verifies **order payment details directly on-chain** via RPC or blockchain explorer API.
59
57
  - Provides **secure backend integration** for signing and verifying transactions.
60
58
  - Includes optional utility helpers for:
61
59
  - **Currency conversion** (via [ExchangeRate API](https://www.exchangerate-api.com/))
62
60
  - **USD ⇄ WEI** conversion for token precision handling.
63
61
 
64
-
65
62
  ## Setup
66
63
 
67
64
  Before installing this package, make sure you have an active **Payra** account:
@@ -87,7 +84,6 @@ To obtain your **RPC URLs** which are required for reading on-chain order status
87
84
  Optional (recommended):
88
85
  - Create a free API key at [ExchangeRate API](https://www.exchangerate-api.com/) to enable **automatic fiat → USD conversions** using the built-in utility helpers.
89
86
 
90
-
91
87
  ## Installation
92
88
 
93
89
  ### From PyPI
@@ -129,7 +125,6 @@ cp .env.example .env
129
125
 
130
126
  This file stores your **private configuration** and connection settings for all supported networks. Never commit `.env` to version control.
131
127
 
132
-
133
128
  ### Required Variables
134
129
 
135
130
  #### Exchange Rate (optional)
@@ -175,10 +170,10 @@ PAYRA_LINEA_RPC_URL_2=
175
170
 
176
171
  ## Usage Example
177
172
 
178
- ### Generating and verifying a Payra signature in your backend
173
+ ### Generating signature
179
174
 
180
175
  ```python
181
- from payra_sdk import PayraUtils, PayraSignatureGenerator, PayraSDKException
176
+ from payra_sdk import PayraUtils, PayraSignature, PayraSDKException
182
177
 
183
178
  try:
184
179
  # Convert amount to smallest unit (wei or token decimals
@@ -186,24 +181,24 @@ try:
186
181
 
187
182
  PAYMENT_DATA = {
188
183
  "network": "polygon",
189
- "tokenAddress": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", # USDT on Polygon
190
- "orderId": "ORDER-1753824905006-301-322",
191
- "amountWei": amount_wei, # e.g. 3.34 USDT in smallest unit
184
+ "token_address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F", # USDT on Polygon
185
+ "order_id": "ord-258",
186
+ "amount_wei": amount_wei, # e.g. 3.34 USDT in smallest unit
192
187
  "timestamp": 1753826059, # current Unix timestamp
193
- "payerAddress": "0xe6c961D6ad9a27Ea8e5d99e40abaC365DE9Cc162"
188
+ "payer_address": "0xe6c961D6ad9a27Ea8e5d99e40abaC365DE9Cc162"
194
189
  }
195
190
 
196
191
  # Initialize signer
197
- payra_signer = PayraSignatureGenerator()
192
+ payra_signature = PayraSignature()
198
193
 
199
194
  # Generate cryptographic signature
200
- signature = payra_signer.generate_signature(
195
+ signature = payra_signature.generate(
201
196
  network=PAYMENT_DATA["network"],
202
- token_address=PAYMENT_DATA["tokenAddress"],
203
- order_id=PAYMENT_DATA["orderId"],
204
- amount_wei=PAYMENT_DATA["amountWei"],
197
+ token_address=PAYMENT_DATA["token_address"],
198
+ order_id=PAYMENT_DATA["order_id"],
199
+ amount_wei=PAYMENT_DATA["amount_wei"],
205
200
  timestamp=PAYMENT_DATA["timestamp"],
206
- payer_address=PAYMENT_DATA["payerAddress"]
201
+ payer_address=PAYMENT_DATA["payer_address"]
207
202
  )
208
203
 
209
204
  print(f"Generated signature: {signature}")
@@ -218,11 +213,11 @@ except Exception as e:
218
213
  | Field | Type | Description |
219
214
  |--------------|----------|----------------------------------------------|
220
215
  | **`network`** | `string` | Selected network name |
221
- | **`tokenAddress`** | `string` | ERC20 token contract address |
222
- | **`orderId`** | `string` | Unique order reference (e.g. ORDER-123) |
223
- | **`amountWei`** | `string` or `integer` | Token amount in smallest unit (e.g. wei) |
216
+ | **`token_address`** | `string` | ERC20 token contract address |
217
+ | **`order_id`** | `string` | Unique order reference (e.g. ORDER-123) |
218
+ | **`amount_wei`** | `string` or `integer` | Token amount in smallest unit (e.g. wei) |
224
219
  | **`timestamp`** | `number` | Unix timestamp of signature creation |
225
- | **`payerAddress`** | `string` | Payer Wallet Address
220
+ | **`payer_address`** | `string` | Payer Wallet Address
226
221
 
227
222
  #### Behind the Scenes
228
223
 
@@ -233,7 +228,7 @@ except Exception as e:
233
228
 
234
229
  ---
235
230
 
236
- ### Get Order Status
231
+ ### Get Order Details
237
232
 
238
233
  Retrieve **full payment details** for a specific order from the Payra smart contract. This method returns the complete on-chain payment data associated with the order, including:
239
234
  - whether the order has been paid,
@@ -245,18 +240,18 @@ Retrieve **full payment details** for a specific order from the Payra smart cont
245
240
  Use this method when you need **detailed information** about the payment or want to display full transaction data.
246
241
 
247
242
  ```python
248
- from payra_sdk import PayraOrderVerification, PayraSDKException
243
+ from payra_sdk import PayraOrderService, PayraSDKException
249
244
 
250
245
  try:
251
246
  ORDER_ID = "ord-258"
252
247
  # Initialize verifier for a specific network
253
- verifier = PayraOrderVerification("polygon")
248
+ order_service = PayraOrderService("polygon")
254
249
 
255
- print("\nGet order status...")
256
- result = verifier.get_order_status(ORDER_ID)
250
+ print("\nGet order details...")
251
+ details = order_service.get_details(ORDER_ID)
257
252
 
258
253
  print("Order ID:", ORDER_ID)
259
- print("Result:", result)
254
+ print("Details:", details)
260
255
 
261
256
  except PayraSDKException as e:
262
257
  print(f"Payra SDK error: {e}")
@@ -266,8 +261,8 @@ except Exception as e:
266
261
 
267
262
  #### Behind the Scenes
268
263
 
269
- 1. The backend initializes a `PayraOrderVerification` object for the desired blockchain network.
270
- 2. It calls `get_order_status(order_id)` to check if the order transaction exists and is confirmed on-chain.
264
+ 1. The backend initializes a `PayraOrderService` object for the desired blockchain network.
265
+ 2. It calls `get_details(order_id)` to check if the order transaction exists and is confirmed on-chain.
271
266
  3. The function returns a dictionary with:
272
267
 
273
268
  ```python
@@ -291,16 +286,16 @@ Perform a **simple payment check** for a specific order. This method only verifi
291
286
  Use this method when you only need a **quick boolean confirmation** of the payment status.
292
287
 
293
288
  ```python
294
- from payra_sdk import PayraOrderVerification, PayraSDKException
289
+ from payra_sdk import PayraOrderService, PayraSDKException
295
290
 
296
291
  try:
297
292
  ORDER_ID = "ord-258"
298
293
 
299
294
  # Initialize verifier for a specific network
300
- verifier = PayraOrderVerification("polygon")
295
+ order_service = PayraOrderService("polygon")
301
296
 
302
297
  print("\nChecking order status...")
303
- result = verifier.is_order_paid(ORDER_ID)
298
+ result = order_service.is_paid(ORDER_ID)
304
299
 
305
300
  print("Order ID:", ORDER_ID)
306
301
  print("Result:", result)
@@ -320,7 +315,7 @@ except Exception as e:
320
315
 
321
316
  #### Behind the Scenes
322
317
 
323
- 1. The backend initializes a `PayraOrderVerification` object for the desired blockchain network.
318
+ 1. The backend initializes a `PayraOrderService` object for the desired blockchain network.
324
319
  2. It calls `is_order_paid(order_id)` to check if the order transaction exists and is confirmed on-chain.
325
320
  3. The function returns a dictionary with:
326
321
  ```python
@@ -365,14 +360,14 @@ print(f"100 EUR = {usd_value} USD")
365
360
  - `get_decimals(network, token)` – Returns the number of decimals for the given token on that network.
366
361
  - `convert_to_usd(amount, currency)` – Converts fiat amounts (e.g. EUR, GBP) to USD using your ExchangeRate API key.
367
362
 
368
-
369
363
  ## Testing
370
364
 
371
365
  You can run the included `examples` to test signing and verification:
372
366
 
373
367
  ```python
374
368
  python3 example_signature.py
375
- python3 example_order_verification.py
369
+ python3 example_order_get_details.py
370
+ python3 example_order_is_paid
376
371
  python3 example_utils.py
377
372
  ```
378
373
 
@@ -384,7 +379,6 @@ Make sure your `.env` file contains correct values for the `network` being used.
384
379
  - The SDK examples are safe to run, they use **read-only RPC calls** (no real transactions are broadcast).
385
380
  - You can modify `example_signature.py` to test custom token addresses or order parameters.
386
381
 
387
-
388
382
  ## Projects
389
383
 
390
384
  - [GitHub/Home](https://github.com/payracash)
@@ -398,7 +392,6 @@ Make sure your `.env` file contains correct values for the `network` being used.
398
392
  - [https://payra.xyz](https://payra.xyz)
399
393
  - [https://payra.eth](https://payra.eth.limo) - suporrted by Brave and Opera Browser or .limo
400
394
 
401
-
402
395
  ## Social Media
403
396
 
404
397
  - [Telegram Payra Group](https://t.me/+GhTyJJrd4SMyMDA0)
@@ -0,0 +1,10 @@
1
+ payra_sdk/__init__.py,sha256=PvxKm9ON7p0Ym3aJM7TyL0YebWvYWx-4ETFb495tvnE,389
2
+ payra_sdk/exceptions.py,sha256=Dr8dy0RohAYII_-YeSu_doPJSr0EsJPcp6Oj02sio9Q,425
3
+ payra_sdk/order_service.py,sha256=4fFplTMJh0ZB4tgeSqat5hdMQ7Ijf0aI-mGg7scoy5o,4316
4
+ payra_sdk/signature.py,sha256=Py7iqCc9juy56mFHXEUVCpfKYsdLuVh482GZLv0q4iI,8579
5
+ payra_sdk/utils.py,sha256=mp9xX-6ph_xRMSIHh6PP41RcYyKZMLVPEi9M3IxxC4c,4147
6
+ payra_sdk-1.2.7.dist-info/licenses/LICENSE,sha256=mnnujAcvHr1ULEDD2l0ZT6lrpeTv_9bG3n8sngv7ew8,120
7
+ payra_sdk-1.2.7.dist-info/METADATA,sha256=h5sBCTp1jeIKdsAjjuJDYfHDXxfmwOAIuEJns8TlCew,14299
8
+ payra_sdk-1.2.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
9
+ payra_sdk-1.2.7.dist-info/top_level.txt,sha256=oC4dhGzjcpDRRwyU9JjtLu56Uc5moaa76utQGYsPL-g,10
10
+ payra_sdk-1.2.7.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- payra_sdk/__init__.py,sha256=VMmHadXy0RLCjEPZhW_hCc3hg34pkmrL4VhTjqmVBiI,422
2
- payra_sdk/exceptions.py,sha256=Dr8dy0RohAYII_-YeSu_doPJSr0EsJPcp6Oj02sio9Q,425
3
- payra_sdk/order_verification.py,sha256=_AMdw4FQf-WMO0nswylW3AJoCJbxo7__Xi1zz6IeiJo,4342
4
- payra_sdk/signature.py,sha256=JhozJ_Fwhn8lOHO-p8xEHn80I-TMHdeibzIXBI_bkkg,8627
5
- payra_sdk/utils.py,sha256=mp9xX-6ph_xRMSIHh6PP41RcYyKZMLVPEi9M3IxxC4c,4147
6
- payra_sdk-1.2.6.dist-info/licenses/LICENSE,sha256=mnnujAcvHr1ULEDD2l0ZT6lrpeTv_9bG3n8sngv7ew8,120
7
- payra_sdk-1.2.6.dist-info/METADATA,sha256=e3OjC4MBEExh-3BVtQvoYznj1J-oSbgXfC6x54h8Kas,14365
8
- payra_sdk-1.2.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
9
- payra_sdk-1.2.6.dist-info/top_level.txt,sha256=oC4dhGzjcpDRRwyU9JjtLu56Uc5moaa76utQGYsPL-g,10
10
- payra_sdk-1.2.6.dist-info/RECORD,,