aqshah20/mezpay 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

aqshah20/mezpay

Composer 安装命令:

composer require aqshah20/mezpay

包简介

MezPay: A seamless Laravel payment gateway package empowering secure Meezan Bank payment processing. Simplify integration with Meezan Bank's E-commerce Payment Gateway for effortless transactions, supporting Stripe, PayPal, Braintree, and more.

README 文档

README

License

Introduction

MezPay is a seamless Laravel payment gateway package that empowers secure Meezan Bank payment processing. It simplifies the integration process with Meezan Bank's E-commerce Payment Gateway, allowing you to perform effortless and secure transactions.

This package is proudly developed by AQ Shah, a full-stack Laravel developer, with a passion for creating efficient and reliable solutions for payment processing in Laravel applications.

How to Set Up

Step 1: Install Package

You can install the MezPay package via Composer. Open your terminal and run the following command:

composer require aqshah20/mezpay

Step 2: Register MezPay Service Provider

After installing the package, you need to register the MezPay service provider in your Laravel application. Open config/app.php and add the following line to the providers array:

'providers' => [
    // Other service providers...
    MezPay\MezPayServiceProvider::class,
]

Step 3: Publish Configuration and Migrations:

To publish the configuration and migrations for the MezPay package, run the following Artisan commands in your terminal:

php artisan vendor:publish --tag=config

php artisan vendor:publish --tag=mezpay-migrations --ansi

php artisan migrate

After publishing, you can set your API credentials in the generated configuration file located at config/mezpay.php:

return [
    'username' => env('MEZPAY_USERNAME', ''),
    'password' => env('MEZPAY_PASSWORD', ''),
    'success_callback' => env('MEZPAY_SUCCESS_CALLBACK', ''),
    'failed_callback' => env('MEZPAY_FAILED_CALLBACK', ''),
];

Configuration

You can customize the package by adjusting the following settings in the config/mezpay.php file:

return [
    'username' => env('MEZPAY_USERNAME', ''),
    'password' => env('MEZPAY_PASSWORD', ''),
    'success_callback' => env('MEZPAY_SUCCESS_CALLBACK', 'success'),
    'failed_callback' => env('MEZPAY_FAILED_CALLBACK', 'failed'),
];

Handling Payment Callbacks

After configuring the MezPay package, you need to create routes to handle the payment success and failure callbacks.

Step 1: Create Routes

In your routes/web.php file, add the following routes to handle the payment success and failure callbacks:

use App\Http\Controllers\OrdersController;

Route::get('/success/{orderId?}', [OrdersController::class, 'orderSucceeded'])->name('success');
Route::get('/failed/{orderId?}', [OrdersController::class, 'orderFailed'])->name('failed');

Step 2: Implement Controller Methods

Next, create the OrdersController if you haven't already. In the controller, implement the orderSucceeded and orderFailed methods to process the payment callback responses:

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class OrdersController extends Controller
{
    public function orderSucceeded(Request $request)
    {
        // Get the orderId from the URL parameter or any other source as needed
        $orderId = $request->orderId;

        // Perform actions for successful payment
        // For example, update order status, send notifications, etc.

        // You can also pass the $orderId to a view if needed
        return view('success', compact('orderId'));
    }

    public function orderFailed(Request $request)
    {
        // Get the orderId from the URL parameter or any other source as needed
        $orderId = $request->orderId;

        // Perform actions for failed payment
        // For example, update order status, send notifications, etc.

        // You can also pass the $orderId to a view if needed
        return view('failed', compact('orderId'));
    }
}

How to Use:

To use MezPay, follow these steps:

Step 1: Import MezPayFacade

Import the MezPayFacade at the top of the controller or model file where you want to use it:

use MezPay\Facade\MezPayFacade;

Step 2: Register an Order:

Register an order with the minimum required parameters using the registerOrder method:

$paymentGateway = MezPayFacade::registerOrder([
    'order_id' => 152,
    'currency' => 586, // 586 = PKR | 540 = USD
    'amount' => 2000,
]);

Order Registration and Payment

After a user successfully registers an order, they will be redirected to a checkout screen where they can enter their card details to proceed with the payment. An example of this checkout screen can be seen in the following image:

Payment Status Redirection

Upon completing the checkout and submitting their payment details:

  • If the payment is successful, the user will be automatically redirected to the success route, where they will receive a confirmation message and any additional relevant information.
  • In the event of a payment failure, the user will be redirected to the failed route, where they will receive a notification and further instructions.
  • It is essential to properly configure these redirection routes in your application to handle the payment status and provide the appropriate responses to the user based on the outcome of the payment process.

Ensure that the redirection routes are correctly set up to provide a seamless and user-friendly payment experience for your users.

How to Get Order Status:

To obtain the order status, simply call the getOrderStatus(152) method with the orderId as a parameter.

// Call getOrderStatus method with orderId
$response = MezPayFacade::getOrderStatus(152);

// Dump the response for debugging
dd($response);

After making the call, you will receive the result as an array, similar to the following:

array:17 [
  "errorCode" => "0"
  "errorMessage" => "Success"
  "orderNumber" => "152"
  "orderStatus" => 2
  "actionCode" => 0
  "actionCodeDescription" => "Request processed successfully"
  "amount" => 2000
  "currency" => "586"
  "date" => 1689879175356
  "ip" => "39.57.43.95"
  "merchantOrderParams" => array:3 [▶]
  "attributes" => array:1 [▶]
  "cardAuthInfo" => array:3 [▶]
  "authDateTime" => 1689879256478
  "terminalId" => "10007077"
  "authRefNum" => "000025936268"
  "fraudLevel" => 0
]

License

This MezPay package is open-source software licensed under the MIT License. See the LICENSE file for more information.

Contributions and Feedback

Contributions, issues, and feedback are welcome! If you encounter any problems or have suggestions for improvements, please feel free to create an issue on GitHub

Thank you for choosing MezPay to simplify your integration with Meezan Bank's payment gateway. We hope this package streamlines your payment processing and enhances the security of your transactions. If you have any questions or need further assistance, please don't hesitate to reach out. Happy coding!

aqshah20/mezpay 适用场景与选型建议

aqshah20/mezpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 88 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 07 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 aqshah20/mezpay 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 88
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-22