mingjshk / laravel-newebpay

台湾蓝新(智付通) Laravel API

1.0.2 2021-03-04 05:57 UTC

This package is not auto-updated.

Last update: 2024-09-26 22:35:30 UTC


README

ycs77/laravel-newebpay 分支

Latest Stable Version Total Downloads License

Laravel NewebPay 是为 Laravel 编写的支付套件,主要实现蓝新支付(原智付通)功能。Now Support Laravel 8

主要实现项目:

  • NewebPay MPG - 多功能收款
  • NewebPay Cancel - 信用卡取消授权
  • NewebPay Close - 信用卡退款
  • NewebPay Period - 信用卡定期定额委托
  • NewebPay Alter Period Status - 信用卡定期定额委托修改状态
  • NewebPay Alter Period Amt - 信用卡定期定额修改委托

安装

composer require mingjshk/laravel-newebpay

注册套件

Laravel 5.5以上会自动注册套件,可以跳过此步骤

config/app.php注册套件和增加别名:

    'providers' => [
        ...

        /*
         * Package Service Providers...
         */
        MingJSHK\NewebPay\NewebPayServiceProvider::class,

        ...
    ],

    'aliases' => [
        ...

        'NewebPay' => MingJSHK\NewebPay\Facades\NewebPay::class,
    ]

发布设置文件

php artisan vendor:publish --provider="MingJSHK\NewebPay\NewebPayServiceProvider"

使用

设置.env文件

// .env

NEWEBPAY_MERCHANT_ID=""
NEWEBPAY_HASH_KEY=""
NEWEBPAY_HASH_IV=""
NEWEBPAY_DEBUG=true/false

NEWEBPAY_RETURN_URL=""
NEWEBPAY_NOTIFY_URL=""
NEWEBPAY_PERIOD_NOTIFY_URL=""
NEWEBPAY_CLIENT_BACK_URL=""

设置config/newebpay.php

可依据个人商业使用上做调整。

引用、初始化类:

use MingJSHK\NewebPay\NewebPay;

$newebpay = new NewebPay();

NewebPay MPG - 多功能支付

use MingJSHK\NewebPay\Facades\NewebPay;

function order() 
{
    return NewebPay::payment(
        no, // 訂單編號
        amt, // 交易金額
        desc, // 交易描述
        email // 付款人信箱
    )->submit();
}

基本上一般交易可直接在config/newebpay.php做设置,里面有详细的说明,但若遇到特殊情况,可依据个别交易做个别function设置。

use MingJSHK\NewebPay\Facades\NewebPay;

return NewebPay::payment(
    no, // 訂單編號
    amt, // 交易金額
    desc, // 交易描述
    email // 付款人信箱
)
    ->setRespondType() // 回傳格式
    ->setLangType() // 語言設定
    ->setTradeLimit() // 交易秒數限制
    ->setExpireDate() // 交易截止日
    ->setReturnURL() // 由藍新回傳後前景畫面要接收資料顯示的網址
    ->setNotifyURL() // 由藍新回傳後背景處理資料的接收網址
    ->setCutomerURL() // 商店取號網址
    ->setClientBackURL() // 付款取消後返回的網址
    ->setEmailModify() // 是否開放 email 修改
    ->setLoginType() // 是否需要登入智付寶會員
    ->setOrderComment() //商店備註
    ->setPaymentMethod() //付款方式 *依照 config 格式傳送*
    ->setCVSCOM() // 物流方式
    ->setTokenTerm() // 快速付款 token
    ->submit();

此版本1.5由蓝新支付回传后为加密讯息,所以回传后需要进行解码!

use Illuminate\Http\Request;
use MingJSHK\NewebPay\Facades\NewebPay;

function returnURL(Request $request)
{
    return NewebPay::decode($request->input('TradeInfo'));
}

NewebPay Cancel - 信用卡取消授权

use MingJSHK\NewebPay\Facades\NewebPay;

function creditCancel()
{
    return NewebPay::creditCancel(
        no, // 該筆交易的訂單編號
        amt,  // 該筆交易的金額
        'order' // 可選擇是由 order->訂單編號 或是 trade->藍新交易編號來做申請
    )->submit();
}

NewebPay Close - 信用卡退款

use MingJSHK\NewebPay\Facades\NewebPay;

function requestPayment()
{
    return NewebPay::requestPayment(
        no, // 該筆交易的訂單編號
        amt,  // 該筆交易的金額
        'order' // 可選擇是由 order->訂單編號 或是 trade->藍新交易編號來做申請
    )->submit();
}

NewebPay close - 信用卡退款

use MingJSHK\NewebPay\Facades\NewebPay;

function requestRefund()
{
    return NewebPay::requestRefund(
        no, // 該筆交易的訂單編號
        amt,  // 該筆交易的金額
        'order' // 可選擇是由 order->訂單編號 或是 trade->藍新交易編號來做申請
    )->submit();
}

NewebPay Period - 定期定额委托

use MingJSHK\NewebPay\Facades\NewebPay;

function period()
{
    return NewebPay::period(
            $no,        //訂單編號
            $amt,       //訂單金額
            $desc,      //產品名稱
            $type,      //週期類別 (D, W, M, Y)
            $point,     //交易週期授權時間
            $starttype, //檢查卡號模式
            $times,     //授權期數
            $email      //連絡信箱
        )->submit();
}

NewebPay Period Status - 修改定期定额委托状态

use MingJSHK\NewebPay\Facades\NewebPay;

function alterPeriodStatus()
{
    return NewebPay::alterStatus(
            $no,        //訂單編號
            $periodno,  //委託編號
            $type       //狀態類別 (suspend, terminate, restart)
        )->submitAndDecode('period');
}

NewebPay Period - 修改定期定额委托内容

use MingJSHK\NewebPay\Facades\NewebPay;

function alterPeriodAmt()
{
    return NewebPay::alterPeriodAmt(
            $no,        //訂單編號
            $periodno,  //委託編號
            $amt,       //訂單金額
            $type,      //週期類別 (D, W, M, Y)
            $point,     //交易週期授權時間
            $times,     //授權期數
            $extday     //信用卡到期日 (20215 月則填入『0521』)
        )->submitAndDecode('period');
}

官方参考

NewebPay Payment API

许可证

MIT