├── CHANGELOG.md ├── README.md ├── composer.json ├── example ├── Invoice │ ├── B2B │ │ ├── Allowance.php │ │ ├── AllowanceConfirm.php │ │ ├── CancelAllowance.php │ │ ├── CancelAllowanceConfirm.php │ │ ├── GetAllowance.php │ │ ├── GetAllowanceConfirm.php │ │ ├── GetAllowanceInvalid.php │ │ ├── GetAllowanceInvalidConfirm.php │ │ ├── GetInvalid.php │ │ ├── GetInvalidConfirm.php │ │ ├── GetInvoiceWordSetting.php │ │ ├── GetIssue.php │ │ ├── GetIssueConfirm.php │ │ ├── GetReject.php │ │ ├── GetRejectConfirm.php │ │ ├── Invalid.php │ │ ├── InvalidConfirm.php │ │ ├── Issue.php │ │ ├── IssueConfirm.php │ │ ├── MaintainMerchantCustomerData.php │ │ ├── Notify.php │ │ ├── Reject.php │ │ └── RejectConfirm.php │ └── B2C │ │ ├── Allowance.php │ │ ├── AllowanceByCollegiate.php │ │ ├── AllowanceInvalid.php │ │ ├── CancelDelayIssue.php │ │ ├── CheckBarcode.php │ │ ├── CheckLoveCode.php │ │ ├── DelayIssue.php │ │ ├── GetAllowance.php │ │ ├── GetAllowanceByCollegiateResponse.php │ │ ├── GetAllowanceInvalid.php │ │ ├── GetInvalid.php │ │ ├── GetInvoiceWordSetting.php │ │ ├── GetInvoicedResponse.php │ │ ├── GetIssue.php │ │ ├── Invalid.php │ │ ├── InvoiceNotify.php │ │ ├── Issue.php │ │ ├── TriggerIssue.php │ │ └── VoidWithReIssue.php ├── Logistics │ ├── AllInOne │ │ ├── B2C │ │ │ ├── CreateTestData.php │ │ │ ├── ReturnFamiCVS.php │ │ │ ├── ReturnHilifeCvs.php │ │ │ ├── ReturnUnimartCvs.php │ │ │ └── UpdateShipmentInfo.php │ │ ├── C2C │ │ │ ├── CancelC2cOrder.php │ │ │ └── UpdateStoreInfo.php │ │ ├── CreateByTempTrade.php │ │ ├── Home │ │ │ └── ReturnHome.php │ │ ├── LogisticsStatusNotify.php │ │ ├── PrintTradeDocument.php │ │ ├── QueryLogisticsTradeInfo.php │ │ ├── RedirectToLogisticsSelection.php │ │ ├── RedirectWithUnimartFreeze.php │ │ ├── TempTradeEstablishedResponse.php │ │ └── UpdateTempTrade.php │ ├── CrossBorder │ │ ├── CreateTestData.php │ │ ├── CreateUnimartCvsOrder.php │ │ ├── CreateUnimartHomeOrder.php │ │ ├── GetMapResponse.php │ │ ├── GetStatusChangedResponse.php │ │ ├── Map.php │ │ ├── Print.php │ │ └── QueryLogisticsTradeInfo.php │ ├── Domestic │ │ ├── CancelC2cOrder.php │ │ ├── CreateCvs.php │ │ ├── CreateCvsForm.php │ │ ├── CreateHome.php │ │ ├── CreateHomeForm.php │ │ ├── CreateTestData.php │ │ ├── CreateUnimartFreeze.php │ │ ├── GetCreateTestDataResponse.php │ │ ├── GetLogisticStatueResponse.php │ │ ├── GetMapResponse.php │ │ ├── GetReturnResponse.php │ │ ├── GetStoreList.php │ │ ├── Map.php │ │ ├── PrintFamic2cOrderInfo.php │ │ ├── PrintHilifec2cOrderInfo.php │ │ ├── PrintOkmartc2cOrderInfo.php │ │ ├── PrintTradeDocument.php │ │ ├── PrintUniMartc2cOrderInfo.php │ │ ├── QueryLogisticsTradeInfo.php │ │ ├── ReturnFamiCvs.php │ │ ├── ReturnHome.php │ │ ├── ReturnUniMartCvs.php │ │ ├── UpdateShipmentInfo.php │ │ └── UpdateStoreInfo.php │ ├── crossborder_logistics_status.xlsx │ ├── logistics_history.xlsx │ └── logistics_status.xlsx └── Payment │ ├── Aio │ ├── Capture.php │ ├── CreateAtmOrder.php │ ├── CreateBarcodeOrder.php │ ├── CreateBnplOrder.php │ ├── CreateCreditOrder.php │ ├── CreateCvsOrder.php │ ├── CreateInstallmentOrder.php │ ├── CreateOrder.php │ ├── CreatePeriodicOrder.php │ ├── CreateTwqrOrder.php │ ├── CreateWebAtmOrder.php │ ├── DownloadCreditReconcileCsv.php │ ├── DownloadReconcileCsv.php │ ├── GetCheckoutResponse.php │ ├── QueryCreditTrade.php │ ├── QueryPaymentInfo.php │ ├── QueryPeridicTrade.php │ └── QueryTrade.php │ └── Ecpg │ ├── Capture.php │ ├── CreateAllOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreateApplePayOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreateAtmOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreateBarcodeOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreateBindCard.php │ ├── CreateBindCardOrder │ └── WebJS.html │ ├── CreateCreditOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreateCvsOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreateInstallmentOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreateOrder.php │ ├── CreatePaymentWithCardID.php │ ├── CreateUnionPayOrder │ ├── GetToken.php │ └── WebJS.html │ ├── CreditPeriodAction.php │ ├── DeleteCredit.php │ ├── DeleteMemberBindCard.php │ ├── GetCreateBindCardResponse.php │ ├── GetMemberBindCard.php │ ├── GetResponse.php │ ├── GetTokenbyBindingCard.php │ ├── QueryCreditTrade.php │ ├── QueryPaymentInfo.php │ ├── QueryPeridicTrade.php │ ├── QueryTrade.php │ └── QueryTradeMedia.php └── src ├── Abstracts ├── AbstractAesResponse.php ├── AbstractDecryptedResponse.php ├── AbstractFactory.php ├── AbstractResponse.php └── AbstractVerifiedResponse.php ├── Config └── RtnException.php ├── Exceptions ├── RtnException.php └── TransException.php ├── Factories └── Factory.php ├── Interfaces ├── Request │ └── RequestInterface.php ├── Response │ └── ResponseInterface.php └── Services │ ├── HtmlInterface.php │ ├── HttpClientInterface.php │ └── Test │ └── TestInterface.php ├── Request ├── AesRequest.php ├── CheckMacValueRequest.php └── Request.php ├── Response ├── AesJsonResponse.php ├── AesStrResponse.php ├── ArrayResponse.php ├── EncodedStrResponse.php ├── JsonResponse.php ├── StrResponse.php ├── VerifiedArrayResponse.php └── VerifiedEncodedStrResponse.php ├── Services ├── AesService.php ├── ArrayService.php ├── AutoSubmitFormService.php ├── CheckMacValueService.php ├── CurlService.php ├── Helper.php ├── HtmlService.php ├── ManualFormService.php ├── PostService.php └── UrlService.php ├── TestCase ├── MultipleServiceTestCase.php └── SingleServiceTestCase.php └── Traits ├── HashInfo.php └── StageInfo.php /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | ## 1.3.2411270 - 2024-11-27 4 | ----- 5 | ### Added 6 | - Add Logistic Status Code Files. 7 | ### Changed 8 | - Change AIO test integration account. 9 | ### Deprecated 10 | - Remove Sample Code CreateOrderIssueInvoice.php 11 | 12 | ## 1.3.2411050 - 2024-11-05 13 | ----- 14 | ### Added 15 | - Add the domestic logistic `GetStoreList API` example. 16 | 17 | ## 1.3.2408190 - 2024-08-19 18 | ----- 19 | ### Added 20 | - Add `ManualFormService` for generating HTML forms is not auto-submit. 21 | 22 | ### Changed 23 | - Updated jQuery from version 3.5.1 to 3.7.1. 24 | - Enabled the `curl` option `CURLOPT_FOLLOWLOCATION` in the `run` function of the `CurlService`. 25 | 26 | ## 1.2.2403070 - 2024-03-07 27 | ----- 28 | ### Added 29 | - Add Ecpg binding card examples. 30 | ## 1.2.2301023 - 2023-10-23 31 | ----- 32 | ### Added 33 | - Add BNPL payment example 34 | - Add TWQR payment example 35 | ## 1.2.2308100 - 2023-08-21 36 | ----- 37 | ### Added 38 | - Add Ecpg payment example 39 | ## 1.2.2308010 - 2023-08-01 40 | ----- 41 | ### Added 42 | - Add an annotation for $_POST parameter in GetCheckoutResponse.php 43 | ## 1.2.2210310 - 2022-10-31 44 | ----- 45 | 46 | ### Fixed 47 | - Fix CheckMacValue verify failed when ItemName contains plus(+) sign. 48 | 49 | ## 1.2.0 - 2022-01-26 50 | ----- 51 | 52 | ### Fixed 53 | - Fix PHP 5.6 compibility. 54 | - Fix exmaple/Logistics/CrossBorder/Map.php using wrong service class. 55 | 56 | ### Added 57 | - Add support for Ecpay `All in one logistics` API. 58 | - Add TransCode validation(TransException). 59 | - Add Unimart and Hilife freeze delivery return examples. 60 | 61 | ## 1.1.0 - 2021-07-26 62 | ----- 63 | 64 | ### Fixed 65 | - Added AES decrypt and JSON decode result checking 66 | 67 | ### Added 68 | - Added support for Ecpay `B2C invoice` API 69 | - Added support for Ecpay `C2C invoice` API 70 | - Follow the [Semantic Versioning](https://semver.org) 71 | 72 | ## 1.0.2106040 - 2021-07-19 73 | ----- 74 | 75 | ### Fixed 76 | - Added JSON responses format checking 77 | 78 | ### Deprecated 79 | - Marked `Ecpay\Sdk\Factories\Factory::createWithHash` as deprecated (it's still there, just not the 80 | recommended way) and remove from examples. 81 | 82 | ### Added 83 | - Added support for Ecpay `domestic logistics` API 84 | - Added `MD5` CheckMacValue 85 | - Added `curl POST with CheckMacValue and parse string reponse without CheckMacValue` 86 | 87 | 88 | ## 1.0.2011250 - 2020-12-24 89 | ----- 90 | 91 | ### Added 92 | - Added support for Ecpay `payment` API 93 | - Added support for Ecpay `cross-border logistics` API -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 綠界科技 SDK 2 | 提供您整合綠界科技相關服務,支援服務如下。 3 | * [全方位金流](https://www.ecpay.com.tw/Business/payment_standard) 4 | * [物流服務-全方位物流](https://www.ecpay.com.tw/IntroTransport) 5 | * [物流服務-國內物流](https://www.ecpay.com.tw/IntroTransport) 6 | * [物流服務-跨境物流](https://www.ecpay.com.tw/IntroTransportCB) 7 | * [電子發票](https://www.ecpay.com.tw/Business/invoice) 8 | 9 | 10 | # 目錄 11 | * [環境需求](#環境需求) 12 | * [安裝](#安裝) 13 | * [使用](#使用) 14 | * [協助](#協助) 15 | 16 | # 環境需求 17 | - [PHP](https://www.php.net/): ^5.6.20 || ^7.0 || ^8.0 18 | 19 | # 安裝 20 | 建議使用 [Composer](https://getcomposer.org/) 安裝 21 | ```bash 22 | composer require ecpay/sdk 23 | ``` 24 | # 使用 25 | 請參考 [範例](example) 與 [串接文件](https://www.ecpay.com.tw/Service/API_Dwnld)。 26 | 27 | # 協助 28 | - [綠界技術服務工程師信箱](mailto:techsupport@ecpay.com.tw) 29 | - [舊版](https://github.com/ECPay/ECPayAIO_PHP) (停止維護) -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecpay/sdk", 3 | "description": "ECPay SDK", 4 | "type": "library", 5 | "require": { 6 | "php": "^5.6.20 || ^7.0 || ^8.0" 7 | }, 8 | "license": "MIT", 9 | "require-dev": { 10 | "phpunit/phpunit": "^5.0 || ^6.0 || ^7.0 || ^8.0", 11 | "fzaninotto/faker": "1.9.x-dev" 12 | }, 13 | "autoload": { 14 | "psr-4": { 15 | "Ecpay\\Sdk\\": "src/" 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/Invoice/B2B/Allowance.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $itemCount = 1; 14 | $itemPrice = 10; 15 | $itemAmount = ($itemPrice * $itemCount); 16 | $totalAmount = $itemAmount; 17 | $taxAmount = round($totalAmount * 0.05, 0); 18 | $data = [ 19 | 'MerchantID' => '2000132', 20 | 'TaxAmount' => $taxAmount, 21 | 'TotalAmount' => $totalAmount, 22 | 'Details' => [ 23 | [ 24 | 'OriginalInvoiceNumber' => 'MJ20001246', 25 | 'OriginalInvoiceDate' => '2021-07-30', 26 | 'ItemName' => '測試商品01', 27 | 'OriginalSequenceNumber' => 1, 28 | 'ItemName' => '測試商品01', 29 | 'ItemCount' => $itemCount, 30 | 'ItemPrice' => $itemPrice, 31 | 'ItemAmount' => $itemAmount, 32 | ], 33 | ], 34 | ]; 35 | $input = [ 36 | 'MerchantID' => '2000132', 37 | 'RqHeader' => [ 38 | 'Timestamp' => time(), 39 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 40 | 'Revision' => '1.0.0', 41 | ], 42 | 'Data' => $data, 43 | ]; 44 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/Allowance'; 45 | 46 | $response = $postService->post($input, $url); 47 | var_dump($response); 48 | -------------------------------------------------------------------------------- /example/Invoice/B2B/AllowanceConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'AllowanceNo' => '2107301425196279', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/AllowanceConfirm'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2B/CancelAllowance.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'AllowanceNo' => '2107301425196279', 16 | 'Reason' => 'Testing reason', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 23 | 'Revision' => '1.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/CancelAllowance'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Invoice/B2B/CancelAllowanceConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'AllowanceNo' => '2107301425196279', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/CancelAllowanceConfirm'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetAllowance.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'AllowanceNo' => '2107301546105790', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetAllowance'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetAllowanceConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'AllowanceNo' => '2107301546105790', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetAllowanceConfirm'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetAllowanceInvalid.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'AllowanceNo' => '2107301546105790', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetAllowanceInvalid'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetAllowanceInvalidConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'AllowanceNo' => '2107301546105790', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetAllowanceInvalidConfirm'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetInvalid.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceCategory' => 0, 16 | 'InvoiceNumber' => 'MJ20001241', 17 | 'InvoiceDate' => '2021-07-29', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetInvalid'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetInvalidConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceCategory' => 0, 16 | 'InvoiceNumber' => 'MJ20001241', 17 | 'InvoiceDate' => '2021-07-29', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetInvalidConfirm'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetInvoiceWordSetting.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceYear' => '109', 16 | 'InvoiceTerm' => 0, 17 | 'UseStatus' => 0, 18 | 'InvoiceCategory' => 2, 19 | ]; 20 | $input = [ 21 | 'MerchantID' => '2000132', 22 | 'RqHeader' => [ 23 | 'Timestamp' => time(), 24 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 25 | 'Revision' => '1.0.0', 26 | ], 27 | 'Data' => $data, 28 | ]; 29 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetInvoiceWordSetting'; 30 | 31 | $response = $postService->post($input, $url); 32 | var_dump($response); 33 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetIssue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceCategory' => 0, 16 | 'InvoiceNumber' => 'MJ20001294', 17 | 'InvoiceDate' => '2021-07-30', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetIssue'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetIssueConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceCategory' => 0, 16 | 'InvoiceNumber' => 'MJ20001294', 17 | 'InvoiceDate' => '2021-07-30', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetIssueConfirm'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetReject.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNumber' => 'MJ20001336', 16 | 'InvoiceDate' => '2021-07-30', 17 | 'Reason' => 'Testing reason', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetReject'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/GetRejectConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceCategory' => 0, 16 | 'InvoiceNumber' => 'MJ20001336', 17 | 'InvoiceDate' => '2021-07-30', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/GetRejectConfirm'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/Invalid.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNumber' => 'MJ20001241', 16 | 'InvoiceDate' => '2021-07-29', 17 | 'Reason' => 'Testing reason', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/Invalid'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/InvalidConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNumber' => 'MJ20001242', 16 | 'InvoiceDate' => '2021-07-29', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 23 | 'Revision' => '1.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/InvalidConfirm'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Invoice/B2B/Issue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $itemCount = 3; 14 | $itemPrice = 10; 15 | $itemAmount = ($itemPrice * $itemCount); 16 | $saleAmount = $itemAmount; 17 | $taxAmount = round(($saleAmount * 0.05), 0); 18 | $data = [ 19 | 'MerchantID' => '2000132', 20 | 'RelateNumber' => 'test' . time(), 21 | 'CustomerIdentifier' => '23165448', 22 | 'CustomerEmail' => 'test-buyer@ecpay.com.tw', 23 | 'InvType' => '07', 24 | 'TaxType' => '1', 25 | 'Items' => [ 26 | [ 27 | 'ItemSeq' => 1, 28 | 'ItemName' => '測試商品01', 29 | 'ItemCount' => $itemCount, 30 | 'ItemPrice' => $itemPrice, 31 | 'ItemTaxType' => '1', 32 | 'ItemAmount' => $itemAmount, 33 | ], 34 | ], 35 | 'SalesAmount' => $saleAmount, 36 | 'TaxAmount' => $taxAmount, 37 | 'TotalAmount' => ($saleAmount + $taxAmount), 38 | ]; 39 | $input = [ 40 | 'MerchantID' => '2000132', 41 | 'RqHeader' => [ 42 | 'Timestamp' => time(), 43 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 44 | 'Revision' => '1.0.0', 45 | ], 46 | 'Data' => $data, 47 | ]; 48 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/Issue'; 49 | 50 | $response = $postService->post($input, $url); 51 | var_dump($response); 52 | -------------------------------------------------------------------------------- /example/Invoice/B2B/IssueConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNumber' => 'MJ20001240', 16 | 'InvoiceDate' => '2021-07-29', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 23 | 'Revision' => '1.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/IssueConfirm'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Invoice/B2B/MaintainMerchantCustomerData.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'Action' => 'Add', 16 | 'Identifier' => '53538851', 17 | 'type' => '2', 18 | 'CompanyName' => '綠界科技', 19 | 'TradingSlang' => 'Testing Slang', 20 | 'ExchangeMode' => '0', 21 | 'EmailAddress' => 'test-company@ecpay.com.tw', 22 | ]; 23 | $input = [ 24 | 'MerchantID' => '2000132', 25 | 'RqHeader' => [ 26 | 'Timestamp' => time(), 27 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 28 | 'Revision' => '1.0.0', 29 | ], 30 | 'Data' => $data, 31 | ]; 32 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/MaintainMerchantCustomerData'; 33 | 34 | $response = $postService->post($input, $url); 35 | var_dump($response); 36 | -------------------------------------------------------------------------------- /example/Invoice/B2B/Notify.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceDate' => '2021-07-29', 16 | 'InvoiceNumber' => 'MJ20001240', 17 | 'NotifyMail' => 'test-buyer@ecpay.com.tw', 18 | 'InvoiceTag' => '1', 19 | 'Notified' => 'C', 20 | ]; 21 | $input = [ 22 | 'MerchantID' => '2000132', 23 | 'RqHeader' => [ 24 | 'Timestamp' => time(), 25 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 26 | 'Revision' => '1.0.0', 27 | ], 28 | 'Data' => $data, 29 | ]; 30 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/Notify'; 31 | 32 | $response = $postService->post($input, $url); 33 | var_dump($response); 34 | -------------------------------------------------------------------------------- /example/Invoice/B2B/Reject.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNumber' => 'MJ20001243', 16 | 'InvoiceDate' => '2021-07-29', 17 | 'Reason' => 'Testing reason', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 24 | 'Revision' => '1.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/Reject'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2B/RejectConfirm.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNumber' => 'MJ20001243', 16 | 'InvoiceDate' => '2021-07-29', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'RqID' => '701b3264-a538-437e-ad45-2505eb7dde39', 23 | 'Revision' => '1.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://einvoice-stage.ecpay.com.tw/B2BInvoice/RejectConfirm'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Invoice/B2C/Allowance.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $itemCount = 1; 14 | $itemPrice = 10.5; 15 | $itemAmount = $itemPrice * $itemCount; 16 | $allowanceAmount = round(($itemAmount), 0); 17 | $data = [ 18 | 'MerchantID' => '2000132', 19 | 'InvoiceNo' => 'MJ80008939', 20 | 'InvoiceDate' => '2021-07-28', 21 | 'AllowanceNotify' => 'E', 22 | 'NotifyMail' => 'test-allowance@ecpay.com.tw', 23 | 'AllowanceAmount' => $allowanceAmount, 24 | 25 | 'Items' => [ 26 | [ 27 | 'ItemSeq' => 1, 28 | 'ItemName' => '測試商品01', 29 | 'ItemCount' => $itemCount, 30 | 'ItemWord' => '個', 31 | 'ItemPrice' => $itemPrice, 32 | 'ItemAmount' => $itemAmount, 33 | ], 34 | ], 35 | ]; 36 | $input = [ 37 | 'MerchantID' => '2000132', 38 | 'RqHeader' => [ 39 | 'Timestamp' => time(), 40 | 'Revision' => '3.0.0', 41 | ], 42 | 'Data' => $data, 43 | ]; 44 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/Allowance'; 45 | 46 | $response = $postService->post($input, $url); 47 | var_dump($response); 48 | -------------------------------------------------------------------------------- /example/Invoice/B2C/AllowanceByCollegiate.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $itemCount = 1; 14 | $itemPrice = 10.5; 15 | $itemAmount = $itemPrice * $itemCount; 16 | $allowanceAmount = round(($itemAmount), 0); 17 | $data = [ 18 | 'MerchantID' => '2000132', 19 | 'InvoiceNo' => 'MJ80009035', 20 | 'InvoiceDate' => '2021-07-28', 21 | 'AllowanceNotify' => 'E', 22 | 'NotifyMail' => 'test-allowance@ecpay.com.tw', 23 | 'AllowanceAmount' => $allowanceAmount, 24 | 'Items' => [ 25 | [ 26 | 'ItemSeq' => 1, 27 | 'ItemName' => '測試商品01', 28 | 'ItemCount' => $itemCount, 29 | 'ItemWord' => '個', 30 | 'ItemPrice' => $itemPrice, 31 | 'ItemAmount' => $itemAmount, 32 | ], 33 | ], 34 | 35 | // 請參考 example/Invoice/B2C/GetAllowanceByCollegiateResponse.php 範例開發 36 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/return-url', 37 | ]; 38 | $input = [ 39 | 'MerchantID' => '2000132', 40 | 'RqHeader' => [ 41 | 'Timestamp' => time(), 42 | 'Revision' => '3.0.0', 43 | ], 44 | 'Data' => $data, 45 | ]; 46 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/AllowanceByCollegiate'; 47 | 48 | $response = $postService->post($input, $url); 49 | var_dump($response); 50 | -------------------------------------------------------------------------------- /example/Invoice/B2C/AllowanceInvalid.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNo' => 'MJ80009358', 16 | 'AllowanceNo' => '2021072813260868', 17 | 'Reason' => 'Testing reason', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'Revision' => '3.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/AllowanceInvalid'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Invoice/B2C/CancelDelayIssue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | $data = [ 13 | 'MerchantID' => '2000132', 14 | 'Tsr' => 'tsr1627439050', 15 | ]; 16 | $input = [ 17 | 'MerchantID' => '2000132', 18 | 'RqHeader' => [ 19 | 'Timestamp' => time(), 20 | 'Revision' => '3.0.0', 21 | ], 22 | 'Data' => $data, 23 | ]; 24 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/CancelDelayIssue'; 25 | 26 | $response = $postService->post($input, $url); 27 | var_dump($response); 28 | -------------------------------------------------------------------------------- /example/Invoice/B2C/CheckBarcode.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'BarCode' => '/1234567', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'Revision' => '3.0.0', 22 | ], 23 | 'Data' => $data, 24 | ]; 25 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/CheckBarcode'; 26 | 27 | $response = $postService->post($input, $url); 28 | var_dump($response); 29 | -------------------------------------------------------------------------------- /example/Invoice/B2C/CheckLoveCode.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LoveCode' => '168001', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'Revision' => '3.0.0', 22 | ], 23 | 'Data' => $data, 24 | ]; 25 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/CheckLoveCode'; 26 | 27 | $response = $postService->post($input, $url); 28 | var_dump($response); 29 | -------------------------------------------------------------------------------- /example/Invoice/B2C/DelayIssue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $itemCount01 = 3; 14 | $itemPrice01 = 10.5; 15 | $itemAmount01 = round(($itemPrice01 * $itemCount01), 0); 16 | 17 | $itemCount02 = 1; 18 | $itemPrice02 = 150.0; 19 | $itemAmount02 = round(($itemPrice02 * $itemCount02), 0); 20 | 21 | $data = [ 22 | 'MerchantID' => '2000132', 23 | 'RelateNumber' => 'Test' . time(), 24 | 'CustomerName' => '測試消費者', 25 | 'CustomerAddr' => '台北市南港區三重路19-2號6樓', 26 | 'CustomerEmail' => 'test-customer@ecpay.com.tw', 27 | 'Print' => '1', 28 | 'Donation' => '0', 29 | 'TaxType' => '1', 30 | 'SalesAmount' => ($itemAmount01 + $itemAmount02), 31 | 'Items' => [ 32 | [ 33 | 'ItemName' => '測試商品01', 34 | 'ItemCount' => $itemCount01, 35 | 'ItemWord' => '個', 36 | 'ItemPrice' => $itemPrice01, 37 | 'ItemTaxType' => '3', 38 | 'ItemAmount' => $itemAmount01, 39 | ], 40 | [ 41 | 'ItemName' => '測試商品02', 42 | 'ItemCount' => $itemCount02, 43 | 'ItemWord' => '雙', 44 | 'ItemPrice' => $itemPrice02, 45 | 'ItemTaxType' => '3', 46 | 'ItemAmount' => $itemAmount02, 47 | ], 48 | ], 49 | 'InvType' => '07', 50 | 'DelayFlag' => '1', 51 | 'DelayDay' => 15, 52 | 'Tsr' => 'tsr' . time(), 53 | 'PayType' => '2', 54 | 'PayAct' => 'ECPAY', 55 | 56 | // 請參考 example/Invoice/B2C/GetInvoicedResponse.php 範例開發 57 | 'NotifyURL' => 'https://www.ecpay.com.tw/example/notify-url', 58 | ]; 59 | $input = [ 60 | 'MerchantID' => '2000132', 61 | 'RqHeader' => [ 62 | 'Timestamp' => time(), 63 | 'Revision' => '3.0.0', 64 | ], 65 | 'Data' => $data, 66 | ]; 67 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/DelayIssue'; 68 | 69 | $response = $postService->post($input, $url); 70 | var_dump($response); 71 | -------------------------------------------------------------------------------- /example/Invoice/B2C/GetAllowance.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNo' => 'MJ80009376', 16 | 'AllowanceNo' => '2021072814112628', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'Revision' => '3.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/GetAllowance'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2C/GetAllowanceByCollegiateResponse.php: -------------------------------------------------------------------------------- 1 | create(ArrayResponse::class); 10 | 11 | var_dump($arrayResponse->get($_POST)); 12 | -------------------------------------------------------------------------------- /example/Invoice/B2C/GetAllowanceInvalid.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNo' => 'MJ80009399', 16 | 'AllowanceNo' => '2021072814346308', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'Revision' => '3.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/GetAllowanceInvalid'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2C/GetInvalid.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'RelateNumber' => 'Test1627453097', 16 | 'InvoiceNo' => 'MJ80009387', 17 | 'InvoiceDate' => '2021-07-28 ', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'Revision' => '3.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/GetInvalid'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Invoice/B2C/GetInvoiceWordSetting.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceYear' => '109', 16 | 'InvoiceTerm' => 0, 17 | 'UseStatus' => 0, 18 | 'InvoiceCategory' => 1, 19 | ]; 20 | $input = [ 21 | 'MerchantID' => '2000132', 22 | 'RqHeader' => [ 23 | 'Timestamp' => time(), 24 | 'Revision' => '3.0.0', 25 | ], 26 | 'Data' => $data, 27 | ]; 28 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/GetInvoiceWordSetting'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Invoice/B2C/GetInvoicedResponse.php: -------------------------------------------------------------------------------- 1 | create(ArrayResponse::class); 10 | 11 | var_dump($arrayResponse->get($_POST)); 12 | -------------------------------------------------------------------------------- /example/Invoice/B2C/GetIssue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNo' => 'MJ80009376', 16 | 'InvoiceDate' => '2021-07-28', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'Revision' => '3.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/GetIssue'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2C/Invalid.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNo' => 'MJ80009300', 16 | 'InvoiceDate' => '2021-07-28', 17 | 'Reason' => 'Testing reason', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'Revision' => '3.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/Invalid'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Invoice/B2C/InvoiceNotify.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'InvoiceNo' => 'MJ80009449', 16 | 'NotifyMail' => 'test-customer@ecpay.com.tw', 17 | 'Notify' => 'E', 18 | 'InvoiceTag' => 'I', 19 | 'Notified' => 'C', 20 | ]; 21 | $input = [ 22 | 'MerchantID' => '2000132', 23 | 'RqHeader' => [ 24 | 'Timestamp' => time(), 25 | 'Revision' => '3.0.0', 26 | ], 27 | 'Data' => $data, 28 | ]; 29 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/InvoiceNotify'; 30 | 31 | $response = $postService->post($input, $url); 32 | var_dump($response); 33 | -------------------------------------------------------------------------------- /example/Invoice/B2C/Issue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $itemCount = 3; 14 | $itemPriceIncludeTax = 10.5; 15 | $itemAmount = round(($itemPriceIncludeTax * $itemCount), 0); 16 | $saleAmount = $itemAmount; 17 | $data = [ 18 | 'MerchantID' => '2000132', 19 | 'RelateNumber' => 'Test' . time(), 20 | 'CustomerPhone' => '0911222333', 21 | 'Print' => '0', 22 | 'Donation' => '0', 23 | 'CarrierType' => '1', 24 | 'TaxType' => '1', 25 | 'SalesAmount' => $saleAmount, 26 | 'Items' => [ 27 | [ 28 | 'ItemName' => '測試商品01', 29 | 'ItemCount' => $itemCount, 30 | 'ItemWord' => '個', 31 | 'ItemPrice' => $itemPriceIncludeTax, 32 | 'ItemTaxType' => '1', 33 | 'ItemAmount' => $itemAmount, 34 | ], 35 | ], 36 | 'InvType' => '07' 37 | ]; 38 | $input = [ 39 | 'MerchantID' => '2000132', 40 | 'RqHeader' => [ 41 | 'Timestamp' => time(), 42 | 'Revision' => '3.0.0', 43 | ], 44 | 'Data' => $data, 45 | ]; 46 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/Issue'; 47 | 48 | $response = $postService->post($input, $url); 49 | var_dump($response); 50 | -------------------------------------------------------------------------------- /example/Invoice/B2C/TriggerIssue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'Tsr' => 'tsr1627439050', 16 | 'PayType' => '2', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'Revision' => '3.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/TriggerIssue'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Invoice/B2C/VoidWithReIssue.php: -------------------------------------------------------------------------------- 1 | 'ejCk326UnaZWKisg', 9 | 'hashIv' => 'q9jcZX8Ib9LM8wYk', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $itemCount = 1; 14 | $itemPriceIncludeTax = 10.5; 15 | $itemAmount = round(($itemPriceIncludeTax * $itemCount), 0); 16 | $saleAmount = $itemAmount; 17 | $data = [ 18 | 'VoidModel' => [ 19 | 'MerchantID' => '2000132', 20 | 'InvoiceNo' => 'MJ80009359', 21 | 'VoidReason' => 'Testing void reason', 22 | ], 23 | 'IssueModel' => [ 24 | 'MerchantID' => '2000132', 25 | 'RelateNumber' => 'test' . time(), 26 | 'InvoiceDate' => '2021-07-28 13:32:48', 27 | 'CustomerEmail' => 'test-customer@ecpay.com.tw', 28 | 'Print' => '0', 29 | 'Donation' => '0', 30 | 'TaxType' => '1', 31 | 'SalesAmount' => $saleAmount, 32 | 'Items' => [ 33 | [ 34 | 'ItemName' => '測試商品01', 35 | 'ItemCount' => $itemCount, 36 | 'ItemWord' => '個', 37 | 'ItemPrice' => $itemPriceIncludeTax, 38 | 'ItemTaxType' => '1', 39 | 'ItemAmount' => $itemAmount, 40 | ], 41 | ], 42 | 'InvType' => '07' 43 | ], 44 | ]; 45 | $input = [ 46 | 'MerchantID' => '2000132', 47 | 'RqHeader' => [ 48 | 'Timestamp' => time(), 49 | 'Revision' => '3.0.0', 50 | ], 51 | 'Data' => $data, 52 | ]; 53 | $url = 'https://einvoice-stage.ecpay.com.tw/B2CInvoice/VoidWithReIssue'; 54 | 55 | $response = $postService->post($input, $url); 56 | var_dump($response); 57 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/B2C/CreateTestData.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsSubType' => 'FAMI', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'Revision' => '1.0.0', 22 | ], 23 | 'Data' => $data, 24 | ]; 25 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/CreateTestData'; 26 | 27 | $response = $postService->post($input, $url); 28 | var_dump($response); 29 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/B2C/ReturnFamiCVS.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1769542', 16 | 'GoodsAmount' => 130, 17 | 'ServiceType' => '4', 18 | 'SenderName' => '王大明', 19 | 20 | // 請參考 example/Logistics/AllInOne/LogisticsStatusNotify.php 範例開發 21 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 22 | ]; 23 | $input = [ 24 | 'MerchantID' => '2000132', 25 | 'RqHeader' => [ 26 | 'Timestamp' => time(), 27 | 'Revision' => '1.0.0', 28 | ], 29 | 'Data' => $data, 30 | ]; 31 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/ReturnCVS'; 32 | 33 | $response = $postService->post($input, $url); 34 | var_dump($response); 35 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/B2C/ReturnHilifeCvs.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1865733', 16 | 'GoodsAmount' => 100, 17 | 'ServiceType' => '4', 18 | 'SenderName' => '王大明', 19 | 'SenderPhone' => '0911222333', 20 | 21 | // 請參考 example/Logistics/AllInOne/LogisticsStatusNotify.php 範例開發 22 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 23 | ]; 24 | $input = [ 25 | 'MerchantID' => '2000132', 26 | 'RqHeader' => [ 27 | 'Timestamp' => time(), 28 | 'Revision' => '1.0.0', 29 | ], 30 | 'Data' => $data, 31 | ]; 32 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/ReturnHilifeCVS'; 33 | 34 | $response = $postService->post($input, $url); 35 | var_dump($response); 36 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/B2C/ReturnUnimartCvs.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1769541', 16 | 'GoodsAmount' => 130, 17 | 'ServiceType' => '4', 18 | 'SenderName' => '王大明', 19 | 20 | // 請參考 example/Logistics/AllInOne/LogisticsStatusNotify.php 範例開發 21 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 22 | ]; 23 | $input = [ 24 | 'MerchantID' => '2000132', 25 | 'RqHeader' => [ 26 | 'Timestamp' => time(), 27 | 'Revision' => '1.0.0', 28 | ], 29 | 'Data' => $data, 30 | ]; 31 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/ReturnUniMartCVS'; 32 | 33 | $response = $postService->post($input, $url); 34 | var_dump($response); 35 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/B2C/UpdateShipmentInfo.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1770237', 16 | 'ShipmentDate' => '2021/10/25', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/UpdateShipmentInfo'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/C2C/CancelC2cOrder.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1770265', 16 | 'CVSPaymentNo' => 'C1234567', 17 | 'CVSValidationNo' => '4111', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'Revision' => '1.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/CancelC2COrder'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/C2C/UpdateStoreInfo.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1770242', 16 | 'CVSPaymentNo' => '144310142000', 17 | 'CVSValidationNo' => '9926', 18 | 'StoreType' => '01', 19 | 'ReceiverStoreID' => '018527', 20 | ]; 21 | $input = [ 22 | 'MerchantID' => '2000132', 23 | 'RqHeader' => [ 24 | 'Timestamp' => time(), 25 | 'Revision' => '1.0.0', 26 | ], 27 | 'Data' => $data, 28 | ]; 29 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/UpdateStoreInfo'; 30 | 31 | $response = $postService->post($input, $url); 32 | var_dump($response); 33 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/CreateByTempTrade.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'TempLogisticsID' => '2264', 15 | ]; 16 | $input = [ 17 | 'MerchantID' => '2000132', 18 | 'RqHeader' => [ 19 | 'Timestamp' => time(), 20 | 'Revision' => '1.0.0', 21 | ], 22 | 'Data' => $data, 23 | ]; 24 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/CreateByTempTrade'; 25 | 26 | $response = $postService->post($input, $url); 27 | var_dump($response); 28 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/Home/ReturnHome.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1769853', 16 | 'GoodsAmount' => 130, 17 | 'Temperature' => '0001', 18 | 'Distance' => '00', 19 | 'Specification' => '0001', 20 | 21 | // 請參考 example/Logistics/AllInOne/LogisticsStatusNotify.php 範例開發 22 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 23 | ]; 24 | $input = [ 25 | 'MerchantID' => '2000132', 26 | 'RqHeader' => [ 27 | 'Timestamp' => time(), 28 | 'Revision' => '1.0.0', 29 | ], 30 | 'Data' => $data, 31 | ]; 32 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/ReturnHome'; 33 | 34 | $response = $postService->post($input, $url); 35 | var_dump($response); 36 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/LogisticsStatusNotify.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 11 | 'hashIv' => 'v77hoKGq4kWxNNIS', 12 | ]); 13 | $aesParser = $factory->create(AesParser::class); 14 | $parsedRequest = $aesParser->get(file_get_contents('php://input')); 15 | 16 | // 物流狀態(貨態) or 物流狀態(逆物流)通知相關處理 17 | 18 | $aesGenerater = $factory->create(AesGenerater::class); 19 | $data = [ 20 | 'RtnCode' => '1', 21 | 'RtnMsg' => '', 22 | ]; 23 | $input = [ 24 | 'MerchantID' => '2000132', 25 | 'RqHeader' => [ 26 | 'Timestamp' => time(), 27 | ], 28 | 'TransCode' => '1', 29 | 'TransMsg' => '', 30 | 'Data' => $data, 31 | ]; 32 | $response = $aesGenerater->get($input); 33 | var_dump($response); 34 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/PrintTradeDocument.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesStrResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => ['1769543'], 16 | 'LogisticsSubType' => 'FAMI', 17 | ]; 18 | $input = [ 19 | 'MerchantID' => '2000132', 20 | 'RqHeader' => [ 21 | 'Timestamp' => time(), 22 | 'Revision' => '1.0.0', 23 | ], 24 | 'Data' => $data, 25 | ]; 26 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/PrintTradeDocument'; 27 | 28 | $response = $postService->post($input, $url); 29 | echo $response['body']; 30 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/QueryLogisticsTradeInfo.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1769853', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'Revision' => '1.0.0', 22 | ], 23 | 'Data' => $data, 24 | ]; 25 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/QueryLogisticsTradeInfo'; 26 | 27 | $response = $postService->post($input, $url); 28 | var_dump($response); 29 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/RedirectToLogisticsSelection.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesStrResponseService'); 12 | 13 | $data = [ 14 | 'TempLogisticsID' => '0', 15 | 'GoodsAmount' => 100, 16 | 'GoodsName' => '範例商品', 17 | 'SenderName' => '陳大明', 18 | 'SenderZipCode' => '11560', 19 | 'SenderAddress' => '台北市南港區三重路19-2號6樓', 20 | 21 | // 請參考 example/Logistics/AllInOne/LogisticsStatusNotify.php 範例開發 22 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 23 | 24 | // 請參考 example/Logistics/AllInOne/TempTradeEstablishedResponse.php 範例開發 25 | 'ClientReplyURL' => 'https://www.ecpay.com.tw/example/client-reply', 26 | ]; 27 | $input = [ 28 | 'MerchantID' => '2000132', 29 | 'RqHeader' => [ 30 | 'Timestamp' => time(), 31 | 'Revision' => '1.0.0', 32 | ], 33 | 'Data' => $data, 34 | ]; 35 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/RedirectToLogisticsSelection'; 36 | 37 | $response = $postService->post($input, $url); 38 | echo $response['body']; 39 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/RedirectWithUnimartFreeze.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesStrResponseService'); 12 | 13 | $data = [ 14 | 'TempLogisticsID' => '0', 15 | 'GoodsAmount' => 100, 16 | 'GoodsName' => '範例商品', 17 | 'SenderName' => '陳大明', 18 | 'SenderZipCode' => '11560', 19 | 'SenderAddress' => '台北市南港區三重路19-2號6樓', 20 | 'Temperature' => '0003', 21 | 22 | // 請參考 example/Logistics/AllInOne/LogisticsStatusNotify.php 範例開發 23 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 24 | 25 | // 請參考 example/Logistics/AllInOne/TempTradeEstablishedResponse.php 範例開發 26 | 'ClientReplyURL' => 'https://www.ecpay.com.tw/example/client-reply', 27 | ]; 28 | $input = [ 29 | 'MerchantID' => '2000132', 30 | 'RqHeader' => [ 31 | 'Timestamp' => time(), 32 | 'Revision' => '1.0.0', 33 | ], 34 | 'Data' => $data, 35 | ]; 36 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/RedirectToLogisticsSelection'; 37 | 38 | $response = $postService->post($input, $url); 39 | echo $response['body']; 40 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/TempTradeEstablishedResponse.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 10 | 'hashIv' => 'v77hoKGq4kWxNNIS', 11 | ]); 12 | $response = $factory->create(AesJsonResponse::class); 13 | $parsed = []; 14 | $parsed['ResultData'] = $response->get($_POST['ResultData']); 15 | var_dump($parsed); 16 | -------------------------------------------------------------------------------- /example/Logistics/AllInOne/UpdateTempTrade.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | $data = [ 13 | 'TempLogisticsID' => '2264', 14 | 'SenderName' => '王小美', 15 | ]; 16 | $input = [ 17 | 'MerchantID' => '2000132', 18 | 'RqHeader' => [ 19 | 'Timestamp' => time(), 20 | 'Revision' => '1.0.0', 21 | ], 22 | 'Data' => $data, 23 | ]; 24 | $url = 'https://logistics-stage.ecpay.com.tw/Express/v2/UpdateTempTrade'; 25 | 26 | $response = $postService->post($input, $url); 27 | var_dump($response); 28 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/CreateTestData.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'Country' => 'SG', 16 | 'LogisticsType' => 'CB', 17 | 'LogisticsSubType' => 'UNIMARTCBCVS', 18 | ]; 19 | $input = [ 20 | 'MerchantID' => '2000132', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time(), 23 | 'Revision' => '1.0.0', 24 | ], 25 | 'Data' => $data, 26 | ]; 27 | $url = 'https://logistics-stage.ecpay.com.tw/CrossBorder/CreateTestData'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/CreateUnimartCvsOrder.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'LogisticsType' => 'CB', 18 | 'LogisticsSubType' => 'UNIMARTCBCVS', 19 | 'GoodsAmount' => 1000, 20 | 'GoodsWeight' => 5.0, 21 | 'GoodsEnglishName' => 'Test goods', 22 | 'ReceiverCountry' => 'SG', 23 | 'ReceiverName' => 'Test Receiver', 24 | 'ReceiverCellPhone' => '65212345678', 25 | 'ReceiverStoreID' => '711_1', 26 | 'ReceiverZipCode' => '419701', 27 | 'ReceiverAddress' => 'address 23424 -fr 13-2', 28 | 'ReceiverEmail' => 'test-receiver@ecpay.com.tw', 29 | 'SenderName' => 'Test Sender', 30 | 'SenderCellPhone' => '886987654321', 31 | 'SenderAddress' => 'address 23424 -fr 13-2, Nangang Dist., Taipei City 115, Taiwan (R.O.C.)', 32 | 'SenderEmail' => 'test-sender@ecpay.com.tw', 33 | 'Remark' => 'Test Remark', 34 | 35 | // 請參考 example/Logistics/CrossBorder/GetStatusChangedResponse.php 範例開發 36 | 'ServerReplyURL' => 'https://logistics-stage.ecpay.com.tw/MockMerchant/NoticsTestRtn', 37 | ]; 38 | $input = [ 39 | 'MerchantID' => '2000132', 40 | 'RqHeader' => [ 41 | 'Timestamp' => time(), 42 | 'Revision' => '1.0.0', 43 | ], 44 | 'Data' => $data, 45 | ]; 46 | $url = 'https://logistics-stage.ecpay.com.tw/CrossBorder/Create'; 47 | 48 | $response = $postService->post($input, $url); 49 | var_dump($response); 50 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/CreateUnimartHomeOrder.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'LogisticsType' => 'CB', 18 | 'LogisticsSubType' => 'UNIMARTCBHOME', 19 | 'GoodsAmount' => 1000, 20 | 'GoodsWeight' => 5.0, 21 | 'GoodsEnglishName' => 'Test goods', 22 | 'ReceiverCountry' => 'SG', 23 | 'ReceiverName' => 'Test Receiver', 24 | 'ReceiverCellPhone' => '65212345678', 25 | 'ReceiverZipCode' => '419701', 26 | 'ReceiverAddress' => 'address 23424 -fr 13-2', 27 | 'ReceiverEmail' => 'test-receiver@ecpay.com.tw', 28 | 'SenderName' => 'Test Sender', 29 | 'SenderCellPhone' => '886987654321', 30 | 'SenderAddress' => 'address 23424 -fr 13-2, Nangang Dist., Taipei City 115, Taiwan (R.O.C.)', 31 | 'SenderEmail' => 'test-sender@ecpay.com.tw', 32 | 'Remark' => 'Test Remark', 33 | 34 | // 請參考 example/Logistics/CrossBorder/GetStatusChangedResponse.php 範例開發 35 | 'ServerReplyURL' => 'https://logistics-stage.ecpay.com.tw/MockMerchant/NoticsTestRtn', 36 | ]; 37 | $input = [ 38 | 'MerchantID' => '2000132', 39 | 'RqHeader' => [ 40 | 'Timestamp' => time(), 41 | 'Revision' => '1.0.0', 42 | ], 43 | 'Data' => $data, 44 | ]; 45 | $url = 'https://logistics-stage.ecpay.com.tw/CrossBorder/Create'; 46 | 47 | $response = $postService->post($input, $url); 48 | var_dump($response); 49 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/GetMapResponse.php: -------------------------------------------------------------------------------- 1 | create(ArrayResponse::class); 10 | 11 | var_dump($arrayResponse->get($_POST)); 12 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/GetStatusChangedResponse.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 10 | 'hashIv' => 'v77hoKGq4kWxNNIS', 11 | ]); 12 | $aesJsonResponse = $factory->create(AesJsonResponse::class); 13 | $response = file_get_contents('php://input'); 14 | 15 | var_dump($aesJsonResponse->get($response)); 16 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/Map.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('AutoSubmitFormService'); 12 | 13 | $input = [ 14 | 'MerchantID' => '2000132', 15 | 'MerchantTradeNo' => 'Test' . time(), 16 | 'LogisticsType' => 'CB', 17 | 'LogisticsSubType' => 'UNIMARTCBCVS', 18 | 'Destination' => 'SG', 19 | 20 | // 請參考 example/Logistics/CrossBorder/GetMapResponse.php 範例開發 21 | 'ServerReplyURL' => 'https://logistics-stage.ecpay.com.tw/MockMerchant/NoticsTestRtn', 22 | ]; 23 | $action = 'https://logistics-stage.ecpay.com.tw/CrossBorder/Map'; 24 | 25 | echo $postService->generate($input, $action); 26 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/Print.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1658389', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'Revision' => '1.0.0', 22 | ], 23 | 'Data' => $data, 24 | ]; 25 | $url = 'https://logistics-stage.ecpay.com.tw/CrossBorder/Print'; 26 | 27 | $response = $postService->post($input, $url); 28 | var_dump($response); 29 | -------------------------------------------------------------------------------- /example/Logistics/CrossBorder/QueryLogisticsTradeInfo.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '2000132', 15 | 'LogisticsID' => '1658389', 16 | ]; 17 | $input = [ 18 | 'MerchantID' => '2000132', 19 | 'RqHeader' => [ 20 | 'Timestamp' => time(), 21 | 'Revision' => '1.0.0', 22 | ], 23 | 'Data' => $data, 24 | ]; 25 | $url = 'https://logistics-stage.ecpay.com.tw/CrossBorder/QueryLogisticsTradeInfo'; 26 | 27 | $response = $postService->post($input, $url); 28 | var_dump($response); 29 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/CancelC2cOrder.php: -------------------------------------------------------------------------------- 1 | 'XBERn1YOvpM9nfZc', 9 | 'hashIv' => 'h1ONHk4P4yqbl5LK', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000933', 16 | 'AllPayLogisticsID' => '1718552', 17 | 'CVSPaymentNo' => 'C9681067', 18 | 'CVSValidationNo' => '2448', 19 | ]; 20 | $url = 'https://logistics-stage.ecpay.com.tw/Express/CancelC2COrder'; 21 | 22 | $response = $postService->post($input, $url); 23 | var_dump($response); 24 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/CreateCvs.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvEncodedStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'LogisticsType' => 'CVS', 19 | 'LogisticsSubType' => 'FAMI', 20 | 'GoodsAmount' => 1000, 21 | 'GoodsName' => '綠界 SDK 範例商品', 22 | 'SenderName' => '陳大明', 23 | 'SenderCellPhone' => '0911222333', 24 | 'ReceiverName' => '王小美', 25 | 'ReceiverCellPhone' => '0933222111', 26 | 27 | // 請參考 example/Logistics/Domestic/GetLogisticStatueResponse.php 範例開發 28 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 29 | 30 | // 請參考 example/Logistics/Domestic/GetMapResponse.php 範例取得 31 | 'ReceiverStoreID' => '006598', 32 | ]; 33 | $url = 'https://logistics-stage.ecpay.com.tw/Express/Create'; 34 | 35 | $response = $postService->post($input, $url); 36 | var_dump($response); 37 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/CreateCvsForm.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'LogisticsType' => 'CVS', 19 | 'LogisticsSubType' => 'FAMI', 20 | 'GoodsAmount' => 1000, 21 | 'GoodsName' => '綠界 SDK 範例商品', 22 | 'SenderName' => '陳大明', 23 | 'SenderCellPhone' => '0911222333', 24 | 'ReceiverName' => '王小美', 25 | 'ReceiverCellPhone' => '0933222111', 26 | 27 | // 請參考 example/Logistics/Domestic/GetLogisticStatueResponse.php 範例開發 28 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 29 | 'ClientReplyURL' => 'https://www.ecpay.com.tw/example/client-reply', 30 | 31 | // 請參考 example/Logistics/Domestic/GetMapResponse.php 範例取得 32 | 'ReceiverStoreID' => '006598' 33 | ]; 34 | $action = 'https://logistics-stage.ecpay.com.tw/Express/Create'; 35 | 36 | echo $autoSubmitFormService->generate($input, $action); 37 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/CreateHome.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvEncodedStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'LogisticsType' => 'HOME', 19 | 'LogisticsSubType' => 'TCAT', 20 | 'GoodsAmount' => 1000, 21 | 'GoodsName' => '綠界 SDK 範例商品', 22 | 'SenderName' => '陳大明', 23 | 'SenderCellPhone' => '0911222333', 24 | 'SenderZipCode' => '11560', 25 | 'SenderAddress' => '台北市南港區三重路19-2號6樓', 26 | 'ReceiverName' => '王小美', 27 | 'ReceiverCellPhone' => '0933222111', 28 | 'ReceiverZipCode' => '11560', 29 | 'ReceiverAddress' => '台北市南港區三重路19-2號6樓', 30 | 'Temperature' => '0001', 31 | 'Distance' => '00', 32 | 'Specification' => '0001', 33 | 'ScheduledPickupTime' => '4', 34 | 'ScheduledDeliveryTime' => '4', 35 | 36 | // 請參考 example/Logistics/Domestic/GetLogisticStatueResponse.php 範例開發 37 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 38 | ]; 39 | $url = 'https://logistics-stage.ecpay.com.tw/Express/Create'; 40 | 41 | $response = $postService->post($input, $url); 42 | var_dump($response); 43 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/CreateHomeForm.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'LogisticsType' => 'HOME', 19 | 'LogisticsSubType' => 'TCAT', 20 | 'GoodsAmount' => 1000, 21 | 'GoodsName' => '綠界 SDK 範例商品', 22 | 'SenderName' => '陳大明', 23 | 'SenderCellPhone' => '0911222333', 24 | 'SenderZipCode' => '11560', 25 | 'SenderAddress' => '台北市南港區三重路19-2號6樓', 26 | 'ReceiverName' => '王小美', 27 | 'ReceiverCellPhone' => '0933222111', 28 | 'ReceiverZipCode' => '11560', 29 | 'ReceiverAddress' => '台北市南港區三重路19-2號6樓', 30 | 'Temperature' => '0001', 31 | 'Distance' => '00', 32 | 'Specification' => '0001', 33 | 'ScheduledPickupTime' => '4', 34 | 'ScheduledDeliveryTime' => '4', 35 | 36 | // 請參考 example/Logistics/Domestic/GetLogisticStatueResponse.php 範例開發 37 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 38 | 'ClientReplyURL' => 'https://www.ecpay.com.tw/example/client-reply', 39 | ]; 40 | $action = 'https://logistics-stage.ecpay.com.tw/Express/Create'; 41 | 42 | echo $autoSubmitFormService->generate($input, $action); 43 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/CreateTestData.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'LogisticsSubType' => 'FAMI', 17 | 18 | // 請參考 example/Logistics/Domestic/GetCreateTestDataResponse.php 範例開發 19 | 'ClientReplyURL' => 'https://www.ecpay.com.tw/example/client-reply', 20 | 21 | ]; 22 | $action = 'https://logistics-stage.ecpay.com.tw/Express/CreateTestData'; 23 | 24 | echo $autoSubmitFormService->generate($input, $action); 25 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/CreateUnimartFreeze.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvEncodedStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'LogisticsType' => 'CVS', 19 | 'LogisticsSubType' => 'UNIMARTFREEZE', 20 | 'GoodsAmount' => 1000, 21 | 'GoodsName' => '綠界 SDK 範例商品', 22 | 'SenderName' => '陳大明', 23 | 'SenderCellPhone' => '0911222333', 24 | 'ReceiverName' => '王小美', 25 | 'ReceiverCellPhone' => '0933222111', 26 | 27 | // 請參考 example/Logistics/Domestic/GetLogisticStatueResponse.php 範例開發 28 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 29 | 30 | // 請參考 example/Logistics/Domestic/GetMapResponse.php 範例取得 31 | 'ReceiverStoreID' => '896539', 32 | ]; 33 | $url = 'https://logistics-stage.ecpay.com.tw/Express/Create'; 34 | 35 | $response = $postService->post($input, $url); 36 | var_dump($response); 37 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/GetCreateTestDataResponse.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 10 | 'hashIv' => 'v77hoKGq4kWxNNIS', 11 | 'hashMethod' => 'md5', 12 | ]); 13 | $checkoutResponse = $factory->create(VerifiedArrayResponse::class); 14 | 15 | var_dump($checkoutResponse->get($_POST)); 16 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/GetLogisticStatueResponse.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 10 | 'hashIv' => 'v77hoKGq4kWxNNIS', 11 | 'hashMethod' => 'md5', 12 | ]); 13 | $checkoutResponse = $factory->create(VerifiedArrayResponse::class); 14 | 15 | var_dump($checkoutResponse->get($_POST)); 16 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/GetMapResponse.php: -------------------------------------------------------------------------------- 1 | create(ArrayResponse::class); 10 | 11 | var_dump($response->get($_POST)); 12 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/GetReturnResponse.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 10 | 'hashIv' => 'v77hoKGq4kWxNNIS', 11 | 'hashMethod' => 'md5', 12 | ]); 13 | $checkoutResponse = $factory->create(VerifiedArrayResponse::class); 14 | 15 | var_dump($checkoutResponse->get($_POST)); 16 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/GetStoreList.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvJsonResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 17 | // 超商類別(最新類別請參考開發文件: https://developers.ecpay.com.tw/?p=47496) 18 | // 1. All 19 | // 2. FAMI: 全家 20 | // 3. UNIMART: 7-ELEVEN超商(常溫) 21 | // 4. HILIFE: 萊爾富 22 | // 5. OKMART: OK超商 23 | // 6. UNIMARTFREEZE: 7-ELEVEN超商(冷鏈) 24 | 'CvsType' => 'All', 25 | ]; 26 | $url = 'https://logistics-stage.ecpay.com.tw/Helper/GetStoreList'; 27 | 28 | $response = $postService->post($input, $url); 29 | var_dump($response); 30 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/Map.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'LogisticsType' => 'CVS', 18 | 'LogisticsSubType' => 'FAMI', 19 | 'IsCollection' => 'N', 20 | 21 | // 請參考 example/Logistics/Domestic/GetMapResponse.php 範例開發 22 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 23 | ]; 24 | $action = 'https://logistics-stage.ecpay.com.tw/Express/map'; 25 | 26 | echo $autoSubmitFormService->generate($input, $action); 27 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/PrintFamic2cOrderInfo.php: -------------------------------------------------------------------------------- 1 | 'XBERn1YOvpM9nfZc', 9 | 'hashIv' => 'h1ONHk4P4yqbl5LK', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000933', 16 | 'AllPayLogisticsID' => '1717813', 17 | 'CVSPaymentNo' => '11000062128', 18 | ]; 19 | $action = 'https://logistics-stage.ecpay.com.tw/Express/PrintFAMIC2COrderInfo'; 20 | 21 | echo $autoSubmitFormService->generate($input, $action); 22 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/PrintHilifec2cOrderInfo.php: -------------------------------------------------------------------------------- 1 | 'XBERn1YOvpM9nfZc', 9 | 'hashIv' => 'h1ONHk4P4yqbl5LK', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000933', 16 | 'AllPayLogisticsID' => '1717823', 17 | 'CVSPaymentNo' => '161D54490371', 18 | ]; 19 | $action = 'https://logistics-stage.ecpay.com.tw/Express/PrintHILIFEC2COrderInfo'; 20 | 21 | echo $autoSubmitFormService->generate($input, $action); 22 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/PrintOkmartc2cOrderInfo.php: -------------------------------------------------------------------------------- 1 | 'XBERn1YOvpM9nfZc', 9 | 'hashIv' => 'h1ONHk4P4yqbl5LK', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000933', 16 | 'AllPayLogisticsID' => '1717858', 17 | 'CVSPaymentNo' => 'W5254579754', 18 | ]; 19 | $action = 'https://logistics-stage.ecpay.com.tw/Express/PrintOKMARTC2COrderInfo'; 20 | 21 | echo $autoSubmitFormService->generate($input, $action); 22 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/PrintTradeDocument.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'AllPayLogisticsID' => '1717876', 17 | ]; 18 | $action = 'https://logistics-stage.ecpay.com.tw/helper/printTradeDocument'; 19 | 20 | echo $autoSubmitFormService->generate($input, $action); 21 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/PrintUniMartc2cOrderInfo.php: -------------------------------------------------------------------------------- 1 | 'XBERn1YOvpM9nfZc', 9 | 'hashIv' => 'h1ONHk4P4yqbl5LK', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000933', 16 | 'AllPayLogisticsID' => '1717812', 17 | 'CVSPaymentNo' => 'C9680734', 18 | 'CVSValidationNo' => '4551', 19 | ]; 20 | $action = 'https://logistics-stage.ecpay.com.tw/Express/PrintUniMartC2COrderInfo'; 21 | 22 | echo $autoSubmitFormService->generate($input, $action); 23 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/QueryLogisticsTradeInfo.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvVerifiedEncodedStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'AllPayLogisticsID' => '1718546', 17 | 'TimeStamp' => time(), 18 | ]; 19 | $url = 'https://logistics-stage.ecpay.com.tw/Helper/QueryLogisticsTradeInfo/V2'; 20 | 21 | $response = $postService->post($input, $url); 22 | var_dump($response); 23 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/ReturnFamiCvs.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'GoodsAmount' => 1000, 17 | 'ServiceType' => '4', 18 | 'SenderName' => '陳大明', 19 | 20 | // 請參考 example/Logistics/Domestic/GetReturnResponse.php 範例開發 21 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 22 | ]; 23 | $url = 'https://logistics-stage.ecpay.com.tw/express/ReturnCVS'; 24 | 25 | $response = $postService->post($input, $url); 26 | var_dump($response); 27 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/ReturnHome.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'AllPayLogisticsID' => '1718537', 17 | 'GoodsAmount' => 1000, 18 | 'Temperature' => '0001', 19 | 'Distance' => '00', 20 | 21 | // 請參考 example/Logistics/Domestic/GetReturnResponse.php 範例開發 22 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 23 | ]; 24 | $url = 'https://logistics-stage.ecpay.com.tw/Express/ReturnHome'; 25 | 26 | $response = $postService->post($input, $url); 27 | var_dump($response); 28 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/ReturnUniMartCvs.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'GoodsAmount' => 1000, 17 | 'ServiceType' => '4', 18 | 'SenderName' => '陳大明', 19 | 20 | // 請參考 example/Logistics/Domestic/GetReturnResponse.php 範例開發 21 | 'ServerReplyURL' => 'https://www.ecpay.com.tw/example/server-reply', 22 | ]; 23 | $url = 'https://logistics-stage.ecpay.com.tw/express/ReturnUniMartCVS'; 24 | 25 | $response = $postService->post($input, $url); 26 | var_dump($response); 27 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/UpdateShipmentInfo.php: -------------------------------------------------------------------------------- 1 | '5294y06JbISpM5x9', 9 | 'hashIv' => 'v77hoKGq4kWxNNIS', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000132', 16 | 'AllPayLogisticsID' => '1718550', 17 | 'ShipmentDate' => date('Y/m/d'), 18 | ]; 19 | $url = 'https://logistics-stage.ecpay.com.tw/Helper/UpdateShipmentInfo'; 20 | 21 | $response = $postService->post($input, $url); 22 | var_dump($response); 23 | -------------------------------------------------------------------------------- /example/Logistics/Domestic/UpdateStoreInfo.php: -------------------------------------------------------------------------------- 1 | 'XBERn1YOvpM9nfZc', 9 | 'hashIv' => 'h1ONHk4P4yqbl5LK', 10 | 'hashMethod' => 'md5', 11 | ]); 12 | $postService = $factory->create('PostWithCmvStrResponseService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '2000933', 16 | 'AllPayLogisticsID' => '1718552', 17 | 'CVSPaymentNo' => 'C9681067', 18 | 'CVSValidationNo' => '2448', 19 | 'StoreType' => '01', 20 | 'ReceiverStoreID' => '131386', 21 | ]; 22 | $url = 'https://logistics-stage.ecpay.com.tw/Express/UpdateStoreInfo'; 23 | 24 | $response = $postService->post($input, $url); 25 | var_dump($response); 26 | -------------------------------------------------------------------------------- /example/Logistics/crossborder_logistics_status.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ECPay/SDK_PHP/e25fcc04f43f52bce152167d040826ebebb70fe4/example/Logistics/crossborder_logistics_status.xlsx -------------------------------------------------------------------------------- /example/Logistics/logistics_history.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ECPay/SDK_PHP/e25fcc04f43f52bce152167d040826ebebb70fe4/example/Logistics/logistics_history.xlsx -------------------------------------------------------------------------------- /example/Logistics/logistics_status.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ECPay/SDK_PHP/e25fcc04f43f52bce152167d040826ebebb70fe4/example/Logistics/logistics_status.xlsx -------------------------------------------------------------------------------- /example/Payment/Aio/Capture.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithCmvEncodedStrResponseService'); 12 | 13 | $input = [ 14 | 'MerchantID' => '3002607', 15 | 'MerchantTradeNo' => '5fa271cc74e51', 16 | 'TradeNo' => '2011041718071855', 17 | 'Action' => 'C', 18 | 'TotalAmount' => 8685, 19 | ]; 20 | $url = 'https://payment-stage.ecpay.com.tw/CreditDetail/DoAction'; 21 | 22 | $response = $postService->post($input, $url); 23 | var_dump($response); 24 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateAtmOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'ATM', 23 | 'EncryptType' => 1, 24 | 25 | // ATM 專用參數 26 | 'ExpireDate' => 7, 27 | 28 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 29 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 30 | 'PaymentInfoURL' => 'https://www.ecpay.com.tw/example/payment-info', 31 | ]; 32 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 33 | 34 | echo $autoSubmitFormService->generate($input, $action); 35 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateBarcodeOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'BARCODE', 23 | 'EncryptType' => 1, 24 | 25 | // Barcode 專用參數 26 | 'StoreExpireDate' => 5, 27 | 'Desc_1' => '範例交易描述 1', 28 | 'Desc_2' => '範例交易描述 2', 29 | 'Desc_3' => '範例交易描述 3', 30 | 'Desc_4' => '範例交易描述 4', 31 | 32 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 33 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 34 | 'PaymentInfoURL' => 'https://www.ecpay.com.tw/example/payment-info', 35 | ]; 36 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 37 | 38 | echo $autoSubmitFormService->generate($input, $action); 39 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateBnplOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 3000, // 金額須大於2999 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'BNPL', 23 | 'EncryptType' => 1, 24 | 25 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 26 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 27 | ]; 28 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 29 | 30 | echo $autoSubmitFormService->generate($input, $action); 31 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateCreditOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'Credit', 23 | 'EncryptType' => 1, 24 | 25 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 26 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 27 | ]; 28 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 29 | 30 | echo $autoSubmitFormService->generate($input, $action); 31 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateCvsOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'CVS', 23 | 'EncryptType' => 1, 24 | 25 | // CVS 專用參數 26 | 'StoreExpireDate' => 4320, 27 | 'Desc_1' => '範例交易描述 1', 28 | 'Desc_2' => '範例交易描述 2', 29 | 'Desc_3' => '範例交易描述 3', 30 | 'Desc_4' => '範例交易描述 4', 31 | 32 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 33 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 34 | 'PaymentInfoURL' => 'https://www.ecpay.com.tw/example/payment-info', 35 | ]; 36 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 37 | 38 | echo $autoSubmitFormService->generate($input, $action); 39 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateInstallmentOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'Credit', 23 | 'EncryptType' => 1, 24 | 25 | // 信用卡分期專用參數 26 | 'CreditInstallment' => '3,6,18', 27 | 28 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 29 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 30 | ]; 31 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 32 | 33 | echo $autoSubmitFormService->generate($input, $action); 34 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'ALL', 23 | 'EncryptType' => 1, 24 | 25 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 26 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 27 | ]; 28 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 29 | 30 | echo $autoSubmitFormService->generate($input, $action); 31 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreatePeriodicOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 23 | 'ChoosePayment' => 'Credit', 24 | 'EncryptType' => 1, 25 | 26 | // 定期定額專用參數 27 | 'PeriodAmount' => 100, 28 | 'PeriodType' => 'M', 29 | 'Frequency' => 1, 30 | 'ExecTimes' => 6, 31 | 32 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 33 | 'PeriodReturnURL' => 'https://www.ecpay.com.tw/example/receive', 34 | ]; 35 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 36 | 37 | echo $autoSubmitFormService->generate($input, $action); 38 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateTwqrOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ChoosePayment' => 'TWQR', 23 | 'EncryptType' => 1, 24 | 25 | // 請參考 example/Payment/GetCheckoutResponse.php 範例開發 26 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 27 | ]; 28 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 29 | 30 | echo $autoSubmitFormService->generate($input, $action); 31 | -------------------------------------------------------------------------------- /example/Payment/Aio/CreateWebAtmOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 13 | 14 | $input = [ 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => 'Test' . time(), 17 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 18 | 'PaymentType' => 'aio', 19 | 'TotalAmount' => 100, 20 | 'TradeDesc' => UrlService::ecpayUrlEncode('交易描述範例'), 21 | 'ItemName' => '範例商品一批 100 TWD x 1', 22 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 23 | 'ChoosePayment' => 'WebATM', 24 | 'EncryptType' => 1, 25 | ]; 26 | $action = 'https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5'; 27 | 28 | echo $autoSubmitFormService->generate($input, $action); 29 | -------------------------------------------------------------------------------- /example/Payment/Aio/DownloadCreditReconcileCsv.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 12 | 13 | $input = [ 14 | 'MerchantID' => '3002607', 15 | 'PayDateType' => 'close', 16 | 'StartDate' => '2015-02-12', 17 | 'EndDate' => '2015-02-12', 18 | ]; 19 | $action = 'https://payment-stage.ecpay.com.tw/CreditDetail/FundingReconDetail'; 20 | 21 | echo $autoSubmitFormService->generate($input, $action); 22 | -------------------------------------------------------------------------------- /example/Payment/Aio/DownloadReconcileCsv.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $autoSubmitFormService = $factory->create('AutoSubmitFormWithCmvService'); 12 | 13 | $input = [ 14 | 'MerchantID' => '3002607', 15 | 'DateType' => '2', 16 | 'BeginDate' => '2015-02-12', 17 | 'EndDate' => '2015-02-12', 18 | 'MediaFormated' => '0', 19 | ]; 20 | $action = 'https://vendor-stage.ecpay.com.tw/PaymentMedia/TradeNoAio'; 21 | 22 | echo $autoSubmitFormService->generate($input, $action); 23 | -------------------------------------------------------------------------------- /example/Payment/Aio/GetCheckoutResponse.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $checkoutResponse = $factory->create(VerifiedArrayResponse::class); 13 | 14 | // 模擬綠界付款結果回傳格式範例,非真實付款結果 15 | $_POST = [ 16 | 'MerchantID' => '3002607', 17 | 'MerchantTradeNo' => 'WPLL4E341E122DB44D62', 18 | 'PaymentDate' => '2019/05/09 00:01:21', 19 | 'PaymentType' => 'Credit_CreditCard', 20 | 'PaymentTypeChargeFee' => '1', 21 | 'RtnCode' => '1', 22 | 'RtnMsg' => '交易成功', 23 | 'SimulatePaid' => '0', 24 | 'TradeAmt' => '500', 25 | 'TradeDate' => '2019/05/09 00:00:18', 26 | 'TradeNo' => '1905090000188278', 27 | 'CheckMacValue' => '6E7F053EF215FC851A050A2FF01D72CBE440EA138DC3E905647985DDF236FD25', 28 | ]; 29 | 30 | var_dump($checkoutResponse->get($_POST)); 31 | -------------------------------------------------------------------------------- /example/Payment/Aio/QueryCreditTrade.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithCmvJsonResponseService'); 12 | 13 | $parameters = [ 14 | 'MerchantID' => '3002607', 15 | 'CreditRefundId' => 13475885, 16 | 'CreditAmount' => 100, 17 | 'CreditCheckCode' => 62861749, 18 | ]; 19 | $url = 'https://payment-stage.ecPay.com.tw/CreditDetail/QueryTrade/V2'; 20 | 21 | $response = $postService->post($parameters, $url); 22 | var_dump($response); 23 | -------------------------------------------------------------------------------- /example/Payment/Aio/QueryPaymentInfo.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithCmvVerifiedEncodedStrResponseService'); 12 | 13 | $input = [ 14 | 'MerchantID' => '3002607', 15 | 'MerchantTradeNo' => 'Test1732693750', 16 | 'TimeStamp' => time(), 17 | ]; 18 | $url = 'https://payment-stage.ecpay.com.tw/Cashier/QueryPaymentInfo'; 19 | 20 | $response = $postService->post($input, $url); 21 | var_dump($response); 22 | -------------------------------------------------------------------------------- /example/Payment/Aio/QueryPeridicTrade.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithCmvJsonResponseService'); 12 | 13 | $input = [ 14 | 'MerchantID' => '3002607', 15 | 'MerchantTradeNo' => 'Test1732694169', 16 | 'TimeStamp' => time(), 17 | ]; 18 | $url = 'https://payment-stage.ecpay.com.tw/Cashier/QueryCreditCardPeriodInfo'; 19 | 20 | $response = $postService->post($input, $url); 21 | var_dump($response); 22 | -------------------------------------------------------------------------------- /example/Payment/Aio/QueryTrade.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithCmvVerifiedEncodedStrResponseService'); 12 | 13 | $input = [ 14 | 'MerchantID' => '3002607', 15 | 'MerchantTradeNo' => 'Test1732693750', 16 | 'TimeStamp' => time(), 17 | ]; 18 | $url = 'https://payment-stage.ecpay.com.tw/Cashier/QueryTradeInfo/V5'; 19 | 20 | $response = $postService->post($input, $url); 21 | var_dump($response); 22 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/Capture.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'PlatformID' => '3002607', 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => '20180914001', 17 | 'TradeNo' => '1809261503338172', 18 | 'Action' => 'C', 19 | 'TotalAmount' => 100 20 | ]; 21 | 22 | $input = [ 23 | 'MerchantID' => '3002607', 24 | 'RqHeader' => [ 25 | 'Timestamp' => time() 26 | ], 27 | 'Data' => $data 28 | ]; 29 | 30 | $url = 'https://ecpayment-stage.ecpay.com.tw/1.0.0/Credit/DoAction'; 31 | 32 | $response = $postService->post($input, $url); 33 | var_dump($response); 34 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateAllOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "0", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'CardInfo' => [ 30 | 'Redeem' => 0, 31 | 'OrderResultURL' => 'https://www.ecpay.com.tw/example/receive', 32 | 'CreditInstallment' => '3,6,12', 33 | 'FlexibleInstallment' => 30 34 | ], 35 | 'UnionPayInfo' => [ 36 | 'OrderResultURL' => 'https://www.ecpay.com.tw/example/receive' 37 | ], 38 | 'ATMInfo' => [ 39 | 'ExpireDate' => 3 40 | ], 41 | 'CVSInfo' => [ 42 | 'StoreExpireDate' => 10080 43 | ], 44 | 'BarcodeInfo' => [ 45 | 'StoreExpireDate' => 7 46 | ], 47 | 'ConsumerInfo' => [ 48 | 'MerchantMemberID' => 'test123456', 49 | 'Email' => 'customer@email.com', 50 | 'Phone' => '0912345678', 51 | 'Name' => 'Test', 52 | 'CountryCode' => '158' 53 | ] 54 | ]; 55 | 56 | $input = [ 57 | 'MerchantID' => '3002607', 58 | 'RqHeader' => [ 59 | 'Timestamp' => time() 60 | ], 61 | 'Data' => $data 62 | ]; 63 | 64 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 65 | $response = $postService->post($input, $url); 66 | 67 | // 回傳前端畫面所需資訊 68 | $result = [ 69 | 'Token' => $response['Data']['Token'], 70 | 'MerchantTradeNo' => $merchantTradeNo 71 | ]; 72 | 73 | echo(json_encode($result)); 74 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateApplePayOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "7", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'ConsumerInfo' => [ 30 | 'MerchantMemberID' => 'test123456', 31 | 'Email' => 'customer@email.com', 32 | 'Phone' => '0912345678', 33 | 'Name' => 'Test', 34 | 'CountryCode' => '158' 35 | ] 36 | ]; 37 | 38 | $input = [ 39 | 'MerchantID' => '3002607', 40 | 'RqHeader' => [ 41 | 'Timestamp' => time() 42 | ], 43 | 'Data' => $data 44 | ]; 45 | 46 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 47 | $response = $postService->post($input, $url); 48 | 49 | // 回傳前端畫面所需資訊 50 | $result = [ 51 | 'Token' => $response['Data']['Token'], 52 | 'MerchantTradeNo' => $merchantTradeNo 53 | ]; 54 | 55 | echo(json_encode($result)); 56 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateApplePayOrder/WebJS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 綠界科技 ECPay - 第三方支付領導品牌 13 | 14 | 15 |
16 |
17 | 53 |
54 | 55 | 56 |
57 | 58 | 59 |
60 |
61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateAtmOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "3", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'ATMInfo' => [ 30 | 'ExpireDate' => 3 31 | ], 32 | 'ConsumerInfo' => [ 33 | 'MerchantMemberID' => 'test123456', 34 | 'Email' => 'customer@email.com', 35 | 'Phone' => '0912345678', 36 | 'Name' => 'Test', 37 | 'CountryCode' => '158' 38 | ] 39 | ]; 40 | 41 | $input = [ 42 | 'MerchantID' => '3002607', 43 | 'RqHeader' => [ 44 | 'Timestamp' => time() 45 | ], 46 | 'Data' => $data 47 | ]; 48 | 49 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 50 | $response = $postService->post($input, $url); 51 | 52 | // 回傳前端畫面所需資訊 53 | $result = [ 54 | 'Token' => $response['Data']['Token'], 55 | 'MerchantTradeNo' => $merchantTradeNo 56 | ]; 57 | 58 | echo(json_encode($result)); 59 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateAtmOrder/WebJS.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 綠界科技 ECPay - 第三方支付領導品牌 13 | 14 | 15 |
16 |
17 | 64 |
65 | 66 | 67 |
68 | 69 | 70 |
71 |
72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateBarcodeOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "5", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'BarcodeInfo' => [ 30 | 'StoreExpireDate' => 7 31 | ], 32 | 'ConsumerInfo' => [ 33 | 'MerchantMemberID' => 'test123456', 34 | 'Email' => 'customer@email.com', 35 | 'Phone' => '0912345678', 36 | 'Name' => 'Test', 37 | 'CountryCode' => '158' 38 | ] 39 | ]; 40 | 41 | $input = [ 42 | 'MerchantID' => '3002607', 43 | 'RqHeader' => [ 44 | 'Timestamp' => time() 45 | ], 46 | 'Data' => $data 47 | ]; 48 | 49 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 50 | $response = $postService->post($input, $url); 51 | 52 | // 回傳前端畫面所需資訊 53 | $result = [ 54 | 'Token' => $response['Data']['Token'], 55 | 'MerchantTradeNo' => $merchantTradeNo 56 | ]; 57 | 58 | echo(json_encode($result)); 59 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateBindCard.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // $_POST['BindCardPayToken'] 請帶入前端 Web 取得的綁定信用卡代碼 BindCardPayToken 14 | $data = [ 15 | 'MerchantID' => '3002607', 16 | 'BindCardPayToken' => $_POST['BindCardPayToken'], 17 | 'MerchantMemberID' => 'testphpsdk3002607' 18 | ]; 19 | 20 | $input = [ 21 | 'MerchantID' => '3002607', 22 | 'RqHeader' => [ 23 | 'Timestamp' => time() 24 | ], 25 | 'Data' => $data 26 | ]; 27 | 28 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/CreateBindCard'; 29 | 30 | $response = $postService->post($input, $url); 31 | echo(json_encode($response)); -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateCreditOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "1", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'CardInfo' => [ 30 | 'Redeem' => 0, 31 | 'OrderResultURL' => 'https://www.ecpay.com.tw/example/receive', 32 | ], 33 | 'ConsumerInfo' => [ 34 | 'MerchantMemberID' => 'test123456', 35 | 'Email' => 'customer@email.com', 36 | 'Phone' => '0912345678', 37 | 'Name' => 'Test', 38 | 'CountryCode' => '158' 39 | ] 40 | ]; 41 | 42 | $input = [ 43 | 'MerchantID' => '3002607', 44 | 'RqHeader' => [ 45 | 'Timestamp' => time() 46 | ], 47 | 'Data' => $data 48 | ]; 49 | 50 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 51 | $response = $postService->post($input, $url); 52 | 53 | // 回傳前端畫面所需資訊 54 | $result = [ 55 | 'Token' => $response['Data']['Token'], 56 | 'MerchantTradeNo' => $merchantTradeNo 57 | ]; 58 | 59 | echo(json_encode($result)); 60 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateCvsOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "4", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'CVSInfo' => [ 30 | 'StoreExpireDate' => 10080 31 | ], 32 | 'ConsumerInfo' => [ 33 | 'MerchantMemberID' => 'test123456', 34 | 'Email' => 'customer@email.com', 35 | 'Phone' => '0912345678', 36 | 'Name' => 'Test', 37 | 'CountryCode' => '158' 38 | ] 39 | ]; 40 | 41 | $input = [ 42 | 'MerchantID' => '3002607', 43 | 'RqHeader' => [ 44 | 'Timestamp' => time() 45 | ], 46 | 'Data' => $data 47 | ]; 48 | 49 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 50 | $response = $postService->post($input, $url); 51 | 52 | // 回傳前端畫面所需資訊 53 | $result = [ 54 | 'Token' => $response['Data']['Token'], 55 | 'MerchantTradeNo' => $merchantTradeNo 56 | ]; 57 | 58 | echo(json_encode($result)); 59 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateInstallmentOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "2,8", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'CardInfo' => [ 30 | 'Redeem' => 0, 31 | 'OrderResultURL' => 'https://www.ecpay.com.tw/example/receive', 32 | 'CreditInstallment' => '3,6,12', 33 | 'FlexibleInstallment' => 30 // 圓夢分期 34 | ], 35 | 'ConsumerInfo' => [ 36 | 'MerchantMemberID' => 'test123456', 37 | 'Email' => 'customer@email.com', 38 | 'Phone' => '0912345678', 39 | 'Name' => 'Test', 40 | 'CountryCode' => '158' 41 | ] 42 | ]; 43 | 44 | $input = [ 45 | 'MerchantID' => '3002607', 46 | 'RqHeader' => [ 47 | 'Timestamp' => time() 48 | ], 49 | 'Data' => $data 50 | ]; 51 | 52 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 53 | $response = $postService->post($input, $url); 54 | 55 | // 回傳前端畫面所需資訊 56 | $result = [ 57 | 'Token' => $response['Data']['Token'], 58 | 'MerchantTradeNo' => $merchantTradeNo 59 | ]; 60 | 61 | echo(json_encode($result)); 62 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateOrder.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // $_POST['PayToken'] 為取得對應模擬前端發送的 PayToken input 欄位 14 | // $_POST['MerchantTradeNo'] 須與取得 Token 時的 MerchantTradeNo 欄位相同 15 | $data = [ 16 | 'MerchantID' => '3002607', 17 | 'PayToken' => $_POST['PayToken'], 18 | 'MerchantTradeNo' => $_POST['MerchantTradeNo'] 19 | ]; 20 | 21 | $input = [ 22 | 'MerchantID' => '3002607', 23 | 'RqHeader' => [ 24 | 'Timestamp' => time() 25 | ], 26 | 'Data' => $data 27 | ]; 28 | 29 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/CreatePayment'; 30 | 31 | $response = $postService->post($input, $url); 32 | echo(json_encode($response)); -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreatePaymentWithCardID.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // $_POST['BindCardID'] 請帶入綁定信用卡時取得的綁定信用卡代碼 BindCardID 14 | $merchantTradeNo = 'test' . time(); 15 | $data = [ 16 | 'PlatformID' => '', 17 | 'MerchantID' => '3002607', 18 | 'BindCardID' => $_POST['BindCardID'], 19 | 'OrderInfo' => [ 20 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 21 | 'MerchantTradeNo' => $merchantTradeNo, 22 | 'TotalAmount' => '100', 23 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 24 | 'TradeDesc' => 'DESC', 25 | 'ItemName' => 'Test' 26 | ], 27 | 'ConsumerInfo' => [ 28 | 'MerchantMemberID' => 'testphpsdk3002607', 29 | 'Email' => 'customer@email.com', 30 | 'Phone' => '0912345678', 31 | 'Name' => 'Test', 32 | 'CountryCode' => '158', 33 | 'Address' => '', 34 | ], 35 | 'CustomField' => '', 36 | ]; 37 | 38 | $input = [ 39 | 'MerchantID' => '3002607', 40 | 'RqHeader' => [ 41 | 'Timestamp' => time() 42 | ], 43 | 'Data' => $data 44 | ]; 45 | 46 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/CreatePaymentWithCardID'; 47 | 48 | $response = $postService->post($input, $url); 49 | echo(json_encode($response)); -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreateUnionPayOrder/GetToken.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // 請依照平台商提供的付款方式參照 API 文件調整 $data 中的參數 14 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9040) 15 | $merchantTradeNo = 'test' . time(); 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'RememberCard' => 1, 19 | 'PaymentUIType' => 2, 20 | 'ChoosePaymentList' => "6", 21 | 'OrderInfo' => [ 22 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 23 | 'MerchantTradeNo' => $merchantTradeNo, 24 | 'TotalAmount' => '100', 25 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive', 26 | 'TradeDesc' => 'DESC', 27 | 'ItemName' => 'Test' 28 | ], 29 | 'UnionPayInfo' => [ 30 | 'OrderResultURL' => 'https://www.ecpay.com.tw/example/receive', 31 | ], 32 | 'ConsumerInfo' => [ 33 | 'MerchantMemberID' => 'test123456', 34 | 'Email' => 'customer@email.com', 35 | 'Phone' => '0912345678', 36 | 'Name' => 'Test', 37 | 'CountryCode' => '158' 38 | ] 39 | ]; 40 | 41 | $input = [ 42 | 'MerchantID' => '3002607', 43 | 'RqHeader' => [ 44 | 'Timestamp' => time() 45 | ], 46 | 'Data' => $data 47 | ]; 48 | 49 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyTrade'; 50 | $response = $postService->post($input, $url); 51 | 52 | // 回傳前端畫面所需資訊 53 | $result = [ 54 | 'Token' => $response['Data']['Token'], 55 | 'MerchantTradeNo' => $merchantTradeNo 56 | ]; 57 | 58 | echo(json_encode($result)); 59 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/CreditPeriodAction.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'PlatformID' => '3002607', 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => '123486456', 17 | 'Action' => 'ReAuth', 18 | ]; 19 | 20 | $input = [ 21 | 'MerchantID' => '3002607', 22 | 'RqHeader' => [ 23 | 'Timestamp' => time() 24 | ], 25 | 'Data' => $data 26 | ]; 27 | 28 | $url = 'https://ecpayment-stage.ecpay.com.tw/1.0.0/Cashier/CreditCardPeriodAction'; 29 | 30 | $response = $postService->post($input, $url); 31 | var_dump($response); 32 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/DeleteCredit.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'MerchantID' => '3002607', 15 | 'ConsumerInfo' => [ 16 | 'MerchantMemberID' => 'test123456', 17 | 'Email' => 'customer@email.com', 18 | 'Phone' => '0912345678', 19 | 'Name' => 'Test', 20 | 'CountryCode' => '158' 21 | ] 22 | ]; 23 | 24 | $input = [ 25 | 'MerchantID' => '3002607', 26 | 'RqHeader' => [ 27 | 'Timestamp' => time() 28 | ], 29 | 'Data' => $data 30 | ]; 31 | 32 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyUser'; 33 | 34 | $response = $postService->post($input, $url); 35 | var_dump($response); -------------------------------------------------------------------------------- /example/Payment/Ecpg/DeleteMemberBindCard.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // $_POST['BindCardID'] 請帶入綁定信用卡時取得的綁定信用卡代碼 BindCardID 14 | $data = [ 15 | 'PlatformID' => '', 16 | 'MerchantID' => '3002607', 17 | 'BindCardID' => $_POST['BindCardID'] 18 | ]; 19 | 20 | $input = [ 21 | 'MerchantID' => '3002607', 22 | 'RqHeader' => [ 23 | 'Timestamp' => time() 24 | ], 25 | 'Data' => $data 26 | ]; 27 | 28 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/DeleteMemberBindCard'; 29 | 30 | $response = $postService->post($input, $url); 31 | echo(json_encode($response)); -------------------------------------------------------------------------------- /example/Payment/Ecpg/GetCreateBindCardResponse.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $AesService = $factory->create(AesService::class); 13 | 14 | // 模擬綠界綁定信用卡結果通知 OrderResultURL,完整回傳內容請參閱 API 文件 15 | // (參考開發文件: https://developers.ecpay.com.tw/?p=35606) 16 | // $data = [ 17 | // 'PlatformID' => '', 18 | // 'MerchantID' => '3002607', 19 | // 'MerchantMemberID' => 'testphpsdk3002607', 20 | // 'BindCardID' => '9814a32ed10c4dcea2209b786146ddeb61bb92d2bc3d49b8b7c9f1333f5c2236', 21 | // 'IsSameCard' => true, 22 | // 'CardInfo' => [ 23 | // 'Card6No' => '431195', 24 | // 'Card4No' => '2222', 25 | // 'CardValidYY' => '25', 26 | // 'CardValidMM' => '12', 27 | // 'AuthCode' => '777777', 28 | // 'Gwsr' => 13118888, 29 | // 'ProcessDate' => '2024/03/04 16:36:54', 30 | // 'Amount' => 100, 31 | // 'Eci' => 0, 32 | // 'Stage' => 0, 33 | // 'Stast' => 0, 34 | // 'Staed' => 0 35 | // ], 36 | // 'CustomField' => '', 37 | // 'OrderInfo' => [ 38 | // 'MerchantTradeNo' => 'test1709541383', 39 | // 'TradeNo' => '2403041636445569', 40 | // 'PaymentDate' => '2024/03/04 16:36:54', 41 | // 'TradeAmt' => 100, 42 | // 'PaymentType' => 'Credit', 43 | // 'TradeDate' => '2024/03/04 16:36:44', 44 | // 'ChargeFee' => 2.45, 45 | // 'TradeStatus' => '1' 46 | // ], 47 | // 'RtnCode' => 1, 48 | // 'RtnMsg' => 'Success' 49 | // ]; 50 | 51 | // $resultData = [ 52 | // 'MerchantID' => '3002607', 53 | // 'RpHeader' => null, 54 | // 'TransCode' => 1, 55 | // 'TransMsg' => 'Success!', 56 | // 'Data' => $AesService->encrypt($data) 57 | // ]; 58 | 59 | // $_POST = [ 60 | // 'ResultData' => json_encode($resultData) 61 | // ]; 62 | 63 | // 處理綠界回傳綁定信用卡結果 64 | $resultData = $_POST['ResultData']; 65 | $resultData = json_decode($resultData, true); 66 | 67 | // AES 解密 68 | $decrypt = $AesService->decrypt($resultData['Data']); 69 | 70 | echo(json_encode($decrypt)); 71 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/GetMemberBindCard.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // $_POST['MerchantTradeNo'] 須與綁定信用卡交易時的 MerchantTradeNo 欄位相同 14 | $data = [ 15 | 'PlatformID' => '', 16 | 'MerchantID' => '3002607', 17 | 'MerchantMemberID' => 'testphpsdk3002607', 18 | 'MerchantTradeNo' => $_POST['MerchantTradeNo'] 19 | ]; 20 | 21 | $input = [ 22 | 'MerchantID' => '3002607', 23 | 'RqHeader' => [ 24 | 'Timestamp' => time() 25 | ], 26 | 'Data' => $data 27 | ]; 28 | 29 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetMemberBindCard'; 30 | 31 | $response = $postService->post($input, $url); 32 | echo(json_encode($response)); -------------------------------------------------------------------------------- /example/Payment/Ecpg/GetResponse.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 10 | 'hashIv' => 'EkRm7iFT261dpevs', 11 | ]); 12 | $AesService = $factory->create(AesService::class); 13 | 14 | // 模擬對送綠界回傳付款資訊的加密 Data 進行解密,實際串接請參閱 API 文件 15 | // (參考開發文件: https://developers.ecpay.com.tw/?p=9058#) 16 | $data = [ 17 | 'RtnCode' => 1, 18 | 'RtnMsg' => 'Success', 19 | 'PlatformID' => '3002607', 20 | 'MerchantID' => '3002607', 21 | 'Token' => 'm12dae4846446sq', 22 | 'TokenExpireDate' => date('Y/m/d H:i:s') 23 | ]; 24 | 25 | // 模擬界回傳付款資訊的加密資料,AES 加密 26 | $encryptData = $AesService->encrypt($data); 27 | 28 | $input = [ 29 | 'MerchantID' => '3002607', 30 | 'RpHeader' => [ 31 | 'Timestamp' => time() 32 | ], 33 | 'TransCode' => 1, 34 | 'TransMsg' => 'Success', 35 | 'Data' => $encryptData 36 | ]; 37 | 38 | // AES 解密 39 | $decrypt = $AesService->decrypt($input['Data']); 40 | 41 | echo(json_encode($decrypt)); 42 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/GetTokenbyBindingCard.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | // API 參數設定 14 | // (完整參數列表請參閱 API 文件: https://developers.ecpay.com.tw/?p=35591) 15 | $merchantTradeNo = 'test' . time(); 16 | $protocol = 'http'; 17 | if (isset($_SERVER['HTTPS'])){ 18 | $protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http"; 19 | } 20 | $orderResultURL = $protocol . '://' . $_SERVER['SERVER_NAME'] . '/example/Payment/Ecpg/GetCreateBindCardResponse.php'; 21 | 22 | $data = [ 23 | 'PlatformID' => '', 24 | 'MerchantID' => '3002607', 25 | 'ConsumerInfo' => [ 26 | 'MerchantMemberID' => 'testphpsdk3002607', 27 | 'Email' => 'customer@email.com', 28 | 'Phone' => '0912345678', 29 | 'Name' => 'Test', 30 | 'CountryCode' => '158' 31 | ], 32 | 'OrderInfo' => [ 33 | 'MerchantTradeDate' => date('Y/m/d H:i:s'), 34 | 'MerchantTradeNo' => $merchantTradeNo, 35 | 'TotalAmount' => '100', 36 | 'TradeDesc' => '綁卡交易描述', 37 | 'ItemName' => '交易名稱', 38 | 'ReturnURL' => 'https://www.ecpay.com.tw/example/receive' 39 | ], 40 | 41 | // 請參考 example/Payment/Ecpg/GetCreateBindCardResponse.php 範例開發 42 | 'OrderResultURL' => $orderResultURL, 43 | 'CustomField' => '自訂欄位', 44 | ]; 45 | 46 | $input = [ 47 | 'MerchantID' => '3002607', 48 | 'RqHeader' => [ 49 | 'Timestamp' => time() 50 | ], 51 | 'Data' => $data 52 | ]; 53 | 54 | $url = 'https://ecpg-stage.ecpay.com.tw/Merchant/GetTokenbyBindingCard'; 55 | 56 | $response = $postService->post($input, $url); 57 | 58 | // 回傳前端畫面所需資訊 59 | $result = [ 60 | 'Token' => $response['Data']['Token'], 61 | 'MerchantTradeNo' => $merchantTradeNo 62 | ]; 63 | 64 | echo(json_encode($result)); -------------------------------------------------------------------------------- /example/Payment/Ecpg/QueryCreditTrade.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'PlatformID' => '3002607', 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => '20180914001' 17 | ]; 18 | 19 | $input = [ 20 | 'MerchantID' => '3002607', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time() 23 | ], 24 | 'Data' => $data 25 | ]; 26 | 27 | $url = 'https://ecpayment-stage.ecpay.com.tw/1.0.0/CreditDetail/QueryTrade'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/QueryPaymentInfo.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'PlatformID' => '3002607', 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => '123486456', 17 | ]; 18 | 19 | $input = [ 20 | 'MerchantID' => '3002607', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time() 23 | ], 24 | 'Data' => $data 25 | ]; 26 | 27 | $url = 'https://ecpayment-stage.ecpay.com.tw/1.0.0/Cashier/QueryPaymentInfo'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/QueryPeridicTrade.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'PlatformID' => '3002607', 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => '20180914001', 17 | ]; 18 | 19 | $input = [ 20 | 'MerchantID' => '3002607', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time() 23 | ], 24 | 'Data' => $data 25 | ]; 26 | 27 | $url = 'https://ecpayment-stage.ecpay.com.tw/1.0.0/Cashier/QueryTrade'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/QueryTrade.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 9 | 'hashIv' => 'EkRm7iFT261dpevs', 10 | ]); 11 | $postService = $factory->create('PostWithAesJsonResponseService'); 12 | 13 | $data = [ 14 | 'PlatformID' => '3002607', 15 | 'MerchantID' => '3002607', 16 | 'MerchantTradeNo' => '20180914001', 17 | ]; 18 | 19 | $input = [ 20 | 'MerchantID' => '3002607', 21 | 'RqHeader' => [ 22 | 'Timestamp' => time() 23 | ], 24 | 'Data' => $data 25 | ]; 26 | 27 | $url = 'https://ecpayment-stage.ecpay.com.tw/1.0.0/Cashier/QueryTrade'; 28 | 29 | $response = $postService->post($input, $url); 30 | var_dump($response); 31 | -------------------------------------------------------------------------------- /example/Payment/Ecpg/QueryTradeMedia.php: -------------------------------------------------------------------------------- 1 | 'pwFHCqoQZGmho4w6', 11 | 'hashIv' => 'EkRm7iFT261dpevs', 12 | ]); 13 | $AesService = $factory->create(AesService::class); 14 | $CurlService = $factory->create(CurlService::class); 15 | 16 | $data = [ 17 | 'MerchantID' => '3002607', 18 | 'DateType' => '2', 19 | 'BeginDate' => '2022-07-01', 20 | 'EndDate' => '2022-07-30', 21 | 'PaymentType' => '01' 22 | ]; 23 | $encryptData = $AesService->encrypt($data); 24 | 25 | $input = [ 26 | 'MerchantID' => '3002607', 27 | 'RqHeader' => [ 28 | 'Timestamp' => time() 29 | ], 30 | 'Data' => $encryptData 31 | ]; 32 | 33 | $url = 'https://ecpayment-stage.ecpay.com.tw/1.0.0/Cashier/QueryTradeMedia'; 34 | $filepath = '../../../QueryTradeMedia' . time() . '.csv'; 35 | 36 | $CurlService->setHeaders(array('Content-Type:application/json')); 37 | $result = $CurlService->run(json_encode($input), $url); 38 | 39 | file_put_contents($filepath, $result); 40 | echo($result); -------------------------------------------------------------------------------- /src/Abstracts/AbstractAesResponse.php: -------------------------------------------------------------------------------- 1 | aesService = $aesService; 22 | } 23 | 24 | /** 25 | * 取得 Response 26 | * 27 | * @param mixed $source 28 | * @return array 29 | * 30 | * @throws RtnException 31 | */ 32 | public function get($source) 33 | { 34 | $this->hasTransError($source); 35 | $parsed = $this->toArray($source); 36 | $sorted = ArrayService::naturalSort($parsed); 37 | 38 | return $sorted; 39 | } 40 | 41 | /** 42 | * Has transaction errors 43 | * 44 | * @param string $response 45 | * @return void 46 | * 47 | * @throws TransException 48 | */ 49 | protected function hasTransError($response) 50 | { 51 | $decoded = json_decode($response, true); 52 | if (isset($decoded['TransCode'])) { 53 | $code = intval($decoded['TransCode']); 54 | $message = $decoded['TransMsg']; 55 | if ($code !== 1) { 56 | throw new TransException($code, $message); 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Abstracts/AbstractDecryptedResponse.php: -------------------------------------------------------------------------------- 1 | aesService = $aesService; 28 | } 29 | 30 | /** 31 | * 取得 Response 32 | * 33 | * @param mixed $source 34 | * @return array 35 | * 36 | * @throws RtnException 37 | */ 38 | public function get($source) 39 | { 40 | $parsed = $this->toArray($source); 41 | $decrypted = $this->aesService->decryptData($parsed); 42 | return ArrayService::naturalSort($decrypted); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Abstracts/AbstractFactory.php: -------------------------------------------------------------------------------- 1 | isSubclassOf($target)) { 34 | $result = true; 35 | } 36 | } 37 | } 38 | 39 | return $result; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Abstracts/AbstractResponse.php: -------------------------------------------------------------------------------- 1 | toArray($source); 22 | $sorted = ArrayService::naturalSort($parsed); 23 | 24 | return $sorted; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Abstracts/AbstractVerifiedResponse.php: -------------------------------------------------------------------------------- 1 | checkMacValueService = $checkMacValueService; 27 | } 28 | 29 | /** 30 | * 取得 Response 31 | * 32 | * @param mixed $source 33 | * @return array 34 | * 35 | * @throws RtnException 36 | */ 37 | public function get($source) 38 | { 39 | $parsed = $this->toArray($source); 40 | if (!$this->verify($parsed)) { 41 | throw new RtnException(106); 42 | } 43 | $sorted = ArrayService::naturalSort($parsed); 44 | return $sorted; 45 | } 46 | 47 | /** 48 | * 驗證回應 49 | * 50 | * @param array $source 51 | * @return boolean 52 | */ 53 | public function verify($source) 54 | { 55 | return $this->checkMacValueService->verify($source); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/Config/RtnException.php: -------------------------------------------------------------------------------- 1 | 'Generate CheckMacValue failed', 5 | 103 => 'Response is not JSON format', 6 | 104 => 'Class with hash do not exist', 7 | 105 => 'Get response failed', 8 | 106 => 'CheckMacValue verify failed', 9 | 107 => 'cURL initialize failed', 10 | 108 => 'Perform cURL session failed', 11 | 109 => 'AES decrypt failed', 12 | 110 => 'AES encrypt failed', 13 | 111 => 'JSON decrypt failed', 14 | 15 | ]; 16 | -------------------------------------------------------------------------------- /src/Exceptions/RtnException.php: -------------------------------------------------------------------------------- 1 | toRtnMessage($code); 12 | parent::__construct($message, $code); 13 | } 14 | 15 | /** 16 | * 轉換為回應訊息 17 | * 18 | * @param int $code 19 | * @return string 20 | */ 21 | public function toRtnMessage($code) 22 | { 23 | $messageList = include __DIR__ . '/../Config/RtnException.php'; 24 | $message = 'Undefined error'; 25 | if (isset($messageList[$code])) { 26 | $message = $messageList[$code]; 27 | } 28 | 29 | return $message; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Exceptions/TransException.php: -------------------------------------------------------------------------------- 1 | '', 35 | 'hashIv' => '', 36 | 'hashMethod' => CheckMacValueService::METHOD_SHA256, 37 | ]; 38 | 39 | public function __construct(array $options = []) 40 | { 41 | $this->options = array_merge($this->options, $options); 42 | } 43 | 44 | /** 45 | * 類別工廠 46 | * 47 | * @param string $class 48 | * @return mixed 49 | * 50 | * @throws RtnException 51 | */ 52 | public function create($class) 53 | { 54 | $instance = null; 55 | switch (true) { 56 | case $this->isClassOrAlias($class, 'JsonCurlService'): 57 | $instance = $this->create(CurlService::class); 58 | $headers = [ 59 | 'Content-Type:application/json', 60 | ]; 61 | $instance->setHeaders($headers); 62 | break; 63 | case $this->isClassOrAlias($class, 'AutoSubmitFormService'): 64 | $request = $this->create(Request::class); 65 | $htmlService = $this->create(HtmlService::class); 66 | $instance = new AutoSubmitFormService($request, $htmlService); 67 | break; 68 | 69 | // CheckMacValue 應用 70 | case $this->isClassOrAlias($class, CheckMacValueService::class): 71 | $instance = new $class( 72 | $this->options['hashKey'], 73 | $this->options['hashIv'], 74 | $this->options['hashMethod'] 75 | ); 76 | break; 77 | case $this->isClassOrAlias($class, CheckMacValueRequest::class): 78 | case $this->isClassOrAlias($class, AbstractVerifiedResponse::class): 79 | $checkMacValueService = $this->create(CheckMacValueService::class); 80 | $instance = new $class($checkMacValueService); 81 | break; 82 | case $this->isClassOrAlias($class, 'PostWithCmvVerifiedEncodedStrResponseService'): 83 | $checkMacValueRequest = $this->create(CheckMacValueRequest::class); 84 | $curlService = $this->create(CurlService::class); 85 | $response = $this->create(VerifiedEncodedStrResponse::class); 86 | $instance = new PostService($checkMacValueRequest, $curlService, $response); 87 | break; 88 | case $this->isClassOrAlias($class, 'PostWithCmvEncodedStrResponseService'): 89 | $checkMacValueRequest = $this->create(CheckMacValueRequest::class); 90 | $curlService = $this->create(CurlService::class); 91 | $response = $this->create(EncodedStrResponse::class); 92 | $instance = new PostService($checkMacValueRequest, $curlService, $response); 93 | break; 94 | case $this->isClassOrAlias($class, 'PostWithCmvJsonResponseService'): 95 | $checkMacValueRequest = $this->create(CheckMacValueRequest::class); 96 | $curlService = $this->create(CurlService::class); 97 | $response = $this->create(JsonResponse::class); 98 | $instance = new PostService($checkMacValueRequest, $curlService, $response); 99 | break; 100 | case $this->isClassOrAlias($class, 'PostWithCmvStrResponseService'): 101 | $checkMacValueRequest = $this->create(CheckMacValueRequest::class); 102 | $curlService = $this->create(CurlService::class); 103 | $response = $this->create(StrResponse::class); 104 | $instance = new PostService($checkMacValueRequest, $curlService, $response); 105 | 106 | break; 107 | case $this->isClassOrAlias($class, 'AutoSubmitFormWithCmvService'): 108 | $checkMacValueRequest = $this->create(CheckMacValueRequest::class); 109 | $htmlService = $this->create(HtmlService::class); 110 | $instance = new AutoSubmitFormService($checkMacValueRequest, $htmlService); 111 | break; 112 | case $this->isClassOrAlias($class, 'FormWithCmvService'): 113 | $checkMacValueRequest = $this->create(CheckMacValueRequest::class); 114 | $htmlService = $this->create(HtmlService::class); 115 | $instance = new ManualFormService($checkMacValueRequest, $htmlService); 116 | break; 117 | 118 | // AES 應用 119 | case $this->isClassOrAlias($class, AesService::class): 120 | $instance = new $class($this->options['hashKey'], $this->options['hashIv']); 121 | break; 122 | case $this->isClassOrAlias($class, AesRequest::class): 123 | case $this->isClassOrAlias($class, AbstractAesResponse::class): 124 | $aesService = $this->create(AesService::class); 125 | $instance = new $class($aesService); 126 | break; 127 | case $this->isClassOrAlias($class, 'PostWithAesJsonResponseService'): 128 | $aesRequest = $this->create(AesRequest::class); 129 | $jsonCurlService = $this->create('JsonCurlService'); 130 | $response = $this->create(AesJsonResponse::class); 131 | $instance = new PostService($aesRequest, $jsonCurlService, $response); 132 | break; 133 | case $this->isClassOrAlias($class, 'PostWithAesStrResponseService'): 134 | $aesRequest = $this->create(AesRequest::class); 135 | $jsonCurlService = $this->create('JsonCurlService'); 136 | $response = $this->create(AesStrResponse::class); 137 | $instance = new PostService($aesRequest, $jsonCurlService, $response); 138 | break; 139 | 140 | default: 141 | $instance = new $class(); 142 | } 143 | 144 | return $instance; 145 | } 146 | 147 | /** 148 | * 含 Hash 資訊類別工廠 149 | * 150 | * @deprecated since version v1.0.2105270, 請改用 create 方法 151 | * @param string $class 152 | * @param string $key 153 | * @param string $iv 154 | * @return mixed 155 | * 156 | * @throws RtnException 157 | */ 158 | public function createWithHash($class, $key, $iv) 159 | { 160 | $this->options['hashKey'] = $key; 161 | $this->options['hashIv'] = $iv; 162 | 163 | return $this->create($class); 164 | } 165 | 166 | /** 167 | * 是否為某類別或別名 168 | * 169 | * @param string $class 170 | * @param string $target 171 | * @return boolean 172 | */ 173 | private function isClassOrAlias($class, $target) 174 | { 175 | $result = false; 176 | if ($class === $target) { 177 | $result = true; 178 | } else { 179 | if (class_exists($class) && class_exists($target)) { 180 | $reflection = new ReflectionClass($class); 181 | if ($reflection->isSubclassOf($target)) { 182 | $result = true; 183 | } 184 | } 185 | } 186 | 187 | return $result; 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/Interfaces/Request/RequestInterface.php: -------------------------------------------------------------------------------- 1 | aesService = $aesService; 20 | } 21 | 22 | /** 23 | * 取得 Request 24 | * 25 | * @param array $source 26 | * @return mixed 27 | * 28 | * @throws RtnException 29 | */ 30 | public function get($source) 31 | { 32 | $encrypted = $this->aesService->encryptData($source); 33 | $sorted = ArrayService::naturalSort($encrypted); 34 | $encoded = json_encode($sorted); 35 | return $encoded; 36 | } 37 | 38 | /** 39 | * 轉陣列 40 | * 41 | * @param mixed $source 42 | * @return array 43 | */ 44 | public function toArray($source) 45 | { 46 | $request = $this->get($source); 47 | $decoded = json_decode($request, true); 48 | return $decoded; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Request/CheckMacValueRequest.php: -------------------------------------------------------------------------------- 1 | checkMacValueService = $checkMacValueService; 20 | } 21 | 22 | /** 23 | * 取得 Request 24 | * 25 | * @param array $source 26 | * @return mixed 27 | * 28 | * @throws RtnException 29 | */ 30 | public function get($source) 31 | { 32 | $appened = $this->checkMacValueService->append($source); 33 | $sorted = ArrayService::naturalSort($appened); 34 | return $sorted; 35 | } 36 | 37 | /** 38 | * 轉陣列 39 | * 40 | * @param mixed $source 41 | * @return array 42 | */ 43 | public function toArray($source) 44 | { 45 | $request = $this->get($source); 46 | return $request; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/Request/Request.php: -------------------------------------------------------------------------------- 1 | get($source); 33 | return $request; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Response/AesJsonResponse.php: -------------------------------------------------------------------------------- 1 | aesService->decryptData($decode); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Response/AesStrResponse.php: -------------------------------------------------------------------------------- 1 | $response 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Response/ArrayResponse.php: -------------------------------------------------------------------------------- 1 | $response 19 | ]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Response/VerifiedArrayResponse.php: -------------------------------------------------------------------------------- 1 | setHashKey($key); 30 | $this->setHashIv($iv); 31 | } 32 | 33 | /** 34 | * AES 解密 35 | * 36 | * @param string $source 37 | * @return array 38 | * 39 | * @throws RtnException 40 | */ 41 | public function decrypt($source) 42 | { 43 | $jsonDecoded = []; 44 | $base64Decoded = base64_decode($source); 45 | $decrypted = openssl_decrypt( 46 | $base64Decoded, 47 | $this->method, 48 | $this->getHashKey(), 49 | $this->options, 50 | $this->getHashIv() 51 | ); 52 | if ($decrypted === false) { 53 | throw new RtnException(109); 54 | } 55 | 56 | $urlDecoded = urldecode($decrypted); 57 | $jsonDecoded = json_decode($urlDecoded, true); 58 | if (is_null($jsonDecoded)) { 59 | throw new RtnException(111); 60 | } 61 | 62 | return $jsonDecoded; 63 | } 64 | 65 | /** 66 | * 解密資料 67 | * 68 | * @param array $source 69 | * @return array 70 | * 71 | * @throws RtnException 72 | */ 73 | public function decryptData($source) 74 | { 75 | $field = $this->getFieldName(); 76 | if (isset($source[$field])) { 77 | $source[$field] = $this->decrypt($source[$field]); 78 | } 79 | 80 | return $source; 81 | } 82 | 83 | /** 84 | * AES 加密 85 | * 86 | * @param array $source 87 | * @return string 88 | * 89 | * @throws RtnException 90 | */ 91 | public function encrypt($source) 92 | { 93 | $dataBase64Encode = ''; 94 | try { 95 | $jsonEncoded = json_encode($source); 96 | $urlEncoded = urlencode($jsonEncoded); 97 | $encrypted = openssl_encrypt( 98 | $urlEncoded, 99 | $this->method, 100 | $this->getHashKey(), 101 | $this->options, 102 | $this->getHashIv() 103 | ); 104 | $dataBase64Encode = base64_encode($encrypted); 105 | } catch (Exception $e) { 106 | throw new RtnException(110); 107 | } 108 | 109 | return $dataBase64Encode; 110 | } 111 | 112 | /** 113 | * 加密資料 114 | * 115 | * @param array $source 116 | * @return array 117 | * 118 | * @throws RtnException 119 | */ 120 | public function encryptData($source) 121 | { 122 | $field = $this->getFieldName(); 123 | if (isset($source[$field])) { 124 | $source[$field] = $this->encrypt($source[$field]); 125 | } 126 | 127 | return $source; 128 | } 129 | 130 | /** 131 | * 取得加密欄位名稱 132 | * 133 | * @return string 134 | */ 135 | public function getFieldName() 136 | { 137 | return 'Data'; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/Services/ArrayService.php: -------------------------------------------------------------------------------- 1 | request = $request; 27 | $this->htmlService = $htmlService; 28 | } 29 | 30 | /** 31 | * 產生自動送出表單 JS 32 | * 33 | * @param string $formId 34 | * @return string 35 | */ 36 | public function autoSubmitJs($formId) 37 | { 38 | $js = ''; 41 | return $js; 42 | } 43 | 44 | /** 45 | * 產生自動送出表單 46 | * 47 | * @param array $input 48 | * @param string $action 49 | * @param string $id 50 | * @param string $target 51 | * @param string $submitText 52 | * @return string 53 | */ 54 | public function generate($input, $action, $target = '_self', $id = 'ecpay-form', $submitText = 'ecpay-button') 55 | { 56 | $request = $this->request->toArray($input); 57 | $html = $this->htmlService->header(); 58 | $html .= ''; 59 | $html .= $this->htmlService->form($request, $action, $target, $id, $submitText); 60 | $html .= $this->autoSubmitJs($id); 61 | $html .= ''; 62 | $html .= $this->htmlService->footer(); 63 | return $html; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Services/CheckMacValueService.php: -------------------------------------------------------------------------------- 1 | setHashKey($key); 32 | $this->setHashIv($iv); 33 | $this->setMethod($method); 34 | } 35 | 36 | /** 37 | * 附加檢查碼 38 | * 39 | * @param array $source 40 | * @param boolean $isSort 41 | * @return array 42 | */ 43 | public function append($source, $isSort = true) 44 | { 45 | $source[$this->getFieldName()] = $this->generate($source); 46 | if ($isSort) { 47 | $source = $this->sort($source); 48 | } 49 | 50 | return $source; 51 | } 52 | 53 | /** 54 | * 檢查碼參數過濾 55 | * 56 | * @param array $source 57 | * @return array 58 | */ 59 | public function filter($source) 60 | { 61 | if (isset($source[$this->getFieldName()])) { 62 | unset($source[$this->getFieldName()]); 63 | } 64 | 65 | return $source; 66 | } 67 | 68 | /** 69 | * 產生檢查碼 70 | * 71 | * @param array $source 72 | * @return string 73 | * 74 | * @throws RtnException 75 | */ 76 | public function generate($source) 77 | { 78 | try { 79 | $filtered = $this->filter($source); 80 | $sorted = $this->sort($filtered); 81 | $combined = $this->toEncodeSourceString($sorted); 82 | $encoded = UrlService::ecpayUrlEncode($combined); 83 | $hash = $this->generateHash($encoded); 84 | $checkMacValue = strtoupper($hash); 85 | } catch (Exception $e) { 86 | throw new RtnException(102); 87 | } 88 | 89 | return $checkMacValue; 90 | } 91 | 92 | /** 93 | * 產生雜湊值 94 | * 95 | * @param string $source 96 | * @return string 97 | */ 98 | public function generateHash($source) 99 | { 100 | $hash = ''; 101 | if ($this->method === self::METHOD_SHA256) { 102 | $hash = hash('sha256', $source); 103 | } else { 104 | $hash = md5($source); 105 | } 106 | return $hash; 107 | } 108 | 109 | /** 110 | * 取得壓碼欄位名稱 111 | * 112 | * @return string 113 | */ 114 | public function getFieldName() 115 | { 116 | return 'CheckMacValue'; 117 | } 118 | 119 | /** 120 | * 設定雜湊方式 121 | * 122 | * @param string $method 123 | * @return void 124 | */ 125 | public function setMethod($method) 126 | { 127 | $this->method = $method; 128 | } 129 | 130 | /** 131 | * 排序 132 | * 133 | * @param array $source 134 | * @return array 135 | */ 136 | public function sort($source) 137 | { 138 | return ArrayService::naturalSort($source); 139 | } 140 | 141 | /** 142 | * 轉換為編碼來源字串 143 | * 144 | * @param array $source 145 | * @return string 146 | */ 147 | public function toEncodeSourceString($source) 148 | { 149 | $combined = 'HashKey=' . $this->getHashKey(); 150 | foreach ($source as $name => $value) { 151 | $combined .= '&' . $name . '=' . $value; 152 | } 153 | $combined .= '&HashIV=' . $this->getHashIv(); 154 | return $combined; 155 | } 156 | 157 | /** 158 | * 檢核檢查碼 159 | * 160 | * @param array $source 161 | * @return boolean 162 | */ 163 | public function verify($source) 164 | { 165 | $checkMacValue = $this->generate($source); 166 | return ($checkMacValue === $source[$this->getFieldName()]); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/Services/CurlService.php: -------------------------------------------------------------------------------- 1 | headers = $headers; 26 | } 27 | 28 | /** 29 | * 執行 30 | * 31 | * @param mixed $request 32 | * @param string $url 33 | * @return mixed 34 | * 35 | * @throws RtnException 36 | */ 37 | public function run($request, $url) 38 | { 39 | if (($ch = curl_init()) === false) { 40 | throw new RtnException(107); 41 | } 42 | curl_setopt($ch, CURLOPT_URL, $url); 43 | curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); 44 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 45 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 46 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 47 | curl_setopt($ch, CURLOPT_POST, true); 48 | curl_setopt($ch, CURLOPT_POSTFIELDS, $request); 49 | if (($rs = curl_exec($ch)) === false) { 50 | throw new RtnException(108); 51 | } 52 | curl_close($ch); 53 | return $rs; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/Services/Helper.php: -------------------------------------------------------------------------------- 1 | ' . PHP_EOL; 61 | } 62 | 63 | echo '
' . print_r($content, true) . '

' . PHP_EOL; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Services/HtmlService.php: -------------------------------------------------------------------------------- 1 | '; 34 | } 35 | 36 | /** 37 | * 產生表單 38 | * 39 | * @param array $input 40 | * @param string $action 41 | * @param string $target 42 | * @param string $id 43 | * @param string $submitText 44 | * @return string 45 | */ 46 | public function form($input, $action, $target, $id, $submitText) 47 | { 48 | $formTarget = $this->escapeHtml($target); 49 | $formAction = $this->escapeHtml($action); 50 | $form = '
'; 51 | foreach ($input as $name => $value) { 52 | $inputName = $this->escapeHtml($name); 53 | $inputValue = $this->escapeHtml($value); 54 | $form .= ''; 55 | } 56 | $form .= '
'; 57 | return $form; 58 | } 59 | 60 | /** 61 | * 產生 Header 62 | * 63 | * @return string 64 | */ 65 | public function header() 66 | { 67 | $header = ''; 68 | $header .= ''; 69 | $header .= ''; 70 | $header .= ''; 71 | $header .= ''; 72 | return $header; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Services/ManualFormService.php: -------------------------------------------------------------------------------- 1 | request = $request; 27 | $this->htmlService = $htmlService; 28 | } 29 | 30 | /** 31 | * 產生表單 32 | * 33 | * @param array $input 34 | * @param string $action 35 | * @param string $id 36 | * @param string $target 37 | * @param string $submitText 38 | * @return string 39 | */ 40 | public function generate($input, $action, $target = '_self', $id = 'ecpay-form', $submitText = 'ecpay-button') 41 | { 42 | $request = $this->request->toArray($input); 43 | $html = $this->htmlService->header(); 44 | $html .= ''; 45 | $html .= $this->htmlService->form($request, $action, $target, $id, $submitText); 46 | $html .= ''; 47 | $html .= $this->htmlService->footer(); 48 | return $html; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Services/PostService.php: -------------------------------------------------------------------------------- 1 | request = $request; 39 | $this->serverPostService = $httpClientService; 40 | $this->response = $response; 41 | } 42 | 43 | /** 44 | * Server Post 45 | * 46 | * @param array $request 47 | * @param string $url 48 | * @return array 49 | * 50 | * @throws RtnException 51 | */ 52 | public function post($request, $url) 53 | { 54 | $reqeust = $this->request->get($request); 55 | $source = $this->serverPostService->run($reqeust, $url); 56 | return $this->response->get($source); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Services/UrlService.php: -------------------------------------------------------------------------------- 1 | setFactory($this->getSha256CmvFactory()); 38 | $this->faker = FakerFactory::create(); 39 | } 40 | 41 | /** 42 | * 建立類別 43 | * 44 | * @param string $class 45 | * @return mixed 46 | */ 47 | protected function create($class) 48 | { 49 | return $this->factory->create($class); 50 | } 51 | 52 | /** 53 | * 取得 MD5 壓碼工廠 54 | * 55 | * @return Factory 56 | */ 57 | protected function getMd5CmvFactory() 58 | { 59 | return new Factory([ 60 | 'hashIv' => $this->stageOtpHashIv, 61 | 'hashKey' => $this->stageOtpHashKey, 62 | 'hashMethod' => CheckMacValueService::METHOD_MD5, 63 | ]); 64 | } 65 | 66 | /** 67 | * 取得 SHA256 壓碼工廠 68 | * 69 | * @return Factory 70 | */ 71 | protected function getSha256CmvFactory() 72 | { 73 | return new Factory([ 74 | 'hashIv' => $this->stageOtpHashIv, 75 | 'hashKey' => $this->stageOtpHashKey, 76 | 'hashMethod' => CheckMacValueService::METHOD_SHA256, 77 | ]); 78 | } 79 | 80 | /** 81 | * 設定工廠 82 | * 83 | * @param Factory $factory 84 | * @return void 85 | */ 86 | protected function setFactory(Factory $factory) 87 | { 88 | $this->factory = $factory; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/TestCase/SingleServiceTestCase.php: -------------------------------------------------------------------------------- 1 | $this->stageOtpHashIv, 45 | 'hashKey' => $this->stageOtpHashKey, 46 | 'hashMethod' => '', 47 | ]; 48 | } 49 | 50 | /** 51 | * 取得測試 Service 52 | * 53 | * @return mixed 54 | */ 55 | protected function getService() 56 | { 57 | return null; 58 | } 59 | 60 | /** 61 | * Sets up the fixture, for example, open a network connection. 62 | * This method is called before a test is executed. 63 | */ 64 | protected function setUp() 65 | { 66 | parent::setUp(); 67 | $this->factory = new Factory($this->getFactoryOptions()); 68 | $this->service = $this->getService(); 69 | $this->faker = FakerFactory::create(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Traits/HashInfo.php: -------------------------------------------------------------------------------- 1 | hashIv; 29 | } 30 | 31 | /** 32 | * 取得 Hash Key 33 | * 34 | * @return string 35 | */ 36 | public function getHashKey() 37 | { 38 | return $this->hashKey; 39 | } 40 | 41 | /** 42 | * 設定 Hash IV 43 | * 44 | * @param string $iv 45 | * @return void 46 | */ 47 | public function setHashIv($iv) 48 | { 49 | $this->hashIv = $iv; 50 | } 51 | 52 | /** 53 | * 設定 Hash Key 54 | * 55 | * @param string $key 56 | * @return void 57 | */ 58 | public function setHashKey($key) 59 | { 60 | $this->hashKey = $key; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Traits/StageInfo.php: -------------------------------------------------------------------------------- 1 |