khaleds/payment
Composer 安装命令:
composer require khaleds/payment
包简介
Payment helper for Paypal, Paymob, Kashier, Hyperpay and Fawry
README 文档
README
Payment Helper of Payment Gateways ( PayPal - Paymob - Fawry - Thawani - WeAccept - Kashier - Hyperpay - Tap - Opay - Paytabs - Vodafone Cash - Orange Money - Meza Wallet - Etisalat Cash)

Supported gateways
- PayPal
- PayMob
- WeAccept
- Kashier
- Fawry
- HyperPay
- Thawani
- Tap
- Opay
- Paytabs
- E Wallets (Vodafone Cash - Orange Money - Meza Wallet - Etisalat Cash)
- Cash on delivery
Installation
composer require nafezly/payments php artisan migrate
Add this to your DatabaseSeeder run method
use Khaleds\Payment\Seeders\PaymentMethodsTableSeeder; $this->call(PaymentMethodsTableSeeder::class);
Publish Vendor Files
php artisan vendor:publish --tag="nafezly-payments-config" php artisan vendor:publish --tag="nafezly-payments-lang"
nafezly-payments.php file
<?php return [ #PAYMOB 'PAYMOB_API_KEY' => env('PAYMOB_API_KEY'), 'PAYMOB_INTEGRATION_ID' => env('PAYMOB_INTEGRATION_ID'), 'PAYMOB_IFRAME_ID' => env('PAYMOB_IFRAME_ID'), 'PAYMOB_HMAC' => env('PAYMOB_HMAC'), 'PAYMOB_CURRENCY'=> env('PAYMOB_CURRENCY',"EGP"), #HYPERPAY 'HYPERPAY_BASE_URL' => env('HYPERPAY_BASE_URL', "https://eu-test.oppwa.com"), 'HYPERPAY_URL' => env('HYPERPAY_URL', env('HYPERPAY_BASE_URL') . "/v1/checkouts"), 'HYPERPAY_TOKEN' => env('HYPERPAY_TOKEN'), 'HYPERPAY_CREDIT_ID' => env('HYPERPAY_CREDIT_ID'), 'HYPERPAY_MADA_ID' => env('HYPERPAY_MADA_ID'), 'HYPERPAY_APPLE_ID' => env('HYPERPAY_APPLE_ID'), 'HYPERPAY_CURRENCY' => env('HYPERPAY_CURRENCY', "SAR"), #KASHIER 'KASHIER_ACCOUNT_KEY' => env('KASHIER_ACCOUNT_KEY'), 'KASHIER_IFRAME_KEY' => env('KASHIER_IFRAME_KEY'), 'KASHIER_TOKEN' => env('KASHIER_TOKEN'), 'KASHIER_URL' => env('KASHIER_URL', "https://checkout.kashier.io"), 'KASHIER_MODE' => env('KASHIER_MODE', "test"), //live or test 'KASHIER_CURRENCY'=>env('KASHIER_CURRENCY',"EGP"), #FAWRY 'FAWRY_URL' => env('FAWRY_URL', "https://atfawry.fawrystaging.com/"),//https://www.atfawry.com/ for production 'FAWRY_SECRET' => env('FAWRY_SECRET'), 'FAWRY_MERCHANT' => env('FAWRY_MERCHANT'), #PayPal 'PAYPAL_CLIENT_ID' => env('PAYPAL_CLIENT_ID'), 'PAYPAL_SECRET' => env('PAYPAL_SECRET'), 'PAYPAL_CURRENCY' => env('PAYPAL_CURRENCY', "USD"), 'PAYPAL_MODE' => env('PAYPAL_MODE',"sandbox"),//sandbox or live #THAWANI 'THAWANI_API_KEY' => env('THAWANI_API_KEY', ''), 'THAWANI_URL' => env('THAWANI_URL', "https://uatcheckout.thawani.om/"), 'THAWANI_PUBLISHABLE_KEY' => env('THAWANI_PUBLISHABLE_KEY', ''), #TAP 'TAP_CURRENCY' => env('TAP_CURRENCY',"USD"), 'TAP_SECRET_KEY'=>env('TAP_SECRET_KEY','sk_test_XKokBfNWv6FIYuTMg5sLPjhJ'), 'TAP_PUBLIC_KEY'=>env('TAP_PUBLIC_KEY','pk_test_EtHFV4BuPQokJT6jiROls87Y'), 'TAP_LANG_KEY'=>env('TAP_LANG_KEY','ar'), #OPAY 'OPAY_CURRENCY'=>env('OPAY_CURRENCY',"EGP"), 'OPAY_SECRET_KEY'=>env('OPAY_SECRET_KEY'), 'OPAY_PUBLIC_KEY'=>env('OPAY_PUBLIC_KEY'), 'OPAY_MERCHANT_ID'=>env('OPAY_MERCHANT_ID'), 'OPAY_COUNTRY_CODE'=>env('OPAY_COUNTRY_CODE',"EG"), 'OPAY_BASE_URL'=>env('OPAY_BASE_URL',"https://sandboxapi.opaycheckout.com"),//https://api.opaycheckout.com for production #PAYMOB_WALLET (Vodafone-cash,orange-money,etisalat-cash,we-cash,meza-wallet) - test phone 01010101010 ,PIN & OTP IS 123456 'PAYMOB_WALLET_INTEGRATION_ID'=>env('PAYMOB_WALLET_INTEGRATION_ID'), #Paytabs 'PAYTABS_PROFILE_ID' => env('PAYTABS_PROFILE_ID'), 'PAYTABS_SERVER_KEY' => env('PAYTABS_SERVER_KEY'), 'PAYTABS_BASE_URL' => env('PAYTABS_BASE_URL',"https://secure-egypt.paytabs.com"), 'PAYTABS_CHECKOUT_LANG' => env('PAYTABS_CHECKOUT_LANG',"AR"), 'PAYTABS_CURRENCY'=>env('PAYTABS_CURRENCY',"EGP"), 'VERIFY_ROUTE_NAME' => "payment-verify", 'APP_NAME'=>env('APP_NAME'), ];
Web.php MUST Have Route with name “payment-verify”
Route::get('/payments/verify/{payment?}',[FrontController::class,'payment_verify'])->name('payment-verify');
Payment Methods
you can now have all of this payments as a crud !! the table contain (method,name,color,description,icon,is_active) so you can create your own dashboard crud to manage which one active or not and if there is an api functionality you can send this crud where they are active and return back for you the selected method so you can use the factory way directly. pass the method to factory -> pay done you have the response data :)
How To Use
you can pass only method name without payment key word like (Fawry,Paymob,Opay ...etc) or use an api that the user choose which method he wanted and pass it .
$payment = new \Nafezly\Payments\Factories\PaymentFactory(); $payment=$payment->get(string $paymentName) // the required data ->setRequest(array $request) // user model (user , account , vendore etc...) ->setBuyerModel(Model $buyer) ->pay() //verify $payment = new \Nafezly\Payments\Factories\PaymentFactory(); $payment=$payment->get(string $paymentName) // the required data ->setRequest(array $request) // user model (user , account , vendore etc...) ->setBuyerModel(Model $buyer) ->verify()
Response
now you have DTO for response
public bool $status = true; public string $message = ''; public array $data=[]; public array $request=[]; public NafezlyPayment $payment; public string $payment_id = ''; public View|null $html = null; public string $redirect_url = ''; public array $errors = [];
you can check for the status boolean to do your actions next if the status false you will find the error message contain the error and errors array will contain for example the validation errors
Payments Table
now you have a payments table and payment logs table when you us pay function the record will store into payments table with status UNPAID this table is a morph
| column | description |
|---|---|
| model_id | the buyer id |
| model_type | the buyer table |
| order_id | the id that you user paid for |
| order_type | the table name (orders,service,plans ..etc) |
| payment_method | the method name |
| payment_status | PAID -- UNPAID |
| transaction_code | unique code |
| amount | float number |
| notes | nullable notes |
and when you use verify the status will change to PAID
when any something went wrong the request and response will be saved into payment_logs table
Test Cards
Credits
khaleds/payment 适用场景与选型建议
khaleds/payment 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「template」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 khaleds/payment 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 khaleds/payment 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 khaleds/payment 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple ASCII output of array data
E2E Studios PHP Framework adaptation of leafsphp/blade package
Alfabank REST API integration
Ensolab template project
Account Balance / Wallets Manager For FilamentPHP and Filament Account Builder
Render blade templates into a PSR-7 Response object.
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-19