maras0830 / laravel-paynow
Laravel 5 for paynow.
Installs: 10 618
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 5
Open Issues: 0
Requires
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- ext-soap: *
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-03 10:09:18 UTC
README
https://github.com/Maras0830/laravel-paynow
ToDo
- CreditCard Backend Single Transaction
- Transaction Check
- Subscription
- Installment
- 3-Domain Secure
- Callback Check
Installation
Enable php extension soap http://php.net/manual/en/book.soap.php
composer require
$ composer require maras0830/laravel-paynow"
add to config/app.php
'providers' => [ // .... Maras0830\PayNowSDK\Providers\PayNowServiceProvider::class ],
publish config file to config/paynow.php
$ php artisan vendor:publish --provider=Maras0830\PayNowSDK\Providers\PayNowServiceProvider
in .env
PAYNOW_DEBUG_MODE=true PAYNOW_WEB_NO= PAYNOW_PASSWORD= PAYNOW_EC_NAME= PAYNOW_ENCRYPT_KEY= PAYNOW_IV= PAYNOW_CARDINAL=
Usage
測試卡號: 4025950011112222 有效年月: 12/12 安全碼:999
- CreditCard backend transaction
$now = \Carbon\Carbon::now('Asia/Taipei'); $transaction = new Maras0830\PayNowSDK\CreditCardTransaction($now); $card_number = '4023730207292803'; $valid_year = '20'; $valid_month = '05'; $safe_code = '685'; // $res is transaction response. $res = $transaction ->setEncrypt() ->setOrder('測試交易', 'OWLTEST1000111002', 100) // orderinfo strlen > 3 ->setCreditCard($card_number, $valid_year, $valid_month, $safe_code) ->setCustomer(1, 'Eric', '09121212121212', 'test@test.com', '127.0.0.1') ->checkout() ->decodeAndValidate();
- Transaction Check
$my_order_number = 'TEST10001'; $sdk = new Maras0830\PayNowSDK\PayNowAPI(); /** * @throws Maras0830\PayNowSDK\Exceptions\OrderNotFoundException * @throws Maras0830\PayNowSDK\Exceptions\TransactionException * @throws Maras0830\PayNowSDK\Exceptions\OrderIsCancelException * @throws Maras0830\PayNowSDK\Exceptions\UnKnownException */ $res = $sdk->transactionCheck($my_order_number); /** $res => [ 'order_number' => 'xxxxx' // Paynow Order number 'last4' => 'xxxx' // CreditCard last4 code ]; **/
- Subscription
First Transaction
$now = Carbon\Carbon::now('Asia/Taipei'); $transaction = new Maras0830\PayNowSDK\CreditCardTransaction($now); $card_number = '4023730207292803'; $valid_year = '22'; $valid_month = '05'; $safe_code = '685'; $account = 'account'; $password = 'password'; /** * @throws Maras0830\PayNowSDK\Exceptions\PayNowException * @throws Maras0830\PayNowSDK\Exceptions\ValidateException * @throws Maras0830\PayNowSDK\Exceptions\TransactionException */ $res = $transaction ->setEncrypt() ->setOrder('測試交易', 'TEST123' . time(), 100) // orderinfo strlen > 3 ->setCreditCard($card_number, $valid_year, $valid_month, $safe_code) ->setCustomer(1, 'Eric', '09121212121212', 'test@test.com', '127.0.0.1', $account, $password) ->checkoutAndSaveCard() ->decodeAndValidate(); /** $res = [ "WebNo" => "70828783" "TotalPrice" => 100 "OrderNo" => "TEST1231593574222" "ECPlatform" => null "BuySafeNo" => "8000002007014585819" "TranStatus" => "S" "PassCode" => "FDEA87E80373A00FAD48C89AD5BA32A954675678" "RespCode" => "00" "ResponseMSG" => "" "ApproveCode" => "A00001" "last4CardNo" => "2803" "CheckNo" => null "InvoiceNo" => null "batchNo" => null "InvoiceStatus" => null "Result3D" => "" "CIFID_SN" => "1" // 該卡 token, 請保存 "ReturnURL" => null "ErrorMessage" => "" ] */
Others Transaction
$now = Carbon\Carbon::now('Asia/Taipei'); $transaction = new Maras0830\PayNowSDK\CreditCardTransaction($now); $account = 'account'; $password = 'password'; $card_sn = '123'; // CIFID_SN $res = $transaction ->setEncrypt() ->setOrder('測試交易', 'TEST123' . time(), 100) // orderinfo strlen > 3 ->setCustomer(1, 'Eric', '09121212121212', 'test@test.com', '127.0.0.1', $account, $password) ->checkoutBySN($card_sn) // safe_code can use 'XXX' ->decodeAndValidate(); /** $res = [ "WebNo" => "70828783" "TotalPrice" => 100 "OrderNo" => "TEST1231593574222" "ECPlatform" => null "BuySafeNo" => "8000002007014585819" "TranStatus" => "S" "PassCode" => "FDEA87E80373A00FAD48C89AD5BA32A954675678" "RespCode" => "00" "ResponseMSG" => "" "ApproveCode" => "A00001" "last4CardNo" => "2803" "CheckNo" => null "InvoiceNo" => null "batchNo" => null "InvoiceStatus" => null "Result3D" => "" "CIFID_SN" => "1" // 該卡 token, 請保存 "ReturnURL" => null "ErrorMessage" => "" ] */
Refund Order
$payment_refund = new Maras0830\PayNowSDK\PaymentRefund(); $res = $payment_refund->refund( '8000001910145799460', '860.0000', '退款測試', 1, '', '', '', 'harley@gs8899.com.tw', 'Harley', 'harley@gs8899.com.tw' );