Download the PHP package knckff-roychang/laravel-newebpay without Composer

On this page you can find all versions of the php package knckff-roychang/laravel-newebpay. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-newebpay

Laravel 套件,台灣藍新金流(智付通)企業會員金流串接

Installation

(1)用 composer 安裝套件

composer require KNCKFF/laravel-newebpay

(2)建立資料表

php artisan migrate

(3)設定藍新金流的商店資訊參數到 .env 檔

php artisan newebpay:init  

Usage

在你要呈現訂單頁面的控制器中,用 create 方法產生結帳按鈕會用到的資料,並指派給前端的 blade 模版即可,範例如下:
(1)控制器

use KNCKFF\LaravelNewebpay\Library\NewebPay;

$newebpay = NewebPay::create([
    // 必填參數
    'MerchantOrderNo' => 訂單編號(不可重覆),  // 例:a00001
    'Amt' => 訂單總金額,  // 例:150
    'ItemDesc' => 商品資訊,  // 例:測試商品
    'Email' => 付款人電子信箱,  // 例:[email protected]

    // 支付完成後,藍新傳送支付記錄的網址,此套件已寫好不必再指定。
    // 但如果你還是想自訂,就如下行去指定。但路由、控制器內容及存入資料表須行自編寫
    'NotifyURL' => 支付完成的網址,  // 例:http://www.example.com/notifyRes

    // 取號完成轉址的網址,此套件已寫好不必再指定。
    // 但如果你還是想自訂,就如下行去指定。但路由、控制器內容及存入資料表須行自編寫
    'CustomerURL' => 取號完成的網址,  // 例:http://www.example.com/customerRes 

    // 可選參數
    'ClientBackURL' => 返回商店按鈕的連結網址,  // 例:http://www.example.com/shop/123
]);

return view(你訂單頁面的 blade 模版, [
    'newebpay' => $newebpay,  // newebpay 這個 key 名不要改掉
    ... 頁面其他資料的變數,以下省略 ...
]);

註1:交易資料參數必填的欄位,只剩範例中 MerchantOrderNo、Amt、ItemDesc、Email 這四項需要指定  
註2:可選參數,像是返回商店按鈕的連結網址、限制信用卡分期的期數等等,依你專案需要額外去指定  
註3:各項交易資料的參數名稱,皆與官方文件相同

(2)前端呈現訂單資料的頁面中,把按鈕元件放在你想要的位置即可

@component('newebpay::tradeButton', [
    'newebpay' => $newebpay,
    'button' => '<button type="submit" class="button is-success">前往結帳</button>',
])
@endcomponent

註:按鈕的 HTML Tag,可以依你的喜好去更改,直接修改 button 的值即可

(3)取號完成轉址的 blade 模版名稱(不須副檔名 .blade.php),請直接設定在 .env 檔的「NEWEBPAY_CUSTOMER_BLADE」參數。從藍新傳來的資料都會在 $log 這個 Eloquent 實例中(它查詢了 newebpay_customers 資料表),你可以在自己的 blade 使用此物件。例如:

<li>取號狀態及錯誤代碼:{{ $log->Status }}</li>
<li>訂單編號:{{ $log->MerchantOrderNo }}</li>
<li>交易金額:{{ $log->Amt }}</li>
<li>藍新交易序號:{{ $log->TradeNo }}</li>
<li>商店代號:{{ $log->MerchantID }}</li>
<li>繳費截止日期:{{ $log->ExpireDate }}</li>
<li>支付方式:{{ $log->PaymentType }}</li>

(4)支付完成的記錄在 newebpay_notifies 資料表中,控制器中可以用 Eloquent 的方式讀取資料,例如:

use KNCKFF\LaravelNewebpay\Models\NewebpayNotify;

$notify = NewebpayNotify::all();

(5)取號完成的記錄在 newebpay_customers 資料表中,你控制器可以用 Eloquent 的方式讀取資料,例如:

use KNCKFF\LaravelNewebpay\Models\NewebpayCustomer;

$customer = NewebpayCustomer::all();

Test

(1)此套件有提供測試交易資料的表單,供你填部份欄位來擬模交易的流程,配合官方文件了解一些交易資料參數的用處
請修改 .env 檔中下列的參數:

(1)NEWEBPAY_ENV 的值設為 dev (要關閉此測試表單,把此值設為 prod 即可)
(2)NEWEBPAY_MERCHANT_ID、NEWEBPAY_HASH_KEY、NEWEBPAY_HASH_IV 要設為藍新測試站商店的資料
(3)APP_URL 的值要設定專案的域名
(4)NEWEBPAY_CUSTOMER_BLADE 的值要用測試的模版名 newebpay::testCustomerRes

之後瀏覽器連結:

你的網域/newebpay/test/tradeForm 

All versions of laravel-newebpay with dependencies

PHP Build Version
Package Version
Requires php Version ^7.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package knckff-roychang/laravel-newebpay contains the following files

Loading the files please wait ....