This package is abandoned and no longer maintained. No replacement package was suggested.

AIo - Allpay, Ecpay Laravel 5 version

Installs: 120

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 1

Open Issues: 0

Type:ectool

1.0.8 2018-04-03 08:20 UTC

This package is auto-updated.

Last update: 2020-05-16 11:55:10 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads

Aio - Laravel 5 version

It is a fork from ScottChayaa/Allpay package

step 1 : Download the package

composer命令安裝

composer require kevin50406418/aio

或者是新增package至composer.json

"require": {
  "kevin50406418/aio": "^1.0.0"
},

然後更新安裝

composer update

或全新安裝

composer install

step 2 : Modify config file

增加config/app.php中的providersaliases的參數,依需求加上

Allpay:

'providers' => [
  // ...
  Kevin50406418\Aio\AllpayServiceProvider::class,
]

'aliases' => [
  // ...
  'Allpay' => Kevin50406418\Aio\Facade\Allpay::class,
]

Ecpay:

'providers' => [
  // ...
  Kevin50406418\Aio\EcpayServiceProvider::class,
]

'aliases' => [
  // ...
  'Ecpay' => Kevin50406418\Aio\Facade\Ecpay::class,
]

#### step 3 : Publish config to your project 執行下列命令,將package的config檔配置到你的專案中

Allpay:

php artisan vendor:publish --provider=Kevin50406418\Aio\AllpayServiceProvider

Ecpay:

php artisan vendor:publish --provider=Kevin50406418\Aio\EcpayServiceProvider

可至config/allpay.php 或 config/ecpay.php中查看 預設是測試Allpay/Ecpay設定

return [
    'ServiceURL' => 'http://payment-stage.allpay.com.tw/Cashier/AioCheckOut',
    'HashKey'    => '5294y06JbISpM5x9',
    'HashIV'     => 'v77hoKGq4kWxNNIS',
    'MerchantID' => '2000132',
];

How To Use

Allpay:

use Allpay;

Ecpay:

use Ecpay;
public function Demo()
{
    //Official Example : 
    //https://github.com/allpay/PHP/blob/master/AioSDK/example/sample_Credit_CreateOrder.php
    
    //基本參數(請依系統規劃自行調整)
    Allpay::i()->Send['ReturnURL']         = "http://www.allpay.com.tw/receive.php" ;
    Allpay::i()->Send['MerchantTradeNo']   = "Test".time() ;           //訂單編號
    Allpay::i()->Send['MerchantTradeDate'] = date('Y/m/d H:i:s');      //交易時間
    Allpay::i()->Send['TotalAmount']       = 2000;                     //交易金額
    Allpay::i()->Send['TradeDesc']         = "good to drink" ;         //交易描述
    Allpay::i()->Send['ChoosePayment']     = \PaymentMethod::ALL ;     //付款方式

    //訂單的商品資料
    array_push(Allpay::i()->Send['Items'], array('Name' => "歐付寶黑芝麻豆漿", 'Price' => (int)"2000",
               'Currency' => "", 'Quantity' => (int) "1", 'URL' => "dedwed"));

    //Go to AllPay
    echo "歐付寶頁面導向中...";
    echo Allpay::i()->CheckOutString();
}

用laravel的人開發盡量使用CheckOutString()回傳String的方法
當然使用CheckOut()也是可以
但如果使用的話,我猜後面可能會碰到Get不到特定Session的問題

歐付寶回傳頁面時會使用到這個方法
使用方法 ex:

public function PayReturn(Request $request)
{
    /* 取得回傳參數 */
    $arFeedback = Allpay::i()->CheckOutFeedback($request->all());
    //...
}

注意要傳入$request->all()
因為官方原本的方法是帶入$_POST → Laravel 5 不鳥你這個,所以會出錯
固做此修正
不過這部分沒有多做說明,留給大家試試看