承接 danialpanah/webpay 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

danialpanah/webpay

Composer 安装命令:

composer require danialpanah/webpay

包简介

Laravel Package for Processing Online Payments Through Webpay Payment Gateway

README 文档

README

Build Status Latest Release on Packagist Software License

Introduction

Laravel package for connecting and accept payments via Webpay payment gateway in your Laravel application.

Installation

  • Use following command to install:
composer require danialpanah/webpay

This package supports Laravel auto-discovery feature. If you are using Laravel 5.5 or greater no need to do any further actions, otherwise follow below steps.

  • Add the service provider to your providers[] array in config/app.php in your laravel application:
DanialPanah\Webpay\WebpayServiceProvider::class
  • For using Laravel Facade add the alias to your aliases[] array in config/app.php in Laravel:
'Webpay': DanialPanah\Webpay\Facades\Webpay::class

Configuration

  • After installation, you need to add your Webpay api settings. You can update config/webpay.php published file or in you Laravel .env file.

  • Run the following command to publish the configuration file:

php artisan vendor:publish --provider "DanialPanah\Webpay\WebpayServiceProvider"
  • config/webpay.php
return [
    'api_key' => env('WEBPAY_API_KEY', ''),
    'callback_url' => env('WEBPAY_CALLBACK_URL', '')
];
  • Add this to .env.example and .env files:
#Webpay API key and Settings

#your webpay api key e.g "webpay:2bbc6c62-4fe..."
WEBPAY_API_KEY=

#address of rediricting after payment e.g "/payment/test"
WEBPAY_CALLBACK_URL=

Usage

Following are some approaches which you can have for initiate a payment through Webpay package:

  • Initiate Payment and Receive the Payment URL:
// Importing the class namespaces before using it
use DanialPanah\WebPay\Webpay;

$samplePayment = [
   'amount' => 10000,  //required
   'reference_number' => '#####',  //required - invoice number(unique)
   'payer_mobile' => '',  //optional - payer mobile number for save/load cards in gateway
   'cards' => '',  //optional - allowed cards for perform payment
];

$webPay = new Webpay();
$paymentUrl = $webPay->sendPayment($samplePayment);
  • Using Facades (Initiate Payment):
use DanialPanah\WebPay\Facades\Webpay;

$paymentUrl = Webpay::sendPayment($samplePayment);
  • Verify Payment:
$paymentDetails = [
   'amount' => 10000,  //required
   'reference_number' => '#####'  //required - invoice number
];

$webPay = new Webpay();
$response = $webPay->verifyPayment($paymentDetails);
  • Using Facades (Verify Payment):
use DanialPanah\WebPay\Facades\Webpay;

$response = Webpay::verifyPayment($paymentDetails);
  • Sample Response of Verify Successful Payment:
array: [
  "ok" => true
  "result" => {
      "state": "paid"
      "total": 10000
      "wage": 1500
      "gateway": "sep"
      "terminal": "11423087"
      "pay_ref": "KmsctypmKSs0WfEB01H3ROJPLN2ZQrauExLR90nnXk"
      "pay_trace": "228945"
      "pay_pan": "610422******8585"
      "pay_cid": "4470D3E90AA5Z3FB7B21B3348D34EE25EC331915BCQP68BC4D0D1C0678548B8D"
      "pay_time": "2020-04-02T17:47:14.391164Z"
  }
]
  • Laravel Sample Controller:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DanialPanah\WebPay\Facades\Webpay;

class PaymentController extends Controller
{
    /**
     * @return RedirectResponse|Redirector
     * @throws WebpayException
     */    
     public function pay()
    {
        $userTrustedCards = ['6219196262191962', '6104046161040461'];

        $samplePayment = [
           'amount' => 10000,
           'reference_number' => '999999',
           'payer_mobile' => '09121111111',
           'cards' => $userTrustedCards,
        ];

        $paymentUrl = Webpay::sendPayment($samplePayment);

        return redirect($paymentUrl);
    }


    /**
     * @param Request $request
     * @throws VerifyException
     */
    public function verify(Request $request)
    {
        $paymentDetails = [
            'amount' => 10000,
            'reference_number' => '999999',
        ];

        $response = Webpay::verifyPayment($paymentDetails);

        if(!$reponse['ok'] === true) {
            //Transactions was not successful
        }

        //Do something for successful transactoin

    }
}

Support & Security

This package supports Laravel 5.1 or greater, 6.x and 7.x with PHP 7.2 and above.

  • In case of discovering any issues, please create one on the Issues section.
  • For contribution, fork this repo and implements your code then create a PR.

License

This repository is an open-source software under the MIT license.

danialpanah/webpay 适用场景与选型建议

danialpanah/webpay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-03