PHP code example of yoshocon / yoshocon-spgateway

1. Go to this page and download the library: Download yoshocon/yoshocon-spgateway 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/ */

    

yoshocon / yoshocon-spgateway example snippets


'providers' => [
    // ...
    Yoshocon\Spgateway\SpgatewayServiceProvider::class,
],
'aliases' => [
    // ...
    'MPG' => Yoshocon\Spgateway\Facades\MPG::class,
    'Receipt' => Yoshocon\Spgateway\Facades\Receipt::class,
    'Refund' => Yoshocon\Spgateway\Facades\Refund::class,
    'Transfer' => Yoshocon\Spgateway\Facades\Transfer::class,
],
shell
php artisan vendor:publish --provider="Yoshocon\Spgateway\SpgatewayServiceProvider"

// 產生智付通開立發票資料
$receipt = Receipt::generate([
    'BuyerName'       => 'Leo',
    'TotalAmt'        => 10,
    'ItemName'        => [1],
    'ItemCount'       => [1],
    'ItemUnit'        => ['式'],
    'ItemPrice'       => [10],
]);

// $receipt的 getPostData() 及 getPostDataEncrypted 會回傳即將傳送到智付通的表單資料,可在此時紀錄log

// 送出開立發票申請,取得發票開立回傳結果
$res = $receipt->send();

$res = $receipt->search('20171121WJNBX5NNBP', 100);