Downloads
Stars
Version
Laravel EZPay 為串接EZPay的非官方套件
composer require tsaiyihua/laravel-ezpay
php artisan vendor:publish --tag=ezpay
EZPAY_MERCHANT_ID=
EZPAY_HASH_KEY=
EZPAY_HASH_IV=
use TsaiYiHua\EZPay\MPG;
class MpgController extends Controller
{
public function __construct(MPG $mpg)
{
$this->mpg = $mpg;
}
...
public function sendOrder()
{
$data = [
'itemName' => 'Donate',
'amount' => 50
];
return $this->mpg->createOrder($data);
}
use TsaiYiHua\EZPay\Collections\QueryResponseCollection;
use TsaiYiHua\EZPay\Query;
class QueryController extends Controller
{
protected $query;
protected $queryResponse;
public function __construct(Query $query, QueryResponseCollection $queryResponse)
{
$this->query = $query;
$this->>queryResponse = $queryResponse;
}
...
public function queryInfo()
{
$res = $this->query->queryInfo('18120414321996244');
return $this->queryResponse->collectResponse($res);
}
use TsaiYiHua\EZPay\Collections\InvoiceResponseCollection;
use TsaiYiHua\EZPay\Invoice;
class InvoiceController extends Controller
{
...
public function __construct(Invoice $invoice, InvoiceResponseCollection $invResponse)
{
$this->invoice = $invoice;
$this->invResponse = $invResponse;
}
...
public function issueInvoice()
{
$itemData[] = [
'name' => 'Donate',
'qty' => 1,
'unit' => '次',
'price' => 500
];
$invData = [
'orderId' => StringService::identifyNumberGenerator('O'),
'items' => $itemData,
'BuyerName' => 'Buyer Name',
'BuyerEmail' => '[email protected]',
'LoveCode' => 919
];
return $this->invResponse->collectResponse($this->invoice->issueInvoice($invData)->query());
}