PHP code example of mingjshk / laravel-newebpay

1. Go to this page and download the library: Download mingjshk/laravel-newebpay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mingjshk / laravel-newebpay example snippets


    'providers' => [
        ...

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

        ...
    ],

    'aliases' => [
        ...

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

use MingJSHK\NewebPay\Facades\NewebPay;

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

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();

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

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

use MingJSHK\NewebPay\Facades\NewebPay;

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

use MingJSHK\NewebPay\Facades\NewebPay;

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

use MingJSHK\NewebPay\Facades\NewebPay;

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

use MingJSHK\NewebPay\Facades\NewebPay;

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

use MingJSHK\NewebPay\Facades\NewebPay;

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

use MingJSHK\NewebPay\Facades\NewebPay;

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

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