1. Go to this page and download the library: Download chadpeng/laravel-ecpay 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/ */
chadpeng / laravel-ecpay example snippets
artisan vendor:publish --tag=ecpay
use ChadPeng\ECPay\Checkout;
class CheckoutController extends Controller
{
protected $checkout;
public function __construct(Checkout $checkout)
{
$this->checkout = $checkout;
}
public function sendOrder()
{
$formData = [
'UserId' => 1, // 用戶ID , Optional
'ItemDescription' => '產品簡介',
'ItemName' => 'Product Name',
'TotalAmount' => '2000',
'PaymentMethod' => 'Credit', // ALL, Credit, ATM, WebATM
];
return $this->checkout->setPostData($formData)->send();
}
use ChadPeng\ECPay\QueryTradeInfo;
class QueryTradeController extends Controller
{
protected $queryTradeInfo;
public function __construct(QueryTradeInfo $queryTradeInfo)
{
$this->queryTradeInfo = $queryTradeInfo;
}
public function queryInfo($orderId)
{
return $this->queryTradeInfo->getData($orderId)->query();
}
}
use ChadPeng\ECPay\QueryInvoice;
class QueryInvoiceController extends Controller
{
protected $queryInvoice;
public function __construct(QueryInvoice $queryInvoice)
{
$this->queryInvoice = $queryInvoice;
}
public function queryInvInfo($orderId)
{
return $this->queryInvoice->getData($orderId)->query();
}
}