Getting started with API playground!

歡迎來到開發者平台

多種 API 滿足夥伴業務需求,
沙盒測試環境供夥伴盡情發揮

四個步驟 API 串接輕鬆上手

註冊登入

註冊、登入我們的開發環境,展開您的沙盒測試。

選擇 API

選擇您想串接的 API 項目。

沙盒測試

在測試環境中進行 API 串接測試。

服務上線

測試完成後,將 API 嵌入您的服務介面即可上線。

Sandbox 沙盒測試

讓我們試試看!
選擇下方 API,立即體驗模擬沙盒測試環境。

{
    "appRepBody": {
        "exchangeRates": [
            {
                "updateTime": "20200923095508",
                "currency": "USD",
                "currencyName": "美元",
                "cashExchangeRate": {
                    "sale": "30.06500",
                    "buy": "29.58200",
                    "fee": "N/A"
                },
                "spotExchangeRate": {
                    "sale": "29.86500",
                    "buy": "29.78200",
                    "fee": "N/A"
                }
            },
            {
                "updateTime": "20200923095508",
                "currency": "JPY",
                "currencyName": "日圓",
                "cashExchangeRate": {
                    "sale": "0.28170",
                    "buy": "0.27340",
                    "fee": "N/A"
                },
                "spotExchangeRate": {
                    "sale": "0.28020",
                    "buy": "0.27640",
                    "fee": "N/A"
                }
            }
        ]
    },
    "appRepExtension": {}
}
{
    "appRepBody": {
        "updateTime": "20200923095509",
        "currencyList": {
            "美元": "USD",
            "日圓": "JPY",
            "港幣": "HKD",
            "歐元": "EUR",
            "英鎊": "GBP",
            "瑞士法郎": "CHF",
            "澳幣": "AUD",
            "新加坡幣": "SGD",
            "瑞典幣": "SEK",
            "加拿大幣": "CAD",
            "泰銖": "THB",
            "南非幣": "ZAR",
            "紐西蘭幣": "NZD",
            "澳門幣": "MOP",
            "人民幣": "CNY",
            "黃金公克": "XAT",
            "離岸人民幣": "CNH"
        }
    },
    "appRepExtension": {}
}
{
    "appRepBody": {
        "countryCode": "TW",
        "branches": [
            {
                "updateTime": "N/A",
                "branchName": {
                    "branchName": "中科分行",
                    "branchCode": "BR0041"
                },
                "location": {
                    "zipCode": "40764",
                    "coordinate": {
                        "longitude": "120.6122868",
                        "latitude": "24.1847469"
                    },
                    "address": {
                        "chinese": "臺灣大道4段1182號",
                        "english": "No.1182, Sec. 4, Taichungkang Rd., Hsitun District, Taichung City 407, Taiwan (R.O.C.)"
                    }
                },
                "branchService": [
                    "可預約取號",
                    "有外幣業務",
                    "有黃金業務",
                    "無保管箱",
                    "無人民幣ATM"
                ],
                "accessibility": [],
                "branchBasicInfo": {
                    "openingTimes": [
                        {
                            "openingDay": "一",
                            "openingTime": "9:00",
                            "closingTime": "15:30"
                        },
                        {
                            "openingDay": "二",
                            "openingTime": "9:00",
                            "closingTime": "15:30"
                        },
                        {
                            "openingDay": "三",
                            "openingTime": "9:00",
                            "closingTime": "15:30"
                        },
                        {
                            "openingDay": "四",
                            "openingTime": "9:00",
                            "closingTime": "15:30"
                        },
                        {
                            "openingDay": "五",
                            "openingTime": "9:00",
                            "closingTime": "15:30"
                        }
                    ],
                    "serviceNumber": "(04)2465-3008",
                    "faxNumber": "(04)2465-0055",
                    "swiftCode": ""
                }
            }
        ]
    },
    "appRepExtension": {}
}
{
    "appRepBody": {
        "atms": [
            {
                "updateTime": "20200923051502",
                "atmName": {
                    "atmName": "台北市",
                    "atmCode": "00124"
                },
                "location": {
                    "zipCode": "N/A",
                    "coordinate": {
                        "longitude": "121.545138",
                        "latitude": "25.033194"
                    },
                    "address": {
                        "chinese": "台北市大安區信義路四段46號",
                        "english": "N/A"
                    }
                },
                "atmServices": [
                    "有臺幣百元鈔",
                    "有臺幣千元鈔",
                    "有人民幣現鈔",
                    "無美元現鈔",
                    "有日圓現鈔",
                    "無港幣現鈔"
                ],
                "accessibility": [],
                "currency": [
                    "TWD"
                ],
                "supprotedLanguages": [
                    "中文",
                    "英文"
                ],
                "atmBasicInfo": {
                    "openingTimes": [
                        {
                            "openingDay": "一",
                            "openingTime": "00:00",
                            "closingTime": "24:00"
                        },
                        {
                            "openingDay": "二",
                            "openingTime": "00:00",
                            "closingTime": "24:00"
                        },
                        {
                            "openingDay": "三",
                            "openingTime": "00:00",
                            "closingTime": "24:00"
                        },
                        {
                            "openingDay": "四",
                            "openingTime": "00:00",
                            "closingTime": "24:00"
                        },
                        {
                            "openingDay": "五",
                            "openingTime": "00:00",
                            "closingTime": "24:00"
                        },
                        {
                            "openingDay": "六",
                            "openingTime": "00:00",
                            "closingTime": "24:00"
                        },
                        {
                            "openingDay": "日",
                            "openingTime": "00:00",
                            "closingTime": "24:00"
                        }
                    ],
                    "serviceNumber": ""
                }
            }
        ]
    },
    "appRepExtension": {}
}
PHP SampleCode 使用方法:

1.請開啟 QPayToolkit.php 調整參數
	(1) $targetUrl(行數 2)
		主要測試環境使用, 請改成 ==> https://apisbx.sinopac.com/funBIZ/QPay.WebAPI/api/
		備援測試環境使用, 請改成 ==> https://sandbox.sinopac.com/QPay.WebAPI/api/
		
	(2) $ShopNo (行數 5)
		請依信件內提供商店編號更改
	
	(3) $Hash (行數 7)
		請依信件內提供雜湊值, 更改陣列內 A1、A2、B1、B2 參數
		
2.完成參數調整後, 請將要使 API 服務 include QPayToolkit.php 進去, 呼叫方法請參考 SampleCode.php、SamplePrint.php、BackendURL.php, 相關 Sample 如下
	(01) 建立信用卡訂單  ==>  OrderCreate4Card()
	(02) 建立虛擬帳號訂單  ==>  OrderCreate4ATM()
	(03) 信用卡 - 待請款訂單查詢  ==>  OrderUnCapturedQuery()
	(04) 信用卡 – 訂單維護服務  ==>  OrderMaintain()
	(05) 訂單交易查詢  ==>  OrderQuery()
	(06) 訊息查詢服務  ==>  OrderPayQuery()
	(07) 交易對帳檔查詢服務  ==>  BillQuery()
	(08) 撥款檔查詢服務  ==>  AllotQuery()
	(09) 信用卡-定期定額查詢服務  ==>  RegularQuery()
	(10) 即時訊息通知  ==>  BackendURL.php

	PS.$Service 各欄位填寫限制請以API串接手冊為主


---------------------------------------------------------------------------------------------------------
QPayToolkit.php
	//API 位置
	$targetUrl = "https://apisbx.sinopac.com/funBIZ/QPay.WebAPI/api/";
	//商店代號
	$ShopNo = "NA0001_001";
	//雜湊值
	$Hash = Array(	
					"A1" => "65960834240E44B7",
					"A2" => "2831076A098E49E7",
					"B1" => "CB1AFFBF915A492B",
					"B2" => "7F242C0AA612454F"
				);

	//執行 API 服務方法
	function APIService($service, $objService){
		global $ShopNo, $Hash, $targetUrl;
		
		$url = $targetUrl . "/Order";
		
		//取得 Nonce 值
		$Nonce = getNonce($ShopNo, $targetUrl);
		//取得 HashID
		$HashID = getHashID($Hash);
		//取得 IV
		$IV = getIV($Nonce);
		//取得 Sign
		$Sign = getSign($objService, $Nonce, $HashID);
		//訊息內文 E2E 加密(先將變數為 null 移除)
		if ($service == "OrderCreate"){
			$objService->ATMParam = array_filter((array) ($objService->ATMParam));
			$objService->CardParam = array_filter((array) ($objService->CardParam));
			$objService->ConvStoreParam = array_filter((array) ($objService->ConvStoreParam));		
		}

		$objService = array_filter((array) ($objService));		
		
		echo json_encode($objService)."
".$HashID."
".$IV."
"; $Message = EncryptAesCBC(json_encode($objService), $HashID, $IV); //建立 Request Class $Request = new API; $Request->ShopNo = $ShopNo; $Request->APIService = $service; $Request->Sign = $Sign; $Request->Nonce = $Nonce; $Request->Message = $Message; //建立 Response Class $Response = new API; //取得永豐銀行回覆訊息 $Response = json_decode(WebAPI($url, json_encode($Request))); echo json_encode($Response); //取得 Response Nonce $ResNonce = $Response->Nonce; //取得 Response IV $ResIV = getIV($ResNonce); //取得永豐銀行訊息內文 $result = DecryptAesCBC($Response->Message, $HashID, $ResIV); return $result; } //取得 Nonce 方法 function getNonce($shopno, $targeturl){ $url = $targeturl . "/Nonce"; $post_data = json_encode(array('ShopNo' => $shopno)); $result = WebAPI($url, $post_data); $result = json_decode($result); return $result->Nonce; } //取得 Hash ID 計算方法 function getHashID($hash){ //var_dump($hash); $Byte_A1 = strToHexBytes($hash["A1"]); $Byte_A2 = strToHexBytes($hash["A2"]); $Byte_B1 = strToHexBytes($hash["B1"]); $Byte_B2 = strToHexBytes($hash["B2"]); $XOR1 = setXOR($Byte_A1, $Byte_A2); $XOR2 = setXOR($Byte_B1, $Byte_B2); $result = hexBytesToString($XOR1).hexBytesToString($XOR2); return $result; } //取得 IV 計算方法 function getIV($nonce){ $data = SHA256($nonce); return substr($data, strlen($data) - 16, 16); } //取得 Sign 計算方法 function getSign($data, $nonce, $hashid){ $result = ''; $content = ''; //移除 null $data = array_filter((array) ($data)); //對欄位升序排序 ksort($data); //訊息排序組合 while ($fruit_name = current($data)) { //僅抓取第一層變數作組合 if (is_array($data[key($data)]) == false){ $content .= key($data) . '=' . $data[key($data)] . '&'; } next($data); } $content = substr($content , 0, strlen($content) -1); //字串雜湊 $content .= $nonce . $hashid; //SHA256 $result = SHA256($content); return $result; } //字串轉 Hex 方法 function strToHexBytes($string){ $hex = array(); $j = 0; for ($i=0; $i 0, CURLOPT_NOBODY => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_HTTPHEADER => array("Content-type: application/json; charset=utf-8"), CURLOPT_POST=> 1, CURLOPT_POSTFIELDS=> $post_data , CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_SSL_VERIFYHOST => 0, CURLOPT_SSLVERSION => 6 //(1:TLSv1 / 6:TLSv1_2) 使用 TLS 1.2 Protocol ); curl_setopt_array($ch, $options); $result=curl_exec($ch); curl_close($ch); return $result; } //Request、Response 呼叫用 class API { //API 版本 public $Version = '1.0.0'; //商店代號 public $ShopNo; //API服務 public $APIService; //安全簽章 public $Sign; //時間戳記 public $Nonce; //交易訊息內文 public $Message; } //建立訂單交易(OrderCreate) class OrderCreate { //商店代號 public $ShopNo; //訂單編號 public $OrderNo; //訂單總金額 public $Amount; //幣別 public $CurrencyID = 'TWD'; //收款名稱 public $PrdtName; //備註 public $Memo; //自訂參數一 public $Param1; //自訂參數二 public $Param2; //自訂參數三 public $Param3; //導回頁面 public $ReturnURL; //背端通知 public $BackendURL; //收款方式 public $PayType; //寄件者暱稱 public $Sender; //寄件者行動電話 public $SenderMobile; //收件者暱稱 public $Receiver; //收件者行動電話 public $ReceiverMobile; //虛擬帳號用 Param public $ATMParam = array( //付款截止日期 'ExpireDate'=> null ); //信用卡用 Param public $CardParam = array( //自動請款 'AutoBilling'=> null, //預計自動請款天數 'ExpBillingDays'=> null, //信用卡付款連結有效時間(預設為10分鐘) 'ExpMinutes'=> null, //信用卡付款子項目(預設值為一次付清) 'PayTypeSub'=> null, //分期期數 'Staging'=> null, //快速付款 Token 'CCToken'=> null, //扣款總期數 'DeductTotalNum'=> null, //扣款週期 'PeriodType'=> null, //扣款頻率 'DeductFreq'=> null ); } //信用卡 - 待請款訂單查詢(OrderUnCapturedQuery) class OrderUnCapturedQuery { //商店代號 public $ShopNo; //訂單編號 public $OrderNo; } //信用卡 – 訂單維護服務(OrderMaintain) class OrderMaintain { //商店代號 public $ShopNo; //訂單編號 public $OrderNo; //發送要求 public $Command; //申請退款金額 public $Amount; //退款原因 public $Remark; } //訂單交易查詢(OrderQuery) class OrderQuery { //商店代號 public $ShopNo; //訂單編號 public $OrderNo; //收款方式 public $PayType; //交易日期(起) public $OrderDateTimeS; //交易日期(迄) public $OrderDateTimeE; //付款日期(起) public $PayDateTimeS; //付款日期(迄) public $PayDateTimeE; //付款狀態為條件查詢 public $PayFlag; } //訊息查詢服務(OrderPayQuery) class OrderPayQuery { //商店代號 public $ShopNo; //Token 值 public $PayToken; } //交易對帳檔查詢服務(BillQuery) class BillQuery { //商店代號 public $ShopNo; //交易對帳日期 public $BillDate; } //撥款檔查詢服務(AllotQuery) class AllotQuery { //商店代號 public $ShopNo; //撥款日期(起) public $AllotDateS; //撥款日期(迄) public $AllotDateE; //收款方式 public $PayType; } //信用卡-定期定額查詢服務 class RegularQuery { //商店代號 public $ShopNo; //定期定額主單編號 public $MasterOrderNo; } --------------------------------------------------------------------------------------------------------- SampleCode.php include "QPayToolkit.php"; OrderCreate4Card(); //建立信用卡訂單 function OrderCreate4Card() { global $ShopNo; $Service = new OrderCreate; $Service->ShopNo = $ShopNo; $Service->Amount = '50000'; $Service->OrderNo = 'C' . date("YmdHis"); $Service->PayType = 'C'; $Service->PrdtName = '信用卡訂單'; $Service->ReturnURL = 'http://10.11.22.113:8803/QPay.ApiClient-Sandbox/Store/Return'; $Service->BackendURL = 'https://sandbox.sinopac.com/funBIZ.ApiClient/AutoPush/PushSuccess'; $Service->CardParam['AutoBilling'] = 'Y'; //$Service->CardParam['CCToken'] = '0C6C6684-4597-412B-BD4C-E731DCEFE2FB'; --快速付款 /*--------------------定期定額--------------------*/ //$Service->CardParam['PayTypeSub'] = 'REGULAR'; //$Service->CardParam['DeductTotalNum'] = '12'; //$Service->CardParam['PeriodType'] = 'D'; //$Service->CardParam['DeductFreq'] = '2'; /*------------------------------------------------*/ echo APIService("OrderCreate", $Service); } //建立虛擬帳號訂單 function OrderCreate4ATM() { global $ShopNo; $date = new DateTime(date('Y-m-d')); $date->add(new DateInterval('P10D')); $ExpireDate = $date->format('Ymd'); $Service = new OrderCreate; $Service->ShopNo = $ShopNo; $Service->Amount = '50000'; $Service->OrderNo = 'A' . date("YmdHis"); $Service->PayType = 'A'; $Service->PrdtName = '虛擬帳號訂單'; $Service->ReturnURL = 'http://10.11.22.113:8803/QPay.ApiClient-Sandbox/Store/Return'; $Service->BackendURL = 'https://sandbox.sinopac.com/funBIZ.ApiClient/AutoPush/PushSuccess'; $Service->ATMParam['ExpireDate'] = $ExpireDate; echo APIService("OrderCreate", $Service); } //信用卡 - 待請款訂單查詢 function OrderUnCapturedQuery() { global $ShopNo; $Service = new OrderUnCapturedQuery; $Service->ShopNo = $ShopNo; echo APIService("OrderUnCapturedQuery", $Service); } //信用卡 – 訂單維護服務 function OrderMaintain() { global $ShopNo; $Service = new OrderMaintain; $Service->ShopNo = $ShopNo; $Service->OrderNo = 'C201805250005'; $Service->Command = 'R'; echo APIService("OrderMaintain", $Service); } //訂單交易查詢 function OrderQuery() { global $ShopNo; $Service = new OrderQuery; $Service->ShopNo = $ShopNo; $Service->OrderNo = 'A20180706100451'; echo APIService("OrderQuery", $Service); } //訊息查詢服務 function OrderPayQuery() { global $ShopNo; $Service = new OrderPayQuery; $Service->ShopNo = $ShopNo; $Service->PayToken = 'c7b0d2b994251d730f4a2feb24e584c509264e92829c9194d1952da08898e44f'; echo APIService("OrderPayQuery", $Service); } //交易對帳檔查詢服務 function BillQuery() { global $ShopNo; $Service = new BillQuery; $Service->ShopNo = $ShopNo; $Service->BillDate = '20180525'; echo APIService("BillQuery", $Service); } //撥款檔查詢服務 function AllotQuery() { global $ShopNo; $Service = new AllotQuery; $Service->ShopNo = $ShopNo; $Service->AllotDateS = '20180625'; $Service->AllotDateE = '20180625'; $Service->PayType = 'A'; echo APIService("AllotQuery", $Service); } //信用卡-定期定額查詢服務 function RegularQuery() { global $ShopNo; $Service = new RegularQuery; $Service->ShopNo = $ShopNo; $Service->MasterOrderNo = 'CR202005211405'; echo APIService("RegularQuery", $Service); } --------------------------------------------------------------------------------------------------------- BackendURL.php include "QPayToolkit.php"; //取得豐收款 POST 內容 $data = file_get_contents('php://input'); //Log $file = fopen("AutoPush.txt","a+"); //開啟檔案 fwrite($file,$str); fclose($file); //將取得 Json 轉換為物件使用 $Request = new OrderPayQuery; $Request = json_decode($data ); //使用訊息查詢服務確認訂單結果 $Service = new OrderPayQuery; $Service->ShopNo = $Request->ShopNo; $Service->PayToken = $Request->PayToken; //$Response 內有訂單資訊 $Response = APIService("OrderPayQuery", $Service); //確認訂單資訊正確回覆接收成功訊息 echo '{"Status":"S"}'; ---------------------------------------------------------------------------------------------------------

想了解更多?

如果您需要更多協助,歡迎聯絡我們!