This PHP SDK provides a simple interface to integrate Esewa payment gateway functionality into your application. With this SDK, you can easily configure payment details, generate payment forms, decode responses, and validate transactions using Esewa's APIs.
You can install this SDK via Composer. Run the following command in your terminal:
composer require xentixar/esewa-sdkTo generate the autoloader, run the following command in your terminal:
composer dump-autoload- To configure the Esewa payment details, you can use the config method:
use Xentixar\EsewaSdk\Esewa;
$esewa = new Esewa();
$esewa->config('https://your-success-url.com', 'https://your-failure-url.com', 1000.00, 'your-transaction-uuid')Development Environment
- To generate a payment form for the development environment, use the init method without any parameters:
$esewa->init();Production Environment
- To generate a payment form for the production environment, use the init method with the $production parameter set to true:
$esewa->init(true);- After the payment process, you can decode the Esewa response using the decode method:
$responseData = $esewa->decode();- You can validate a transaction using the validate method:
$response = $esewa->validate('1000.00', 'your-transaction-uuid', true);config(string $success_url, string $failure_url, float $amount, string $transaction_uuid, string $product_code = 'EPAYTEST', string $secret_key = '8gBm/:&EnhH.1/q', float $tax_amount = 0, float $product_service_charge = 0, float $product_delivery_charge = 0)
- Configures Esewa payment details.
init(bool $production = false)
- Initializes the payment form for either the development or production environment based on the
$productionflag.
decode(): ?array
- Decodes Esewa response, if the
dataparameter is set in the GET request.
validate(string $total_amount, string $transaction_uuid, bool $production = false, string $product_code = 'EPAYTEST'): string
- Validates the transaction by making a cURL request to check the transaction status based on provided parameters.
- Ensure that the secret key is stored securely and not exposed in your codebase or version control system.
- When dealing with transactions and security, always ensure that you validate transaction responses to ensure authenticity and avoid fraudulent transactions.