pralhadstha/omnipay-khalti
最新稳定版本:v1.0.0
Composer 安装命令:
composer require pralhadstha/omnipay-khalti
包简介
Khalti Omnipay Package for PHP applications
README 文档
README
Khalti driver for the Omnipay PHP payment processing library
Omnipay is a framework agnostic, multi-gateway payment processing library for PHP.
This package implements Khalti support for Omnipay.
Installation
Omnipay is installed via Composer.
To install, simply require league/omnipay and pralhadstha/omnipay-khalti with Composer:
composer require league/omnipay pralhadstha/omnipay-khalti
Basic Usage
Purchase
use Omnipay\Omnipay; use Exception; $gateway = Omnipay::create('Khalti_Khalti'); $gateway->setSecret('secret_key_provided_by_khalti'); $gateway->setTestMode(true); try { $response = $gateway->purchase([ 'amount' => 10000, // Rs. 100 in paisa 'purchaseOrderId' => 'SH-100', 'purchaseOrderName' => "Basmati Rice 500gm", 'websiteUrl' => 'https://merchant.com/', 'returnUrl' => 'https://merchant.com/payment/1/complete', ])->send(); if ($response->isRedirect()) { $response->redirect(); } } catch (Exception $e) { return $e->getMessage(); }
After successful payment and redirect back to merchant site, you can verify the payment status and work accordingly.
Verify Payment
$gateway = Omnipay::create('Khalti_Khalti'); $gateway->setSecret('secret_key_provided_by_khalti'); $gateway->setTestMode(true); $payload = $_GET; try { $response = $gateway->fetchTransaction([ 'paymentId' => $payload['pidx'] ])->send(); if ($response->isSuccessful()) { // Verified } else { // Unverified } } catch (Exception $e) { return $e->getMessage(); }
Working Example
Want to see working examples before integrating them into your project? View the examples here
Official Doc
Please follow the Official Doc to understand about the parameters and their descriptions.
Contributing
Contributions are welcome and will be fully credited.
Contributions can be made via a Pull Request on Github.
Support
If you are having general issues with Omnipay Khalti, drop an email to pralhad.shrestha05@gmail.com for quick support.
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 38
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-07