定制 david-maximous/fawrypay 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

david-maximous/fawrypay

Composer 安装命令:

composer require david-maximous/fawrypay

包简介

Laravel Payment helper for FawryPay

README 文档

README

Latest Version on Packagist Awesome MIT License Made With Love

Laravel Payment Helper for FawryPay/Fawry Accept

fawrypay.png

Supported methods

  • Pay By Reference Code
  • Pay By Credit/Debit Card
  • Pay By Mobile Wallet

Installation

composer require david-maximous/fawrypay

Publish Vendor Files

php artisan vendor:publish --tag="fawrypay-config"
php artisan vendor:publish --tag="fawrypay-lang"

//or use all for all configrations
php artisan vendor:publish --tag="fawrypay-all"

fawrypay.php config file

<?php
return [
    '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'),

    'VERIFY_ROUTE_NAME' => "verify-payment", //Route name for the payment verify route
    'APP_NAME'=>env('APP_NAME'),
];

How To Make payment request

use DavidMaximous\Fawrypay\Classes\FawryPayment;

$payment = new FawryPayment();

//pay function
$response = $payment->pay(
    $amount,
    $user_id,
    $user_name,
    $user_email,
    $user_phone,
    $language,
    $method,
    $item,
    $quantity,
    $description,
    $itemImage
);

//or use
$response = $payment->setUserId($user_id)
->setUserName($user_full_name)
->setUserEmail($user_email)
->setUserPhone($user_phone)
->setMethod($method)    //Optional, Use PayAtFawry/MWALLET/CARD
->setLanguage($language) //Optional, Default is en-gb
->setItem($item_name) //Optional, Default is 1
->setQuantity($quantity) //Optional, Default is 1
->setDescription($description) //Optional
->setItemImage($image_url)  //Optional
->setAmount($amount)
->pay();

dd($response);
//pay function response 
[
	'payment_id'=>"", // refrence code that should stored in your orders table
	'redirect_url'=>"", // redirect url to the payment page
]

How To Make verify request

  • Use only one of the following methods:
  1. Server Notifications (Webhook/Callback Request) [Recommended]
use DavidMaximous\Fawrypay\Classes\FawryVerify;

//This method is used for sending the payment status directly to your server, better for payment methods that have pending status (Pay by Reference Code) to get updated when it's paid
$verify = new FawryVerify();

//verify callback function
$response = $payment->verifyCallback($verify);

dd($response);
//Success/Paid output
[
    'success'=>true,//or false
    'payment_id'=>"PID",
    'message'=>"Done Successfully",//message for client
    'process_data'=>""//fawry response
]

Web.php MUST Have Route with name “verify-payment” and another route for Callback

Route::get('/payments/verify/{payment?}',[PaymentController::class,'payment_verify'])->name('verify-payment'); //Should redirect a user to a pending/confirmation page after finishing the payment
Route::post('/payments/Callback',[PaymentController::class,'verifyCallback'])->name('verify-payment-callback'); //This route should be provided to Fawry in order to use it as your notification endpoint
  1. Get Payment Status (Manual Verification)
use DavidMaximous\Fawrypay\Classes\FawryVerify;

//This method is for verifying payment after the user gets redirected back to your website, should be used inside the verify route function
$verify = new FawryVerify();

//verify function
$response = $payment->verify($verify);

dd($response);
//outputs
[
	'success'=>true,//or false
    'payment_id'=>"PID",
	'message'=>"Done Successfully",//message for client
	'process_data'=>""//fawry response
]

//For manually checking the payment status, please use the following method
$response = $payment->getPaymentStatus($payment_id);
dd($response);
//outputs
[
    'status'=>"PAID", //or New, CANCELED, REFUNDED, EXPIRED, PARTIAL_REFUNDED, FAILED
    'process_data'=>""//fawry response
]

Web.php MUST Have Route with name “verify-payment”

Route::get('/payments/verify/{payment?}',[PaymentController::class,'payment_verify'])->name('verify-payment'); //In this case the user should be redirected to a verify function that calls the verify function mentioned above 

For more information, please check the official documentation

Security

If you discover any security-related issues, please email security@davidmaximous.me instead of using the issue tracker.

david-maximous/fawrypay 适用场景与选型建议

david-maximous/fawrypay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 109 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「fawry」 「online payments」 「fawrypay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 david-maximous/fawrypay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 david-maximous/fawrypay 我们能提供哪些服务?
定制开发 / 二次开发

基于 david-maximous/fawrypay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 109
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-21