mu-hasan/laravel-winpay 问题修复 & 功能扩展

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

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

mu-hasan/laravel-winpay

Composer 安装命令:

composer require mu-hasan/laravel-winpay

包简介

A package that integrate WinPay Payment Gateway with Laravel Framework

README 文档

README

A non-official package that help you to implements WinPay Payment Gateway (winpay.id) into your Laravel applications

Installation

Install the package via composer :

$ composer require mu-hasan/laravel-winpay "^0.0.1"

Add this lines into your .env file and fill with your WinPay credentials :

# ...
WINPAY_HOST=putWinpayHostHere
WINPAY_PK1=putWinpayPrivateKey1Here
WINPAY_PK2=putWinpayPrivateKey2Here
WINPAY_MK=putWinpayMerchantKeyHere
WINPAY_LISTENER=putWinpayListenerPathHere

Laravel

Please register the service provider :

// config/app.php
'Providers' => [
    // ...
    /*
     * Package Service Providers...
     */
    MuHasan\LaravelWinpay\WinpayServiceProvider::class,
    // ...
]

You could use the facade by add this line :

// config/app.php
'aliases' => [
    // ...
    'Winpay' => MuHasan\LaravelWinpay\WinpayFacade::class,
];

Please publish the config file to define your WinPay credentials :

$ php artisan vendor:publish --provider="MuHasan\LaravelWinpay\WinpayServiceProvider"

Lumen

Please add this line to the bootstrap/app.php file

$app->configure('laravel-winpay');
//...
$app->register(MuHasan\LaravelWinpay\WinpayServiceProvider::class);

You could get the config file from this laravel-winpay.php. Then copy it into config/laravel-winpay.php

Send Request to WinPay

For now, this package only support getToolbar and getPaymentCode.

getToolbar

From the documentation, this function will be return list of payment channel. You can use like this:

winpay()->getToolbar();
// OR
Winpay::getToolbar();

getPaymentCode

From the documentation, this function will be return payment code of choosen payment channel and transaction details. You can use like this:

winpay()->getPaymentCode($paymentChannel, $transaction, $user, $items);
// OR
Winpay::getToolbar($paymentChannel, $transaction, $user, $items);

You must passing $paymentChannel parameter from one of getToolbar() response.

The $transaction parameter you must passing the model that implements MuHasan\LaravelWinpay\BillingTransaction interface and define the getBillTransactionEndAt(), getBillTransactionReff(), and getBillTransactionAmount() functions into it.

class FooTransaction extends Model implements BillingTransaction
{
    //...
    public function getBillTransactionEndAt(): \DateTime
    {
        return $this->reff;
    }

    public function getBillTransactionReff(): string
    {
        return $this->reff;
    }

    public function getBillTransactionAmount(): int
    {
        return $this->total;
    }
    //...
}

The $user parameter you must passing the model that implements MuHasan\LaravelWinpay\BillingUser interface and define the getgetBillUserName(), getgetBillUserPhone(), and getgetBillUserEmail() functions into it.

class FooUser extends Model implements BillingUser
{
    //...
    public function getBillUserName(): string
    {
        return $this->name;
    }

    public function getBillUserPhone(): string
    {
        return $this->phone;
    }

    // nullable
    public function getBillUserEmail(): ?string
    {
        return $this->email;
        // OR
        // return null;
    }
    //...
}

The $items parameter you must passing array of the model that implements MuHasan\LaravelWinpay\BillingItem interface and define the getBillItemName(), getBillItemQty(), getBillItemUnitPrice(), getBillItemSku(), and getBillItemDesc() functions into it.

class FooItem extends Model implements BillingItem
{
    //...
    public function getBillItemName(): string
    {
        return $this->name;
    }

    public function getBillItemQty(): int
    {
        return $this->qty;
    }

    public function getBillItemUnitPrice(): int
    {
        return $this->amount;
    }

    // nullable
    public function getBillItemSku(): ?string
    {
        return $this->short_id;
        // OR
        // return null;
    }

    // nullable
    public function getBillItemDesc(): ?string
    {
        return $this->note;
        // OR
        // return null;
    }
    //...
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固