shahzadthathal/skipcash
Composer 安装命令:
composer require shahzadthathal/skipcash
包简介
Skipcash payment gateway integration.
README 文档
README
Install package
composer require shahzadthathal/skipcash
Add Skipcash Provider to config/app.php providers array.
Shahzadthathal\Skipcash\Providers\SkipcashProvider::class
Update .env file
SKIPCASH_CLIENT_ID=''
SKIPCASH_KEY_ID=''
SKIPCASH_KEY_SECRET=''
SKIPCASH_WEBHOOK_KEY=''
SKIPCASH_URL='https://skipcashtest.azurewebsites.net'
#SKIPCASH_URL='https://api.skipcash.app'
Publish config skipcash helper if you want otherwise leave this command. It will create skipcash.php helper under config dir.
php artisan vendor:publish --tag=config
Run migration.
This will create skipcash_logs table where we will save logs from payment gateway.
php artisan migrate
There are two methods to use this package.
1. First method
You can use built in Trait in your controller:
use Shahzadthathal\Skipcash\Traits\SkipCashPaymentGatewayTrait;
use Shahzadthathal\Skipcash\Models\SkipcashLogs;
class YourPaymentController extends Controller{
use SkipCashPaymentGatewayTrait;
//Generate payment link
//http://127.0.0.1:8000/payment/generate-payment-link
$this->generatePaymentLinkSkipcash(Request $request){
//Your custom transaciton id or order id
$transactionId = 'xyz12345';
//Sequance of the fields is important, don't move keys
$requestData = [
"Uid" =>\Str::uuid()->toString(),
"KeyId"=> env('SKIPCASH_KEY_ID'),
"Amount" => "40.00",
'FirstName' => 'Muhammad',
'LastName' => 'Shahzad',
'Phone' => '+971507520175',
'Email' => 'shahzadthathal@gmail.com',
"TransactionId" => $transactionId,
"Custom1" => 'Custom1 anything',
// Add other required fields... i.e. Custom2
];
$responseSkipcashResponse = $this->generatePaymentLinkSkipcash($requestData);
$responseSkipcashArr = json_decode($responseSkipcashResponse, true);
if(isset($responseSkipcashArr['resultObj'])){
$payUrl = $responseSkipcashArr['resultObj']['payUrl'];
header('Content-Type: application/json; charset=utf-8');
header("Location:".$payUrl);
exit;
}
}
//Validate payment
//http://127.0.0.1:8000/payment/gateway/response/skipcash
//Please update above url in SkipCash payment portal in Return URL input box.
$this->validatePaymentSkipcash(Request $request){
$payment_id = $request->get('id');
//Save logs
$currentUrlWithParams = url()->full();
$skipcashLogs = new SkipcashLogs();
$skipcashLogs->user_id = \Auth::user()->id??0;
$skipcashLogs->logs = 'returning '.$currentUrlWithParams;
$skipcashLogs->save();
//Verify payment
$responseSkipcash = $this->validatePaymentSkipcash($payment_id);
$responseSkipcashArr = json_decode($responseSkipcash, true);
$resultObj = $responseSkipcashArr['resultObj'];
//Payment success
if(isset($resultObj['statusId']) && $resultObj['statusId']===2){
//Your custom transaciton id or order id from the payment gateway
$transactionId = $resultObj['transactionId'];
dd('transactionId '.$transactionId.' is verifid payment please update your order.');
}
}
//Webhook
//http://127.0.0.1:8000/payment/gateway/response/skipcash/webhook
//Please update above url in SkipCash payment portal in Webhook URL input box.
public function paymentGatewayResponseSkipcashWebhook(Request $request){
try{
$data = $request->all();
$skipcashLogs = new SkipcashLogs();
$skipcashLogs->user_id = 0;
$skipcashLogs->logs = 'webhook '.$data;
$skipcashLogs->save();
return response()->json(['message' => 'Success'], 200);
}catch(\Exception $e){
throw $e;
}
}
}
Please see \vendor\shahzadthathal\skipcash\src\Http\Controllers\SkipCashController.php for more methods.
2. Second method
php artisan vendor:publish --tag=routes
Above command will create a skipcash.php route file.
Please include skipcash.php in the end of the web.php route file.
require __DIR__.'/skipcash.php';
Create a new controller i.e. YourSkipCashController.php and update it in skipcash.php route file. Copy the content of \vendor\shahzadthathal\skipcash\src\Http\Controllers\SkipCashController.php and paste into your controller.
Now you can access these routes to generate pay link and verify payments.
http://127.0.0.1:8000/payment/generate-payment-link
http://127.0.0.1:8000/payment/gateway/response/skipcash
http://127.0.0.1:8000/payment/gateway/response/skipcash/webhook
shahzadthathal/skipcash 适用场景与选型建议
shahzadthathal/skipcash 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.04k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 shahzadthathal/skipcash 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shahzadthathal/skipcash 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-23