I'm absolutely thrilled to announce the official release of the Payra Laravel SDK! If you're building a modern application with Laravel and want to integrate secure, on-chain crypto payments effortlessly, this SDK is the game-changer you’ve been waiting for.
This isn't just a simple wrapper; this is the key to connecting your trusted Laravel backend directly with the Payra smart contract and the entire blockchain ecosystem. Get ready for seamless, verified crypto transactions with minimal effort.
Why This SDK is a Big Deal for Laravel Developers
Integrating blockchain payments can be complex, often requiring manual handling of cryptographic signatures and intricate on-chain data retrieval. The Payra Laravel SDK eliminates this complexity by providing two core, highly secure functionalities:
1. Secure ECDSA Signature Generation (Offline)
The heart of Payra's security is the ECDSA signature, which verifies the authenticity of every payment request. With this SDK, generating that signature is simple:
- Offline Security: The signature is generated securely on your Laravel backend using your private key, ensuring the key is never exposed to the frontend or version control.
- Smart Contract Compatibility: The signatures are fully compatible with Payra’s Solidity smart contracts, ensuring the payment is valid before it's processed on the blockchain.
2. Direct On-Chain Verification
No more relying on external APIs for order status! The SDK allows your backend to directly query the blockchain (via your configured RPC URLs) to confirm if a payment has been completed:
use Payra\PayraOrderVerification;
// ...
$orderVerification = app(PayraOrderVerification::class);
$orderStatus = $orderVerification->isOrderPaid($network, $orderId);
// Returns 'paid': true or false
This guarantees that you are confirming the order status directly from the immutable ledger, providing the highest level of trust.
How It Works: The Secure Payment Flow
The entire payment process is designed for maximum security and reliability:
Frontend Prepares: The user initiates a payment, and the frontend gathers payment details (Network, Token Address, Amount, Timestamp, Payer Address).
Backend Signs: The frontend sends these details to your Laravel backend. The SDK receives the parameters and uses your secret private key to generate a unique ECDSA signature.
Frontend Executes: The backend returns the signature, and the frontend uses all the parameters (including the signature) to execute the final payment call to the Payra smart contract (
payOrder) on the blockchain.
This server-side signing model is the industry best practice, keeping your most sensitive secrets safe.
Essential Built-in Utilities
The SDK goes beyond just signatures and verification, offering a powerful PayraUtils class to handle common crypto payment headaches:
| Utility | Description |
|---|---|
| USD ⇄ WEI Conversion | Easily convert user-friendly USD amounts to the token's smallest unit (Wei) and vice-versa, correctly handling token decimals (e.g., $1 = $1,000,000 for a 6-decimal token). |
| Token Decimals Lookup | Quickly retrieve the correct number of decimals for any ERC-20 token on a specified network. |
| Fiat-to-USD Conversion | (Optional) If your store uses EUR, GBP, or another currency, the SDK integrates with ExchangeRate API to automatically convert your native currency to USD (which Payra uses for processing). |
This means you spend less time writing conversion logic and more time shipping features!
Quick Setup & Configuration
Getting started is fast and simple, thanks to Laravel's auto-discovery and configuration system.
1. Installation
composer require payracash/payra-sdk-laravel
# Publish config file
php artisan vendor:publish --tag=payra-config
2. Environment Variables
Configure the networks you support right in your .env file. The SDK supports multiple networks (Polygon, Ethereum, Linea, etc.), each with its own unique MERCHANT_ID, PRIVATE_KEY, and multiple redundant RPC URLs:
# Polygon network configuration
PAYRA_POLYGON_MERCHANT_ID=
PAYRA_POLYGON_PRIVATE_KEY=
PAYRA_POLYGON_RPC_URL_1=
PAYRA_POLYGON_RPC_URL_2= # for redundancy!
# Ethereum network configuration
PAYRA_ETHEREUM_MERCHANT_ID=
# ...
3. API Key for Exposed Endpoints
For extra security, if you expose SDK functionalities via HTTP endpoints (e.g., a /api/payra/sign route), the package includes a lightweight, server-to-server API key check using the X-Payra-Key header. You generate this key yourself—it’s not issued by Payra—and it acts as a simple but effective firewall.
Final Thoughts: The Future is On-Chain
The Payra Laravel SDK brings the power of on-chain, stablecoin payments to your Laravel application, combining the security of blockchain cryptography with the ease of use that Laravel developers expect.
It's robust, secure, and ready for production. Stop wrestling with low-level web3 libraries and start building!
Ready to integrate? Check out the full documentation on GitHub now!
Follow Payra on Twix (X) and join our Telegram Group for updates and support!
Top comments (0)