MYPAY LINK PayPage多訂單交易
修改歷程
| 版本 | 異動日期 | 修訂內容 | 位置 | 
|---|---|---|---|
| 1.0 | 2024.09.13 | 新版文件 | |
| 1.1 | 2025.04.08 | 商品增加供應商與成本 | 
開發前請先閱讀
金鑰的注意事項
Q:金鑰的有效期限
A:MyPay的金鑰有效期限只有一年,如果要延長,請自行至金鑰管理系統延長
Q:金鑰可以在什麼時候延長
A:到期日7天前,都可以延長(不包含第7天),一但超過,系統自動產生新金鑰後,即不可再延長
Q:金鑰即將到期前7天時,系統新發的金鑰是否會於信件中夾帶
A:會
Q:金鑰在到期前何時會發信通知
A:定期發送金鑰到期通知的頻率為:60天/30天/20天,若 貴司皆無動作,則系統會於到期前七天產製新金鑰並發送email到 貴司技術窗口信箱,此時舊的金鑰,因還未過期還可以使用,一旦過期,貴司仍使用舊金鑰則會無法交易
交易結果的告知
Q:交易完成的導頁會有交易結果的參數嗎
A:不論是參數中的success_returl 或 failure_returl或是後臺設定的交易成功、失敗導頁網址,均不會給予交易結果參數
Q:何時會給予交易結果
A:MyPay將在接收上游結果後,會由附錄三這邊的設定,背景主動發動通知商家
Q:當我接到MyPay通知時該做什麼
A:請直接回應8888,如沒有回應,MyPay會通知5次,若5次內均得不到8888,系統會寄發信件給予商家的技術人員以及附錄三而外設定的人員
PayPage交易設計概要
安全性設計
所有的付費要求發動都僅能從特約商店的網頁伺服器發出請求,將傳輸的資料以AES加密,再透過HTTPS加密傳輸。交易資料不由消費者端送出,可確保資料不被消費者竄改。所有付費資訊經過MYPAY Link匝道進行轉送處理,特約商店不需要處理消費者的付費流程以及安全控管。
資料驗證
交易參數中有一組由雜湊函式運算出的驗証碼,作為資料驗証用,以確保資料正確性。 大部分交易模式,特約商店以導頁的方式處理付費流程,特約商店只需確保與MYPAY LINK連線正常,即可確保交易安全以及確保資料安全。
系統架構
所有請求與查詢只能透過伺服器發動,由特約商店的網頁伺服器利用伺服端服務程式發動交易,以避免交易資料被消費者竄改或攔截。為確保交易安全,MYPAY Link僅能接受 https connection,注意僅接受TLS1.2以上協定。

MYPAY LINK 目前提供之服務與格式
MYPAY LINK 提供多種交易與應用方式,應用情境如下:
(1)PayPage金流多訂單交易請求:透過MYPAY交易頁面作付款動作
(2)groupId交易查詢:查詢金流交易資訊
我們提供介接方式是透過https連線,只接受POST方式傳送交易資料。
介接網址
特約商店模式
| 位置 | API介接網址 | 
|---|---|
| 測試區 | https://ka.usecase.cc/api/init | 
| 正式區 | https://ka.mypay.tw/api/init | 
Client模式(限定功能)
| 位置 | API介接網址 | 
|---|---|
| 測試區 | https://ka.usecase.cc/api/open | 
| 正式區 | https://ka.mypay.tw/api/open | 
資料加密方式
AES 256編碼 + base64編碼(附錄四資料加密方式)
加密金鑰
金鑰會透過mail發送,也可從管理後台取得
文字編碼
一律使用UTF-8相容編碼
PayPage金流交易
<?php
/**
 * 特約商店串接-PayPage金流交易
 */
final class StoreOrder
{
    /**
     * 特約商店商務代號
     * @var string
     */
    public $storeUid = "289151880002";
    /**
     * 特約商店金鑰或認證碼
     * @var string
     */
    public $storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
    /**
     * 串接交易位置
     * @var string
     */
    public $url = "https://ka.usecase.cc/api/init";
    /**
     * 取得串接欄位資料
     * @return array
     */
    public function getRawData()
    {
        $rawData = array();
        $rawData['store_uid'] = $this->storeUid;
        $rawData['items'] = [['id' => '1',
            'name' => '商品名稱',
            'cost' => '10',
            'amount' => '1',
            'total' => '10']];
        $rawData['cost'] = 10;
        $rawData['user_id'] = "phper";
        $rawData['order_id'] = "1234567890";
        $rawData['ip'] = "192.168.0.1"; // 此為消費者IP,會做為驗證用
        $rawData['pfn'] = "0";
        return $rawData;
    }
    /**
     * 取得服務位置
     * @return array
     */
    public function getService()
    {
        return array(
            'service_name' => 'agent',
            'cmd' => 'api/orders'
        );
    }
    /**
     * AES 256 加密
     * @param array $fields
     * @param string $key
     * @return string
     */
    public function encrypt($fields, $key)
    {
        $data = json_encode($fields);
        $size = openssl_cipher_iv_length('AES-256-CBC');
        $iv   = openssl_random_pseudo_bytes($size);
        $data = openssl_encrypt($data, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
        $data = base64_encode($iv . $data);
        return $data;
    }
    /**
     * 資料 POST 到主機
     * @param array $postData
     * @return mixed
     */
    public function post($postData = [])
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL, $this->url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    /**
     * 取得送出欄位資料
     * @return array
     */
    public function getPostData ()
    {
        $postData = array();
        $postData['store_uid'] = $this->storeUid;
        $postData['service'] = $this->encrypt($this->getService(), $this->storeKey);
        $postData['encry_data'] = $this->encrypt($this->getRawData(), $this->storeKey);
        return $postData;
    }
    /**
     * 執行
     */
    public function run()
    {
        $json = $this->post($this->getPostData());
        echo $json;
    }
}
$StoreOrder = new StoreOrder();
$StoreOrder->run();
?>
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Collections;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Dynamic;
/// <summary>
/// 建議使用.net framework4.5以上版本
/// 1.請透過NuGet安裝Newtonsoft.Json,若.net framework小於4.5請安裝Newtonsoft.Json 7.0以下版本
/// 2.若貴司.net framework小於4 可能無法使用dynamic,若是自行組陣列
/// 3.若貴司.net framework小於3.5 可能無法使用AES類別,若是參閱微軟網站使用較舊方式進行加密
/// 4.若貴司.net framework小於3.5 可能沒有Linq可使用,故data只能組字串,Newtonsoft.Json也可能無法使用
/// </summary>
namespace MyPay {
    /// <summary>
    /// 特約商店串接-PayPage金流交易
    /// </summary>
    public class StoreOrder {
        /// <summary>
        /// 特約商店商務代號
        /// </summary>
        public string storeUid = "289151880002";
        /// <summary>
        /// 特約商店金鑰或認證碼
        /// </summary>
        public string storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
        /// <summary>
        /// 串接交易位置
        /// </summary>
        public string url = "https://ka.usecase.cc/api/init";
        /// <summary>
        /// 執行
        /// </summary>
        static void Main() {
            StoreOrder simulator = new StoreOrder();
            //僅限走https的Tls 1.2以上版本
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            //發送至遠端
            var result = simulator.Post(simulator.GetPostData());
            System.Console.WriteLine(result);
        }
        /// <summary>
        /// 取得串接欄位資料
        /// </summary>
        private dynamic GetRawData() {
            ArrayList items = new ArrayList();
            dynamic item = new ExpandoObject();
            item.id = "1";
            item.name = "商品名稱";
            item.cost = "10";
            item.amount = "1";
            item.total = "10";
            items.Add(item);
            dynamic rawData = new ExpandoObject();
            rawData.store_uid = this.storeUid;
            rawData.items = items;
            rawData.cost = "10";
            rawData.user_id = "phper";
            rawData.order_id = "1234567890";
            rawData.ip = "127.0.0.1"; // 此為消費者IP,會做為驗證用
            rawData.pfn = "0";
            return rawData;
        }
        /// <summary>
        /// 取得服務位置
        /// </summary>
        private ServiceRequest GetService() {
            ServiceRequest rawData = new ServiceRequest();
            rawData.service_name = "agent";
            rawData.cmd = "api/orders";
            return rawData;
        }
        /// <summary>
        /// 取得送出欄位資料
        /// </summary>
        private NameValueCollection GetPostData() {
            string data_json = JsonConvert.SerializeObject(GetRawData(), Formatting.None);
            string svr_json = JsonConvert.SerializeObject(GetService(), Formatting.None);; //依API種類調整
            //產生AES向量
            var IV = GetBytesIV();
            //進行加密
            var data_encode = Encrypt(data_json, this.storeKey, IV);
            var svr_encode = Encrypt(svr_json, this.storeKey, IV);
            //請注意使用的 Http Post 套件是否會自動加上UrlEncode,本Post範例為原始方式,故須加上UrlEncode
            //若自行使用的套件會自動補上UrlEncode,則請忽略下面的UrlEncode,避免做了兩次UrlEncode
            string data_toUrlEncode = HttpUtility.UrlEncode(data_encode);
            string svr_toUrlEncode = HttpUtility.UrlEncode(svr_encode);
            NameValueCollection postData = new NameValueCollection();
            postData["store_uid"] = this.storeUid;
            postData["service"] = svr_toUrlEncode;
            postData["encry_data"] = data_toUrlEncode;
            return postData;
        }
        /// <summary>
        /// AES 256 加密
        /// </summary>
        /// <param name="data"></param>
        /// <param name="key"></param>
        /// <param name="byteIV"></param>
        /// <returns></returns>
        private string Encrypt(string data, string key, byte[] byteIV) {
            var byteKey = System.Text.Encoding.UTF8.GetBytes(key);
            var enBytes = AES_Encrypt(data, byteKey, byteIV);
            return Convert.ToBase64String(BytesAdd(byteIV, enBytes));
        }
        /// <summary>
        /// AES 256 加密處理
        /// </summary>
        /// <param name="original"></param>
        /// <param name="key"></param>
        /// <param name="iv"></param>
        /// <returns></returns>
        private byte[] AES_Encrypt(string original, byte[] key, byte[] iv) {
            try {
                var data = Encoding.UTF8.GetBytes(original);
                var cipher = Aes.Create().CreateEncryptor(key, iv);
                var de = cipher.TransformFinalBlock(data, 0, data.Length);
                return de;
            } catch {
                return null;
            }
        }
        /// <summary>
        /// 轉換Bytes
        /// </summary>
        /// <param name="a"></param>
        /// <param name="arryB"></param>
        /// <returns></returns>
        private byte[] BytesAdd(byte[] a, params byte[][] arryB) {
            List < byte > c = new List < byte > ();
            c.AddRange(a);
            arryB.ToList().ForEach(b => {
                c.AddRange(b);
            });
            return c.ToArray();
        }
        /// <summary>
        /// 產生AES的IV
        /// </summary>
        /// <returns></returns>
        private static byte[] GetBytesIV() {
            var aes = System.Security.Cryptography.AesCryptoServiceProvider.Create();
            aes.KeySize = 256;
            aes.GenerateIV();
            return aes.IV;
        }
        /// <summary>
        /// 資料 POST 到主機
        /// </summary>
        /// <param name="pars"></param>
        /// <returns></returns>
        private string Post(NameValueCollection pars) {
            string result = string.Empty;
            string param = string.Empty;
            if (pars.Count > 0) {
                pars.AllKeys.ToList().ForEach(key => {
                    param += key + "=" + pars[key] + "&";
                });
                if (param[param.Length - 1] == '&') {
                    param = param.Remove(param.Length - 1);
                }
            }
            byte[] bs = Encoding.UTF8.GetBytes(param);
            try {
                HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create(this.url);
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = bs.Length;
                using(Stream reqStream = req.GetRequestStream()) {
                    reqStream.Write(bs, 0, bs.Length);
                }
                using(WebResponse wr = req.GetResponse()) {
                    Encoding myEncoding = Encoding.GetEncoding("UTF-8");
                    using(StreamReader myStreamReader = new StreamReader(wr.GetResponseStream(), myEncoding)) {
                        result = myStreamReader.ReadToEnd();
                    }
                }
                req = null;
            } catch (WebException ex) {
                throw new WebException(ex.Message + "params : " + param, ex, ex.Status, ex.Response);
            }
            return result;
        }
    }
    /// <summary>
    /// 串接服務請求欄位
    /// </summary>
    public class ServiceRequest {
        public string service_name { get; set; }
        public string cmd { get; set; }
    }
}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URLEncoder;
import java.util.*;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import static java.nio.charset.StandardCharsets.UTF_8;
import org.spongycastle.crypto.engines.AESEngine;
import org.spongycastle.crypto.modes.CBCBlockCipher;
import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.crypto.params.ParametersWithIV;
import java.security.SecureRandom;
/**
 * 特約商店串接-PayPage金流交易
 * 1. jackson-core 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
 * 2. jackson-databind 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
 * 3. jackson-annotations 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
 * 4. Spongy Castle 下載 https://mvnrepository.com/artifact/com.madgag.spongycastle/core
 */
public class StoreOrder {
    /**
     * 特約商店商務代號
     */
    String storeUid = "289151880002";
    /**
     * 特約商店金鑰或認證碼
     */
    String storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
    /**
     * 串接交易位置
     */
    String url = "https://ka.usecase.cc/api/init";
    /**
     * 執行
     * @param  args
     */
    public static void main(String[] args) {
        StoreOrder simulator = new StoreOrder();
        String json = simulator.post(simulator.getPostData());
        System.out.print(json);
    }
    @SuppressWarnings(value = { "unchecked", "deprecation" })
    /**
     * 取得串接欄位資料
     * @return 串接原始資料
     */
    public Map getRawData() {
        ArrayList items = new ArrayList();
        Map<Object, Object> item = new HashMap<Object, Object>();
        item.put("id", "1");
        item.put("name", "商品名稱");
        item.put("cost", "10");
        item.put("amount", "1");
        item.put("total", "10");
        items.add(item);
        Map<Object, Object> rawData = new HashMap<Object, Object>();
        rawData.put("store_uid", this.storeUid);
        rawData.put("items", items);
        rawData.put("cost", "10");
        rawData.put("user_id", "phper");
        rawData.put("order_id", "1234567890");
        rawData.put("ip", "127.0.0.1"); // 此為消費者IP,會做為驗證用
        rawData.put("pfn", "0");
        return rawData;
    }
    /**
     * 取得服務位置
     * @return 串接服務資料
     */
    public Map getService() {
        Map<Object, Object> rawData = new HashMap<Object, Object>();
        rawData.put("service_name", "agent");
        rawData.put("cmd", "api/orders");
        return rawData;
    }
    /**
     * AES 256 加密
     * @param rawData 原始資料
     * @param AesKey AES256金鑰字串
     * @return 轉換成Base64資料
     */
    public String encrypt(Map rawData, String AesKey) {
        try {
            ObjectMapper objMapper = new ObjectMapper();
            byte[] data = objMapper.writeValueAsString(rawData).getBytes(UTF_8);
            byte[] key = AesKey.getBytes(UTF_8);
            // 16 bytes is the IV size for AES256
            PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(
                    new CBCBlockCipher(new AESEngine()));
            // Random iv
            SecureRandom rng = new SecureRandom();
            byte[] ivBytes = new byte[16];
            rng.nextBytes(ivBytes);
            cipher.init(true, new ParametersWithIV(new KeyParameter(key),
                    ivBytes));
            byte[] outBuf = new byte[cipher.getOutputSize(data.length)];
            int processed = cipher
                    .processBytes(data, 0, data.length, outBuf, 0);
            processed += cipher.doFinal(outBuf, processed);
            byte[] outBuf2 = new byte[processed + 16]; // Make room for iv
            System.arraycopy(ivBytes, 0, outBuf2, 0, 16); // Add iv
            System.arraycopy(outBuf, 0, outBuf2, 16, processed);
            Base64.Encoder encoder = Base64.getEncoder();
            String base64 = encoder.encodeToString(outBuf2);
            return base64;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 資料 POST 到主機
     * @param qstr 串接資料
     * @return 服務回傳JSON資訊
     */
    public String post(String qstr) {
        String result = "";
        try {
            // 資料
            byte[] qstr_bytes = qstr.getBytes(StandardCharsets.UTF_8);
            URL iurl = new URL(this.url);
            SSLContext sc = SSLContext.getInstance("TLSv1.2"); // $NON-NLS-1$
            sc.init(null, null, new java.security.SecureRandom());
            HttpsURLConnection con = (HttpsURLConnection) iurl.openConnection();
            con.setSSLSocketFactory(sc.getSocketFactory());
            con.setRequestMethod("POST");
            con.setRequestProperty("Content-Type",
                    "application/x-www-form-urlencoded");
            con.setRequestProperty("Content-Length",
                    String.valueOf(qstr_bytes.length));
            con.setRequestProperty("Accept-Charset", "UTF-8");
            con.setDoOutput(true);
            con.setDoInput(true);
            con.getOutputStream()
                    .write(qstr.getBytes(Charset.forName("UTF-8")));
            con.getOutputStream().flush();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    con.getInputStream(), "UTF-8"));
            String inputLine;
            StringBuffer response = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine + "\r\n");
            }
            try {
                result = response.toString();
            } finally {
                in.close();
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return result;
    }
    /**
     * 取得送出欄位資料
     * @return POST完整資料
     */
    public String getPostData() {
        String postData = "";
        try {
            // Base64需要使用UrlEncode做傳輸
            String data_toUrlEncode = URLEncoder.encode(
                    this.encrypt(this.getRawData(), this.storeKey), "UTF-8");
            String svr_toUrlEncode = URLEncoder.encode(
                    this.encrypt(this.getService(), this.storeKey), "UTF-8");
            postData = "store_uid=" + this.storeUid + "&service="
                    + svr_toUrlEncode + "&encry_data=" + data_toUrlEncode;
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return postData;
    }
}
const crypto = require('crypto');
const httpRequest = require('https');
/**
 * 特約商店串接-PayPage金流交易
 */
function StoreOrder() {
    // 特約商店商務代號
    this.storeUid = "289151880002";
    // 特約商店金鑰或認證碼
    this.storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
    // 串接交易位置
    this.url = "https://ka.usecase.cc/api/init";
};
/**
 * 取得串接欄位資料
 */
StoreOrder.prototype.getRawData = function () {
    return {
        store_uid: this.storeUid,
        items: [{
            'id': "1",
            'name': "商品名稱",
            'cost': "10",
            'amount': "1",
            'total': "10"
        }],
        cost: "10",
        user_id: "phper",
        order_id: "1234567890",
        ip: "127.0.0.1",
        pfn: "0"
    };
};
/**
 * 取得服務位置
 */
StoreOrder.prototype.getService = function () {
    return {
        service_name: "agent",
        cmd: "api/orders"
    };
};
/**
 * AES 256 加密
 */
StoreOrder.prototype.encrypt = function (fields, key) {
    let eData = JSON.stringify(fields);
    const blockSize = 16;
    const iv = crypto.randomBytes(blockSize);
    const encryptor = crypto.createCipheriv('aes-256-cbc', key, iv);
    let tmpCipher = encryptor.update(Buffer.from(eData));
    let finalCipher = encryptor.final();
    const tempData = Buffer.concat([tmpCipher, finalCipher], tmpCipher.length + finalCipher.length);
    let data = Buffer.concat([iv, tempData], iv.length + tempData.length).toString('base64');
    return data;
};
/**
 * 資料 POST 到主機
 */
StoreOrder.prototype.post = function (postData) {
    return new Promise((res, rej) => {
        let options = {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            rejectUnauthorized: false
        };
        let send_process = httpRequest.request(this.url, options, (api_res) => {
            let res_data = "";
            api_res.on('data', (tmp_data) => {
                res_data += tmp_data;
            });
            api_res.on('end', () => {
                res(res_data);
            });
        });
        send_process.write(JSON.stringify(postData));
        send_process.end();
    });
};
/**
 * 取得送出欄位資料
 */
StoreOrder.prototype.getPostData = function () {
    return {
        "store_uid": this.storeUid,
        "service": this.encrypt(this.getService(), this.storeKey),
        "encry_data": this.encrypt(this.getRawData(), this.storeKey)
    };
};
/**
 * 執行
 */
StoreOrder.prototype.run = async function () {
    json = await this.post(this.getPostData())
    console.log(json);
};
StoreOrder = new StoreOrder();
StoreOrder.run();
import json
import base64
import requests
from Crypto.Cipher import AES
from Crypto.Util import Padding
from Crypto.Random import get_random_bytes
"""特約商店串接-PayPage金流交易
"""
class StoreOrder:
    # 特約商店商務代號
    storeUid = "289151880002"
    # 特約商店金鑰或認證碼
    storeKey = b"KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx"
    # 串接交易位置
    url = "https://ka.usecase.cc/api/init"
    def getRawData(self):
        """取得串接欄位資料
        Returns:
            {dict}: 欄位資料
        """
        rawData = {
            'store_uid': self.storeUid,
            'items': [{
                    'id': "1",
                    'name': "商品名稱",
                    'cost': "10",
                    'amount': "1",
                    'total': "10"
                }],
            'cost': "10",
            'user_id': "phper",
            'order_id': "1234567890",
            'ip': "127.0.0.1",
            'pfn': "0"
        }
        return rawData
    def getService(self):
        """取得服務位置
        Returns:
            {dict}: 服務位置資料
        """
        return {
            'service_name': 'agent',
            'cmd': 'api/orders'
        }
    def encrypt(self, fields, key):
        """AES 256 加密
        Args:
            fields {dict}: 欄位資料
            key {bytes}: AES金鑰
        Returns:
            {string}: 加密資料
        """
        data = json.dumps(fields, separators=(',', ':'))
        data = Padding.pad(data.encode('utf-8'), AES.block_size)
        iv = get_random_bytes(AES.block_size)
        cipher = AES.new(key, AES.MODE_CBC, iv)
        data = cipher.encrypt(data)
        data = base64.b64encode(iv + data)
        return data
    def post(self, postData):
        """資料 POST 到主機
        Args:
            postData {dict}: 欄位資料
        Returns:
            {string}: JSON資料
        """
        result = requests.post(self.url, postData)
        return result.text
    def getPostData(self):
        """取得送出欄位資料
        Returns:
            {dict}: 欄位資料
        """
        postData = {
            'store_uid': self.storeUid,
            'service': self.encrypt(self.getService(), self.storeKey),
            'encry_data': self.encrypt(self.getRawData(), self.storeKey)
        }
        return postData
    def run(self):
        """執行
        """
        json = self.post(self.getPostData())
        print(json)
StoreOrder = StoreOrder()
StoreOrder.run()
回傳 JSON 結構如下:
{
    "code": "200",
    "msg": "資料正確",
    "url": "http:\/\/pay.k20-mypay.tw\/payment\/81127.html",
    "uid": 81127,
    "key": "af4e678325dd49f8036949c38ab04105"
}
此交易請求參數內含交易訂單編號,與查詢用之金鑰,以及付費網址。貴司也可將此交易訂單編號綁定貴司的消費者訂單,我們會透過主動回報機制,以POST方式回報交易即時資訊,回報網址可以在管理系統中設定,啟動服務後,系統就會主動回傳訂單狀態。
特約商店『PayPage金流交易』參數說明
| 欄位 | 型態 | 說明 | 
|---|---|---|
| store_uid | string(16) | 特約商店商務代號 | 
| service | text | {"service_name": "agent", "cmd": "api\/orders"}JSON格式,AES256加密資料  | 
| encry_data | text | 『PayPage金流交易』欄位參考 JSON格式,AES256加密資料  | 
『PayPage金流交易』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| store_uid | string | 特約商店代碼 | 必填 | 
| user_id | string | 消費者帳號 請注意,記憶卡號跟記憶發票都是依此欄位為基準,如果不同的user來買,請記得切換,否則會出現同一筆資料  | 
必填 | 
| user_name | string | 消費者姓名,電子錢包交易必要欄位 | |
| user_real_name | string | 消費者真實姓名,電子錢包交易必要欄位 | |
| user_zipcode | string | 消費者郵遞區號 | |
| user_address | string | 消費者帳單地址 | |
| user_sn_type | string | 證號類型 | 『證號類型』值參考 | 
| user_sn | string | 付款人身分證/統一證號/護照號碼 | |
| user_phone | string | 消費者家用電話 | |
| user_cellphone_code | string | 消費者行動電話國碼,電子錢包交易必要欄位 | |
| user_cellphone | string | 消費者行動電話,電子錢包交易必要欄位 | |
| user_email | string | 消費者 E-Mail,電子錢包交易必要欄位 | |
| user_birthday | string | 消費者生日 | |
| cost | string | 訂單總金額 = 物品之總價加總 + 折價 + 運費(如為定期定額交易,此為每一期的應扣金額)  | 
必填 | 
| currency | string | 預設交易幣別(預設為TWD新台幣) | 『幣別類型』值參考 | 
| enable_dcc | integer | 啟用dcc(自動換匯) | 『自動換匯』值參考 | 
| order_id | string | 訂單編號(訂單編號最長為50bytes) | 必填 | 
| ip | string | 消費者來源 IP(格式務必正確,部分金流服務商後續處理會驗證) | 必填 | 
| item | string | 訂單內物品數 | |
| items | array | 訂單物品項目 | 必填 每筆『商品項目』欄位參考  | 
| regular | string | 定期定額付費,期數單位 | 『分期類型定義』值參考 | 
| regular_total | string | 總期數(如為 12 期即代入 12,如果不設定終止期,請代入 0) | |
| regular_first_charge_date | string | 定期扣款起扣日 不得小於當日,若未指定日期,將判定為當日扣款 格式為 YYYYMMDD,如 20090916  | 
|
| group_id | string | 定期定額式扣款編號 | |
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | |
| pfn | string | 預選付費方法 | 『付款方式』值參考 | 
| interface | string | 消費者操作介面類型 pc/app | |
| discount | string | 折價金額 (預設0),如果有使用發票功能,建議將折扣資訊放入item。 | |
| success_returl | string | 交易成功導頁網址 | |
| failure_returl | string | 交易失敗導頁網址 | |
| limit_pay_days | integer | 虛擬帳號與超商代碼使用之有效天數 | |
| shipping_fee | string | 運費 | |
| enable_quickpay | integer | 啟用快速結帳 | 『啟用快速結帳』值參考 | 
| enable_ewallet | integer | 啟用電子錢包 | 『啟用電子錢包』值參考 | 
| virtual_pan | string | 電子錢包虛擬卡號 | |
| ewallet_type | integer | 電子錢包執行類型 | 『電子錢包執行類型』值參考 | 
| transaction_type | integer | 交易類型 | 『交易類型』值參考 | 
| creditcard_installment | string | 國內信用卡分期顯示限定 JSON 格式如下 { "3": ["013", "822", "808"], "6": ["822", "812"] }  | 
|
| each_code | string | eACH交易代碼(如果使用eACH必須指定交易代碼) | |
| issue_invoice_state | integer | 開立發票 | 『電子發票是否開立狀態』值參考 | 
| invoice_ratetype | integer | 電子發票稅率別 | 『電子發票稅率別』值參考 | 
| invoice_input_type | integer | 電子發票開立類型 | 『電子發票開立類型』值參考 | 
| invoice_cloud_type | string | 「雲端發票」類型 | 當invoice_input_type為1,此狀態才有效 『雲端發票類型』值參考  | 
| invoice_tax_id | string | 統一編號 | 當invoice_input_type為1,此欄位才有效,非必要 | 
| invoice_mobile_code | string | 手機條碼 | 當invoice_cloud_type為2,此欄位才有效 | 
| invoice_natural_person | string | 自然人憑證條碼 | 當invoice_cloud_type為3,此欄位才有效 | 
| invoice_love_code | string | 愛心碼 | 當invoice_input_type為2,此欄位才有效 | 
| invoice_b2b_title | string | 發票抬頭 | 當invoice_input_type為3時,此欄位才有效 | 
| invoice_b2b_id | string | 統一編號 | 當invoice_input_type為3時,此欄位才有效 | 
| invoice_b2b_address | string | 發票地址 | 當invoice_input_type為3時,此欄位才有效 | 
| invoice_b2b_title_force | string | 若選擇實體發票時,發票抬頭無法異動。 | 『電子發票欄位異動』值參考 | 
| invoice_b2b_id_force | string | 若選擇實體發票時,統一編號無法異動。 | 『電子發票欄位異動』值參考 | 
| invoice_b2b_address_force | integer | 若選擇實體發票時,預設地址無法異動。 | 『電子發票欄位異動』值參考 | 
| user_data | object | 無卡分期消費者資訊 | 『無卡分期消費者資訊』欄位參考 | 
| files_path | string | 無卡分期上傳檔案路徑 (JSON多筆格式) | 『無卡分期檔案』值參考 | 
| price | string | 儲值交易之交易金額/點數 (儲值交易以此欄位辨識交易金額/點數) | |
| recharge_code | string | 儲值交易時,使用當時儲值之儲值產品代碼 | |
| recharge_items | array | 儲值交易用物品資訊 | 每筆『儲值交易項目』欄位參考 | 
| agent_sms_fee_type | integer | 經銷商代收費是否含簡訊費 | 『含不含簡訊費』值參考 | 
| agent_charge_fee_type | integer | 經銷商代收費是否含手續費 | 『含不含手續費類型』值參考 | 
| agent_charge_fee | integer | 經銷商代收費 | |
| is_agent_charge | integer | 是否為經銷商代收費模式 若 is_agent_charge 有指定,以指定優先 若欄位agent_charge_fee有費用,或經銷商代收費是含簡訊費、或經銷商代收費含手續費,則預設為1 若欄位agent_charge_fee無費用,且經銷商代收費不含簡訊費、或經銷商代收費不含手續費或參欄位都未使用則預設為0  | 
『是否為經銷商代收費模式』值參考 | 
| creditcard_is_automatic_payment | string | 信用卡類交易時,是否使用授權請款模式(預設自動請款) | 『信用卡授權請款模式類型』值參考 | 
『PayPage金流交易』回傳欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| code | string | 交易回傳碼 | |
| msg | string | 回傳訊息 | |
| uid | string | 訂單之交易流水號(交易訂單/票券服務訂單/儲值訂單) | |
| key | string | 交易驗証碼 | |
| url | string | 交易網址 | 
| 支援語系名稱 | 語系編碼 | 
|---|---|
| 繁體中文版 | zh-TW(預設) | 
| 簡體中文版 | zh-CN | 
| 英文版 | en | 
| 印尼語 | id | 
『交易完成回傳資訊』回報欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| card_type | string | 信用卡卡別 | 『信用卡別類型』值參考 | 
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| is_agent_charge | int | 是否為經銷商代收費模式 | 『是否為經銷商代收費模式』值參考 | 
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | integer | 交易類型 | 『交易類型定義』值參考 | 
| redeem | string | 紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 銀行代碼 虛擬帳號資訊  | 
|
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考 『超商條碼繳費』值參考  | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
『非即時交易回傳資訊』回報欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| card_type | string | 信用卡卡別 | 『信用卡別類型』值參考 | 
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| is_agent_charge | int | 是否為經銷商代收費模式 | 『是否為經銷商代收費模式』值參考 | 
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | integer | 交易類型 | 『交易類型定義』值參考 | 
| redeem | string | 紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 銀行代碼 虛擬帳號資訊  | 
|
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考  | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
『訂單確認回傳資訊』回報欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| card_type | string | 信用卡卡別 | 『信用卡別類型』值參考 | 
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| is_agent_charge | int | 是否為經銷商代收費模式 | 『是否為經銷商代收費模式』值參考 | 
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | integer | 交易類型 | 『交易類型定義』值參考 | 
| redeem | string | 紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 銀行代碼 虛擬帳號資訊  | 
|
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考  | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
PayPage多訂單金流交易
<?php
/**
 * 特約商店串接-nodejs PayPage多訂單金流交易
 */
final class StoreOrder
{
    /**
     * 特約商店商務代號
     * @var string
     */
    public $storeUid = "289151880011";
    /**
     * 特約商店金鑰或認證碼
     * @var string
     */
    public $storeKey = "25HwOoT9E3ahsGEwVcJDq3CEmLxTIEYn";
    /**
     * 串接交易位置
     * @var string
     */
    public $url = "https://ka.usecase.cc/api/init";
    /**
     * 取得串接欄位資料
     * @return array
     */
    public function getRawData()
    {
        $rawData = array();
        $rawData['orders'] = [
                                 [
                                  'store_uid' => '289151880011',
                                     [
                                         [
                                          'id' => '1',
                                          'name' => '商品名稱',
                                          'cost' => '50',
                                          'amount' => '1',
                                          'total' => '50'
                                         ]
                                     ],
                                  'cost' => 50,
                                  'user_id' => 'userid',
                                  'order_id' => 'O20240912160034',
                                  'ip' => '192.168.0.1',
                                  'pfn' => '0'
                                 ]
                             ];
        return $rawData;
    }
    /**
     * 取得服務位置
     * @return array
     */
    public function getService()
    {
        return array(
            'service_name' => 'agent',
            'cmd' => 'api/groupcreator'
        );
    }
    /**
     * AES 256 加密
     * @param array $fields
     * @param string $key
     * @return string
     */
    public function encrypt($fields, $key)
    {
        $data = json_encode($fields);
        $size = openssl_cipher_iv_length('AES-256-CBC');
        $iv   = openssl_random_pseudo_bytes($size);
        $data = openssl_encrypt($data, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
        $data = base64_encode($iv . $data);
        return $data;
    }
    /**
     * 資料 POST 到主機
     * @param array $postData
     * @return mixed
     */
    public function post($postData = [])
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL, $this->url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    /**
     * 取得送出欄位資料
     * @return array
     */
    public function getPostData ()
    {
        $postData = array();
        $postData['store_uid'] = $this->storeUid;
        $postData['service'] = $this->encrypt($this->getService(), $this->storeKey);
        $postData['encry_data'] = $this->encrypt($this->getRawData(), $this->storeKey);
        return $postData;
    }
    /**
     * 執行
     */
    public function run()
    {
        $json = $this->post($this->getPostData());
        echo $json;
    }
}
$StoreOrder = new StoreOrder();
$StoreOrder->run();
?>
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Collections;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Dynamic;
/// <summary>
/// 建議使用.net framework4.5以上版本
/// 1.請透過NuGet安裝Newtonsoft.Json,若.net framework小於4.5請安裝Newtonsoft.Json 7.0以下版本
/// 2.若貴司.net framework小於4 可能無法使用dynamic,若是自行組陣列
/// 3.若貴司.net framework小於3.5 可能無法使用AES類別,若是參閱微軟網站使用較舊方式進行加密
/// 4.若貴司.net framework小於3.5 可能沒有Linq可使用,故data只能組字串,Newtonsoft.Json也可能無法使用
/// </summary>
namespace MyPay {
    /// <summary>
    /// 特約商店串接-nodejs PayPage多訂單金流交易
    /// </summary>
    public class StoreOrder {
        /// <summary>
        /// 特約商店商務代號
        /// </summary>
        public string storeUid = "289151880011";
        /// <summary>
        /// 特約商店金鑰或認證碼
        /// </summary>
        public string storeKey = "25HwOoT9E3ahsGEwVcJDq3CEmLxTIEYn";
        /// <summary>
        /// 串接交易位置
        /// </summary>
        public string url = "https://ka.usecase.cc/api/init";
        /// <summary>
        /// 執行
        /// </summary>
        static void Main() {
            StoreOrder simulator = new StoreOrder();
            //僅限走https的Tls 1.2以上版本
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            //發送至遠端
            var result = simulator.Post(simulator.GetPostData());
            System.Console.WriteLine(result);
        }
        /// <summary>
        /// 取得串接欄位資料
        /// </summary>
        private dynamic GetRawData() {
            ArrayList orders = new ArrayList();
            dynamic order1 = new ExpandoObject();
            order1.store_uid = "289151880011";
            ArrayList items1 = new ArrayList();
            dynamic items11 = new ExpandoObject();
            items11.id = "1";
            items11.name = "商品名稱";
            items11.cost = "50";
            items11.amount = "1";
            items11.total = "50";
            items1.Add(items11);
            order1.items = items1;
            order1.cost = 50;
            order1.user_id = "userid";
            order1.order_id = "O20240912160034";
            order1.ip = "192.168.0.1";
            order1.pfn = "0";
            orders.Add(order1);
            dynamic rawData = new ExpandoObject();
            rawData.orders = orders;
            return rawData;
        }
        /// <summary>
        /// 取得服務位置
        /// </summary>
        private ServiceRequest GetService() {
            ServiceRequest rawData = new ServiceRequest();
            rawData.service_name = "agent";
            rawData.cmd = "api/groupcreator";
            return rawData;
        }
        /// <summary>
        /// 取得送出欄位資料
        /// </summary>
        private NameValueCollection GetPostData() {
            string data_json = JsonConvert.SerializeObject(GetRawData(), Formatting.None);
            string svr_json = JsonConvert.SerializeObject(GetService(), Formatting.None);; //依API種類調整
            //產生AES向量
            var IV = GetBytesIV();
            //進行加密
            var data_encode = Encrypt(data_json, this.storeKey, IV);
            var svr_encode = Encrypt(svr_json, this.storeKey, IV);
            //請注意使用的 Http Post 套件是否會自動加上UrlEncode,本Post範例為原始方式,故須加上UrlEncode
            //若自行使用的套件會自動補上UrlEncode,則請忽略下面的UrlEncode,避免做了兩次UrlEncode
            string data_toUrlEncode = HttpUtility.UrlEncode(data_encode);
            string svr_toUrlEncode = HttpUtility.UrlEncode(svr_encode);
            NameValueCollection postData = new NameValueCollection();
            postData["store_uid"] = this.storeUid;
            postData["service"] = svr_toUrlEncode;
            postData["encry_data"] = data_toUrlEncode;
            return postData;
        }
        /// <summary>
        /// AES 256 加密
        /// </summary>
        /// <param name="data"></param>
        /// <param name="key"></param>
        /// <param name="byteIV"></param>
        /// <returns></returns>
        private string Encrypt(string data, string key, byte[] byteIV) {
            var byteKey = System.Text.Encoding.UTF8.GetBytes(key);
            var enBytes = AES_Encrypt(data, byteKey, byteIV);
            return Convert.ToBase64String(BytesAdd(byteIV, enBytes));
        }
        /// <summary>
        /// AES 256 加密處理
        /// </summary>
        /// <param name="original"></param>
        /// <param name="key"></param>
        /// <param name="iv"></param>
        /// <returns></returns>
        private byte[] AES_Encrypt(string original, byte[] key, byte[] iv) {
            try {
                var data = Encoding.UTF8.GetBytes(original);
                var cipher = Aes.Create().CreateEncryptor(key, iv);
                var de = cipher.TransformFinalBlock(data, 0, data.Length);
                return de;
            } catch {
                return null;
            }
        }
        /// <summary>
        /// 轉換Bytes
        /// </summary>
        /// <param name="a"></param>
        /// <param name="arryB"></param>
        /// <returns></returns>
        private byte[] BytesAdd(byte[] a, params byte[][] arryB) {
            List < byte > c = new List < byte > ();
            c.AddRange(a);
            arryB.ToList().ForEach(b => {
                c.AddRange(b);
            });
            return c.ToArray();
        }
        /// <summary>
        /// 產生AES的IV
        /// </summary>
        /// <returns></returns>
        private static byte[] GetBytesIV() {
            var aes = System.Security.Cryptography.AesCryptoServiceProvider.Create();
            aes.KeySize = 256;
            aes.GenerateIV();
            return aes.IV;
        }
        /// <summary>
        /// 資料 POST 到主機
        /// </summary>
        /// <param name="pars"></param>
        /// <returns></returns>
        private string Post(NameValueCollection pars) {
            string result = string.Empty;
            string param = string.Empty;
            if (pars.Count > 0) {
                pars.AllKeys.ToList().ForEach(key => {
                    param += key + "=" + pars[key] + "&";
                });
                if (param[param.Length - 1] == '&') {
                    param = param.Remove(param.Length - 1);
                }
            }
            byte[] bs = Encoding.UTF8.GetBytes(param);
            try {
                HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create(this.url);
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = bs.Length;
                using(Stream reqStream = req.GetRequestStream()) {
                    reqStream.Write(bs, 0, bs.Length);
                }
                using(WebResponse wr = req.GetResponse()) {
                    Encoding myEncoding = Encoding.GetEncoding("UTF-8");
                    using(StreamReader myStreamReader = new StreamReader(wr.GetResponseStream(), myEncoding)) {
                        result = myStreamReader.ReadToEnd();
                    }
                }
                req = null;
            } catch (WebException ex) {
                throw new WebException(ex.Message + "params : " + param, ex, ex.Status, ex.Response);
            }
            return result;
        }
    }
    /// <summary>
    /// 串接服務請求欄位
    /// </summary>
    public class ServiceRequest {
        public string service_name { get; set; }
        public string cmd { get; set; }
    }
}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URLEncoder;
import java.util.*;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import static java.nio.charset.StandardCharsets.UTF_8;
import org.spongycastle.crypto.engines.AESEngine;
import org.spongycastle.crypto.modes.CBCBlockCipher;
import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.crypto.params.ParametersWithIV;
import java.security.SecureRandom;
/**
 * 特約商店串接-nodejs PayPage多訂單金流交易
 * 1. jackson-core 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
 * 2. jackson-databind 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
 * 3. jackson-annotations 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
 * 4. Spongy Castle 下載 https://mvnrepository.com/artifact/com.madgag.spongycastle/core
 */
public class StoreOrder {
    /**
     * 特約商店商務代號
     */
    String storeUid = "289151880011";
    /**
     * 特約商店金鑰或認證碼
     */
    String storeKey = "25HwOoT9E3ahsGEwVcJDq3CEmLxTIEYn";
    /**
     * 串接交易位置
     */
    String url = "https://ka.usecase.cc/api/init";
    /**
     * 執行
     * @param  args
     */
    public static void main(String[] args) {
        StoreOrder simulator = new StoreOrder();
        String json = simulator.post(simulator.getPostData());
        System.out.print(json);
    }
    @SuppressWarnings(value = { "unchecked", "deprecation" })
    /**
     * 取得串接欄位資料
     * @return 串接原始資料
     */
    public Map getRawData() {
        ArrayList orders = new ArrayList();
        Map<Object, Object> order1 = new HashMap<Object, Object>();
        order1.put("store_uid", "289151880011");
        ArrayList items1 = new ArrayList();
        Map<Object, Object> items11 = new HashMap<Object, Object>();
        items11.put("id", "1");
        items11.put("name", "商品名稱");
        items11.put("cost", "50");
        items11.put("amount", "1");
        items11.put("total", "50");
        items1.add(items11);
        order1.put("items", items1);
        order1.put("cost", 50);
        order1.put("user_id", "userid");
        order1.put("order_id", "O20240912160034");
        order1.put("ip", "192.168.0.1");
        order1.put("pfn", "0");
        orders.add(order1);
        Map<Object, Object> rawData = new HashMap<Object, Object>();
        rawData.put("orders", orders);
        return rawData;
    }
    /**
     * 取得服務位置
     * @return 串接服務資料
     */
    public Map getService() {
        Map<Object, Object> rawData = new HashMap<Object, Object>();
        rawData.put("service_name", "agent");
        rawData.put("cmd", "api/groupcreator");
        return rawData;
    }
    /**
     * AES 256 加密
     * @param rawData 原始資料
     * @param AesKey AES256金鑰字串
     * @return 轉換成Base64資料
     */
    public String encrypt(Map rawData, String AesKey) {
        try {
            ObjectMapper objMapper = new ObjectMapper();
            byte[] data = objMapper.writeValueAsString(rawData).getBytes(UTF_8);
            byte[] key = AesKey.getBytes(UTF_8);
            // 16 bytes is the IV size for AES256
            PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(
                    new CBCBlockCipher(new AESEngine()));
            // Random iv
            SecureRandom rng = new SecureRandom();
            byte[] ivBytes = new byte[16];
            rng.nextBytes(ivBytes);
            cipher.init(true, new ParametersWithIV(new KeyParameter(key),
                    ivBytes));
            byte[] outBuf = new byte[cipher.getOutputSize(data.length)];
            int processed = cipher
                    .processBytes(data, 0, data.length, outBuf, 0);
            processed += cipher.doFinal(outBuf, processed);
            byte[] outBuf2 = new byte[processed + 16]; // Make room for iv
            System.arraycopy(ivBytes, 0, outBuf2, 0, 16); // Add iv
            System.arraycopy(outBuf, 0, outBuf2, 16, processed);
            Base64.Encoder encoder = Base64.getEncoder();
            String base64 = encoder.encodeToString(outBuf2);
            return base64;
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return null;
    }
    /**
     * 資料 POST 到主機
     * @param qstr 串接資料
     * @return 服務回傳JSON資訊
     */
    public String post(String qstr) {
        String result = "";
        try {
            // 資料
            byte[] qstr_bytes = qstr.getBytes(StandardCharsets.UTF_8);
            URL iurl = new URL(this.url);
            SSLContext sc = SSLContext.getInstance("TLSv1.2"); // $NON-NLS-1$
            sc.init(null, null, new java.security.SecureRandom());
            HttpsURLConnection con = (HttpsURLConnection) iurl.openConnection();
            con.setSSLSocketFactory(sc.getSocketFactory());
            con.setRequestMethod("POST");
            con.setRequestProperty("Content-Type",
                    "application/x-www-form-urlencoded");
            con.setRequestProperty("Content-Length",
                    String.valueOf(qstr_bytes.length));
            con.setRequestProperty("Accept-Charset", "UTF-8");
            con.setDoOutput(true);
            con.setDoInput(true);
            con.getOutputStream()
                    .write(qstr.getBytes(Charset.forName("UTF-8")));
            con.getOutputStream().flush();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    con.getInputStream(), "UTF-8"));
            String inputLine;
            StringBuffer response = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine + "\r\n");
            }
            try {
                result = response.toString();
            } finally {
                in.close();
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return result;
    }
    /**
     * 取得送出欄位資料
     * @return POST完整資料
     */
    public String getPostData() {
        String postData = "";
        try {
            // Base64需要使用UrlEncode做傳輸
            String data_toUrlEncode = URLEncoder.encode(
                    this.encrypt(this.getRawData(), this.storeKey), "UTF-8");
            String svr_toUrlEncode = URLEncoder.encode(
                    this.encrypt(this.getService(), this.storeKey), "UTF-8");
            postData = "store_uid=" + this.storeUid + "&service="
                    + svr_toUrlEncode + "&encry_data=" + data_toUrlEncode;
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return postData;
    }
}
const crypto = require('crypto');
const httpRequest = require('https');
/**
 * 特約商店串接-nodejs PayPage多訂單金流交易
 */
function StoreOrder() {
    // 特約商店商務代號
    this.storeUid = "289151880011";
    // 特約商店金鑰或認證碼
    this.storeKey = "25HwOoT9E3ahsGEwVcJDq3CEmLxTIEYn";
    // 串接交易位置
    this.url = "https://ka.usecase.cc/api/init";
};
/**
 * 取得串接欄位資料
 */
StoreOrder.prototype.getRawData = function () {
    return {
        orders: [
                    {
                     'store_uid': "289151880011",
                        [
                            {
                             'id': "1",
                             'name': "商品名稱",
                             'cost': "50",
                             'amount': "1",
                             'total': "50"
                            }
                        ],
                     'cost': 50,
                     'user_id': "userid",
                     'order_id': "O20240912160034",
                     'ip': "192.168.0.1",
                     'pfn': "0"
                    }
                ],
    };
};
/**
 * 取得服務位置
 */
StoreOrder.prototype.getService = function () {
    return {
        service_name: "agent",
        cmd: "api/groupcreator"
    };
};
/**
 * AES 256 加密
 */
StoreOrder.prototype.encrypt = function (fields, key) {
    let eData = JSON.stringify(fields);
    const blockSize = 16;
    const iv = crypto.randomBytes(blockSize);
    const encryptor = crypto.createCipheriv('aes-256-cbc', key, iv);
    let tmpCipher = encryptor.update(Buffer.from(eData));
    let finalCipher = encryptor.final();
    const tempData = Buffer.concat([tmpCipher, finalCipher], tmpCipher.length + finalCipher.length);
    let data = Buffer.concat([iv, tempData], iv.length + tempData.length).toString('base64');
    return data;
};
/**
 * 資料 POST 到主機
 */
StoreOrder.prototype.post = function (postData) {
    return new Promise((res, rej) => {
        let options = {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            rejectUnauthorized: false
        };
        let send_process = httpRequest.request(this.url, options, (api_res) => {
            let res_data = "";
            api_res.on('data', (tmp_data) => {
                res_data += tmp_data;
            });
            api_res.on('end', () => {
                res(res_data);
            });
        });
        send_process.write(JSON.stringify(postData));
        send_process.end();
    });
};
/**
 * 取得送出欄位資料
 */
StoreOrder.prototype.getPostData = function () {
    return {
        "store_uid": this.storeUid,
        "service": this.encrypt(this.getService(), this.storeKey),
        "encry_data": this.encrypt(this.getRawData(), this.storeKey)
    };
};
/**
 * 執行
 */
StoreOrder.prototype.run = async function () {
    json = await this.post(this.getPostData())
    console.log(json);
};
StoreOrder = new StoreOrder();
StoreOrder.run();
# -*- coding: utf-8 -*-
import json
import base64
import requests
from Crypto.Cipher import AES
from Crypto.Util import Padding
from Crypto.Random import get_random_bytes
"""特約商店串接-nodejs PayPage多訂單金流交易
"""
class StoreOrder:
    # 特約商店商務代號
    storeUid = "289151880011"
    # 特約商店金鑰或認證碼
    storeKey = b"25HwOoT9E3ahsGEwVcJDq3CEmLxTIEYn"
    # 串接交易位置
    url = "https://ka.usecase.cc/api/init"
    def getRawData(self):
        """取得串接欄位資料
        Returns:
            {dict}: 欄位資料
        """
        rawData = {
            'orders': [
                          {
                           'store_uid': "289151880011",
                              [
                                  {
                                   'id': "1",
                                   'name': "商品名稱",
                                   'cost': "50",
                                   'amount': "1",
                                   'total': "50"
                                  }
                              ],
                           'cost': 50,
                           'user_id': "userid",
                           'order_id': "O20240912160034",
                           'ip': "192.168.0.1",
                           'pfn': "0"
                          }
                      ],
        }
        return rawData
    def getService(self):
        """取得服務位置
        Returns:
            {dict}: 服務位置資料
        """
        return {
            'service_name': 'agent',
            'cmd': 'api/groupcreator'
        }
    def encrypt(self, fields, key):
        """AES 256 加密
        Args:
            fields {dict}: 欄位資料
            key {bytes}: AES金鑰
        Returns:
            {string}: 加密資料
        """
        data = json.dumps(fields, separators=(',', ':'))
        data = Padding.pad(data.encode('utf-8'), AES.block_size)
        iv = get_random_bytes(AES.block_size)
        cipher = AES.new(key, AES.MODE_CBC, iv)
        data = cipher.encrypt(data)
        data = base64.b64encode(iv + data)
        return data
    def post(self, postData):
        """資料 POST 到主機
        Args:
            postData {dict}: 欄位資料
        Returns:
            {string}: JSON資料
        """
        result = requests.post(self.url, postData)
        return result.text
    def getPostData(self):
        """取得送出欄位資料
        Returns:
            {dict}: 欄位資料
        """
        postData = {
            'store_uid': self.storeUid,
            'service': self.encrypt(self.getService(), self.storeKey),
            'encry_data': self.encrypt(self.getRawData(), self.storeKey)
        }
        return postData
    def run(self):
        """執行
        """
        json = self.post(self.getPostData())
        print(json)
StoreOrder = StoreOrder()
StoreOrder.run()
回傳 JSON 結構如下:
{
    "code": "200",
    "msg": "資料正確",
    "url": "https://p.usecase.cc/47.html",
    "uid_list": [
        {
            "uid": 216140,
            "order_id": "O20240913123400",
            "items": [
                {
                    "id": "1",
                    "name": "商品名稱",
                    "cost": "50",
                    "amount": "1",
                    "total": "50"
                }
            ]
        }
    ],
    "uid_result": [
        {
            "code": "200",
            "msg": "資料正確",
            "uid": 216140,
            "key": "de509e214c0b1715b90ea07bb928e27f"
        }
    ],
    "uid": 47,
    "key": "ed4a9c6c11d29e40d94142452e475f94"
}
此交易請求參數內含交易訂單編號,與查詢用之金鑰,以及付費網址。貴司也可將此交易訂單編號綁定貴司的消費者訂單,我們會透過主動回報機制,以POST方式回報交易即時資訊,回報網址可以在管理系統中設定,啟動服務後,系統就會主動回傳訂單狀態。
特約商店『PayPage多訂單金流交易』參數說明
| 欄位 | 型態 | 說明 | 
|---|---|---|
| store_uid | string(16) | 特約商店商務代號 | 
| service | text | {"service_name":"agent","cmd":"api\/groupcreator"}JSON格式,AES256加密資料  | 
| encry_data | text | 『PayPage多訂單金流交易』欄位參考 JSON格式,AES256加密資料  | 
『PayPage多訂單金流交易』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| orders | array | 信用卡類交易時,是否使用自動請款模式(預設自動請款) | 每筆『特約商店原始丟過來的資料』欄位參考 | 
『PayPage多訂單金流交易』回傳欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| code | string | 交易回傳碼 | |
| msg | string | 回傳訊息 | |
| uid | string | 金流交易group訂單UID | |
| key | string | group訂單UID 交易驗証碼 | |
| url | string | 交易網址 | |
| uid_list | array | 金流每筆訂單商品內容 | 每筆『金流每筆訂單商品內容』欄位參考 | 
| uid_result | array | 金流交易回傳 | 每筆『金流交易回傳』欄位參考 | 
『特約商店原始丟過來的資料』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| vendor_uid | string | 供應商代號 | |
| acquisition_cost | string | 成本(預設0) | |
| store_uid | string | 特約商店代碼 | 必填 | 
| user_id | string | 消費者帳號 | 必填 | 
| user_name | string | 消費者姓名 | |
| user_real_name | string | 消費者真實姓名 | |
| user_english_name | string | 消費者英文姓名 | |
| user_zipcode | string | 消費者郵遞區號 | |
| user_address | string | 消費者帳單地址 | |
| user_sn_type | string | 證號類型 | 『證號類型』值參考 | 
| user_sn | string | 付款人身分證/統一證號/護照號碼 | |
| user_phone | string | 消費者家用電話 | |
| user_cellphone_code | string | 消費者行動電話國碼 | |
| user_cellphone | string | 消費者行動電話 | |
| user_email | string | 消費者 E-Mail | |
| user_birthday | string | 消費者生日 | |
| cost | string | 訂單總金額 = 物品之總價加總 + 折價 + 運費(如為定期定額交易,此為每一期的應扣金額)  | 
必填 | 
| currency | string | 預設交易幣別(預設為TWD新台幣) | 『幣別類型』值參考 | 
| enable_dcc | integer | 啟用dcc(自動換匯) | 『自動換匯』值參考 | 
| order_id | string | 訂單編號(訂單編號最長為50bytes) | 必填 | 
| ip | string | 消費者來源 IP | 必填 | 
| item | string | 訂單內物品數 | |
| items | array | 訂單物品項目 | 必填 每筆『商品項目 多訂單用到』欄位參考  | 
| regular | string | 定期定額付費,期數單位 | 『分期類型定義』值參考 | 
| regular_total | string | 總期數(如為 12 期即代入 12,如果不設定終止期,請代入 0) | |
| regular_first_charge_date | string | 定期扣款起扣日 若未指定日期、或早於今日,則將判定為當日扣款 格式為 YYYYMMDD,如 20090916  | 
|
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | |
| pfn | string | 預選付費方法 | 『付款方式』值參考 | 
| actual_pay_mode | string | 實際支付方式 (當pfn為CASH-自行收款時,告知系統實際收款方式)  | 
『自行收款付款方式』值參考 | 
| interface | string | interface 對照表 | |
| discount | string | 折價金額 (預設0) | |
| success_returl | string | 交易成功導頁網址 | |
| failure_returl | string | 交易失敗導頁網址 | |
| limit_pay_days | integer | 虛擬帳號與超商代碼使用之有效天數 | |
| shipping_fee | string | 運費 | |
| enable_quickpay | integer | 啟用快速結帳 | 『啟用快速結帳』值參考 | 
| card_save_platform | int | 卡號儲存於哪個平台,特約商店發動者,強制為3 | 1.經銷商 3.特約商店  | 
| enable_ewallet | integer | 啟用電子錢包 | 『啟用電子錢包』值參考 | 
| virtual_pan | string | 電子錢包虛擬卡號 | |
| ewallet_type | integer | 電子錢包執行類型 | 『電子錢包執行類型』值參考 | 
| transaction_type | integer | 交易類型 | 『交易類型』值參考 | 
| creditcard_installment | string | 國內信用卡分期顯示限定 JSON 格式如下 { "3": ["013", "822", "808"], "6": ["822", "812"] }  | 
|
| each_code | string | eACH交易代碼(如果使用eACH必須指定交易代碼) | |
| issue_invoice_state | integer | 開立發票 | 『電子發票是否開立狀態』值參考 | 
| invoice_ratetype | integer | 電子發票稅率別 | 『電子發票稅率別』值參考 | 
| invoice_tax_rate | float | 電子發票稅率:預設0.05(零稅與免稅帶0) | |
| invoice_remark | string | 發票註記(依加值中心提供註記功能) | |
| invoice_input_type | integer | 電子發票開立類型 | 『電子發票開立類型』值參考 | 
| invoice_cloud_type | string | 「雲端發票」類型 | 當invoice_input_type為1,此狀態才有效 『雲端發票類型』值參考  | 
| invoice_tax_id | string | 統一編號 | 當invoice_input_type為1,此欄位才有效,非必要 | 
| invoice_mobile_code | string | 手機條碼 | 當invoice_cloud_type為2,此欄位才有效 | 
| invoice_natural_person | string | 自然人憑證條碼 | 當invoice_cloud_type為3,此欄位才有效 | 
| invoice_m_post_zone | string | EMail 紙本寄送郵遞區號 | 當invoice_cloud_type為4,此欄位才有效,非必須 | 
| invoice_m_address | string | EMail 紙本寄送住址 | 當invoice_cloud_type為4,此欄位才有效,非必須 | 
| invoice_love_code | string | 愛心碼 | 當invoice_input_type為2,此欄位才有效 | 
| invoice_b2b_title | string | 發票抬頭 | 當invoice_input_type為3時,此欄位才有效 | 
| invoice_b2b_id | string | 統一編號 | 當invoice_input_type為3時,此欄位才有效 | 
| invoice_b2b_post_zone | string | 發票地址郵遞區號 | |
| invoice_b2b_address | string | 發票地址 | 當invoice_input_type為3時,此欄位才有效 | 
| invoice_b2b_title_force | string | 若選擇實體發票時,發票抬頭無法異動。 | 『電子發票欄位異動』值參考 | 
| invoice_b2b_id_force | string | 若選擇實體發票時,統一編號無法異動。 | 『電子發票欄位異動』值參考 | 
| invoice_b2b_address_force | integer | 若選擇實體發票時,預設地址無法異動。 | 『電子發票欄位異動』值參考 | 
| invoice_save_platform | int | 發票儲存於哪個平台,特約商店發動者,強制為3 | 1.經銷商 2.特約商店  | 
| user_data | object | 無卡分期消費者資訊 | 『無卡分期消費者資訊』欄位參考 | 
| files_path | string | 無卡分期上傳檔案路徑 (JSON多筆格式) | 『無卡分期檔案』值參考 | 
| price | string | 儲值交易之交易金額/點數 (儲值交易以此欄位辨識交易金額/點數) | |
| recharge_code | string | 儲值交易時,使用當時儲值之儲值產品代碼 | |
| recharge_items | array | 儲值交易用物品資訊 | 每筆『儲值扣值商品項目』欄位參考 | 
| agent_sms_fee_type | integer | 經銷商代收費是否含簡訊費 | 『含不含簡訊費』值參考 | 
| agent_charge_fee_type | integer | 經銷商代收費是否含手續費 | 『含不含手續費類型』值參考 | 
| agent_charge_fee | integer | 經銷商代收費(代收費不為0時,才為代收費模式) | |
| is_agent_charge | integer | 是否為經銷商代收費模式 若 is_agent_charge 有指定,以指定優先 若欄位agent_charge_fee有費用,或經銷商代收費是含簡訊費、或經銷商代收費含手續費,則預設為1 若欄位agent_charge_fee無費用,且經銷商代收費不含簡訊費、或經銷商代收費不含手續費或參欄位都未使用則預設為0  | 
『是否為經銷商代收費模式』值參考 | 
| creditcard_is_automatic_payment | string | 信用卡類交易時,是否使用自動請款模式(預設自動請款) | 『信用卡自動請款類型』值參考 | 
| 『信用卡授權請款模式類型』值參考 | 
『金流交易回傳』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | 金流交易訂單UID | |
| order_id | string | 商家自訂訂單編號 | |
| items | array | 訂單物品項目 | 每筆『商品項目 多訂單用到』欄位參考 | 
『金流交易回傳』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| code | string | 交易回傳碼 | |
| msg | string | 回傳訊息 | |
| uid | string | 金流交易訂單UID | |
| key | string | 交易驗証碼 | 
| 支援語系名稱 | 語系編碼 | 
|---|---|
| 繁體中文版 | zh-TW(預設) | 
| 簡體中文版 | zh-CN | 
| 英文版 | en | 
| 印尼語 | id | 
『交易完成回傳資訊』回報欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| card_type | string | 信用卡卡別 | 『信用卡別類型』值參考 | 
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| is_agent_charge | int | 是否為經銷商代收費模式 | 『是否為經銷商代收費模式』值參考 | 
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | integer | 交易類型 | 『交易類型定義』值參考 | 
| redeem | string | 紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 銀行代碼 虛擬帳號資訊  | 
|
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考 『超商條碼繳費』值參考  | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
『非即時交易回傳資訊』回報欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| card_type | string | 信用卡卡別 | 『信用卡別類型』值參考 | 
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| is_agent_charge | int | 是否為經銷商代收費模式 | 『是否為經銷商代收費模式』值參考 | 
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | integer | 交易類型 | 『交易類型定義』值參考 | 
| redeem | string | 紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 銀行代碼 虛擬帳號資訊  | 
|
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考  | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
『訂單確認回傳資訊』回報欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| card_type | string | 信用卡卡別 | 『信用卡別類型』值參考 | 
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| is_agent_charge | int | 是否為經銷商代收費模式 | 『是否為經銷商代收費模式』值參考 | 
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | integer | 交易類型 | 『交易類型定義』值參考 | 
| redeem | string | 紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 銀行代碼 虛擬帳號資訊  | 
|
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考  | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
交易查詢
<?php
/**
 * 特約商店串接-交易查詢
 */
final class StoreQuery
{
    /**
     * 特約商店商務代號
     * @var string
     */
    public $storeUid = "289151880002";
    /**
     * 特約商店金鑰或認證碼
     * @var string
     */
    public $storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
    /**
     * 串接交易位置
     * @var string
     */
    public $url = "https://pay.usecase.cc/api/init";
    /**
     * 取得串接欄位資料
     * @return array
     */
    public function getRawData()
    {
        $rawData = array();
        $rawData['uid'] = "34799";
        $rawData['key'] = "c23dd140aa9536eb4c09ef053171110f";
        return $rawData;
    }
    /**
     * 取得服務位置
     * @return array
     */
    public function getService()
    {
        return array(
            'service_name' => 'agent',
            'cmd' => 'api/queryordergroup'
        );
    }
    /**
     * AES 256 加密
     * @param array $fields
     * @param string $key
     * @return string
     */
    public function encrypt($fields, $key)
    {
        $data = json_encode($fields);
        $size = openssl_cipher_iv_length('AES-256-CBC');
        $iv   = openssl_random_pseudo_bytes($size);
        $data = openssl_encrypt($data, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
        $data = base64_encode($iv . $data);
        return $data;
    }
    /**
     * 資料 POST 到主機
     * @param array $postData
     * @return mixed
     */
    public function post($postData = [])
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_URL, $this->url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
    /**
     * 取得送出欄位資料
     * @return array
     */
    public function getPostData ()
    {
        $postData = array();
        $postData['store_uid'] = $this->storeUid;
        $postData['service'] = $this->encrypt($this->getService(), $this->storeKey);
        $postData['encry_data'] = $this->encrypt($this->getRawData(), $this->storeKey);
        return $postData;
    }
    /**
     * 執行
     */
    public function run()
    {
        $json = $this->post($this->getPostData());
        echo $json;
    }
}
$StoreQuery = new StoreQuery();
$StoreQuery->run();
?>
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Collections;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Dynamic;
/// <summary>
/// 建議使用.net framework4.5以上版本
/// 1.請透過NuGet安裝Newtonsoft.Json,若.net framework小於4.5請安裝Newtonsoft.Json 7.0以下版本
/// 2.若貴司.net framework小於4 可能無法使用dynamic,若是自行組陣列
/// 3.若貴司.net framework小於3.5 可能無法使用AES類別,若是參閱微軟網站使用較舊方式進行加密
/// 4.若貴司.net framework小於3.5 可能沒有Linq可使用,故data只能組字串,Newtonsoft.Json也可能無法使用
/// </summary>
namespace MyPay {
    /// <summary>
    /// 特約商店串接-交易查詢
    /// </summary>
    public class StoreQuery {
        /// <summary>
        /// 特約商店商務代號
        /// </summary>
        public string storeUid = "289151880002";
        /// <summary>
        /// 特約商店金鑰或認證碼
        /// </summary>
        public string storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
        /// <summary>
        /// 串接交易位置
        /// </summary>
        public string url = "https://pay.usecase.cc/api/init";
        /// <summary>
        /// 執行
        /// </summary>
        static void Main() {
            StoreQuery simulator = new StoreQuery();
            //僅限走https的Tls 1.2以上版本
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            //發送至遠端
            var result = simulator.Post(simulator.GetPostData());
            System.Console.WriteLine(result);
        }
        /// <summary>
        /// 取得串接欄位資料
        /// </summary>
        private dynamic GetRawData() {
            dynamic rawData = new ExpandoObject();
            rawData.uid = "34799";
            rawData.key = "c23dd140aa9536eb4c09ef053171110f";
            return rawData;
        }
        /// <summary>
        /// 取得服務位置
        /// </summary>
        private ServiceRequest GetService() {
            ServiceRequest rawData = new ServiceRequest();
            rawData.service_name = "agent";
            rawData.cmd = "api/queryordergroup";
            return rawData;
        }
        /// <summary>
        /// 取得送出欄位資料
        /// </summary>
        private NameValueCollection GetPostData() {
            string data_json = JsonConvert.SerializeObject(GetRawData(), Formatting.None);
            string svr_json = JsonConvert.SerializeObject(GetService(), Formatting.None);; //依API種類調整
            //產生AES向量
            var IV = GetBytesIV();
            //進行加密
            var data_encode = Encrypt(data_json, this.storeKey, IV);
            var svr_encode = Encrypt(svr_json, this.storeKey, IV);
            //請注意使用的 Http Post 套件是否會自動加上UrlEncode,本Post範例為原始方式,故須加上UrlEncode
            //若自行使用的套件會自動補上UrlEncode,則請忽略下面的UrlEncode,避免做了兩次UrlEncode
            string data_toUrlEncode = HttpUtility.UrlEncode(data_encode);
            string svr_toUrlEncode = HttpUtility.UrlEncode(svr_encode);
            NameValueCollection postData = new NameValueCollection();
            postData["store_uid"] = this.storeUid;
            postData["service"] = svr_toUrlEncode;
            postData["encry_data"] = data_toUrlEncode;
            return postData;
        }
        /// <summary>
        /// AES 256 加密
        /// </summary>
        /// <param name="data"></param>
        /// <param name="key"></param>
        /// <param name="byteIV"></param>
        /// <returns></returns>
        private string Encrypt(string data, string key, byte[] byteIV) {
            var byteKey = System.Text.Encoding.UTF8.GetBytes(key);
            var enBytes = AES_Encrypt(data, byteKey, byteIV);
            return Convert.ToBase64String(BytesAdd(byteIV, enBytes));
        }
        /// <summary>
        /// AES 256 加密處理
        /// </summary>
        /// <param name="original"></param>
        /// <param name="key"></param>
        /// <param name="iv"></param>
        /// <returns></returns>
        private byte[] AES_Encrypt(string original, byte[] key, byte[] iv) {
            try {
                var data = Encoding.UTF8.GetBytes(original);
                var cipher = Aes.Create().CreateEncryptor(key, iv);
                var de = cipher.TransformFinalBlock(data, 0, data.Length);
                return de;
            } catch {
                return null;
            }
        }
        /// <summary>
        /// 轉換Bytes
        /// </summary>
        /// <param name="a"></param>
        /// <param name="arryB"></param>
        /// <returns></returns>
        private byte[] BytesAdd(byte[] a, params byte[][] arryB) {
            List < byte > c = new List < byte > ();
            c.AddRange(a);
            arryB.ToList().ForEach(b => {
                c.AddRange(b);
            });
            return c.ToArray();
        }
        /// <summary>
        /// 產生AES的IV
        /// </summary>
        /// <returns></returns>
        private static byte[] GetBytesIV() {
            var aes = System.Security.Cryptography.AesCryptoServiceProvider.Create();
            aes.KeySize = 256;
            aes.GenerateIV();
            return aes.IV;
        }
        /// <summary>
        /// 資料 POST 到主機
        /// </summary>
        /// <param name="pars"></param>
        /// <returns></returns>
        private string Post(NameValueCollection pars) {
            string result = string.Empty;
            string param = string.Empty;
            if (pars.Count > 0) {
                pars.AllKeys.ToList().ForEach(key => {
                    param += key + "=" + pars[key] + "&";
                });
                if (param[param.Length - 1] == '&') {
                    param = param.Remove(param.Length - 1);
                }
            }
            byte[] bs = Encoding.UTF8.GetBytes(param);
            try {
                HttpWebRequest req = (HttpWebRequest) HttpWebRequest.Create(this.url);
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                req.ContentLength = bs.Length;
                using(Stream reqStream = req.GetRequestStream()) {
                    reqStream.Write(bs, 0, bs.Length);
                }
                using(WebResponse wr = req.GetResponse()) {
                    Encoding myEncoding = Encoding.GetEncoding("UTF-8");
                    using(StreamReader myStreamReader = new StreamReader(wr.GetResponseStream(), myEncoding)) {
                        result = myStreamReader.ReadToEnd();
                    }
                }
                req = null;
            } catch (WebException ex) {
                throw new WebException(ex.Message + "params : " + param, ex, ex.Status, ex.Response);
            }
            return result;
        }
    }
    /// <summary>
    /// 串接服務請求欄位
    /// </summary>
    public class ServiceRequest {
        public string service_name { get; set; }
        public string cmd { get; set; }
    }
}
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URLEncoder;
import java.util.*;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import static java.nio.charset.StandardCharsets.UTF_8;
import org.spongycastle.crypto.engines.AESEngine;
import org.spongycastle.crypto.modes.CBCBlockCipher;
import org.spongycastle.crypto.paddings.PaddedBufferedBlockCipher;
import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.crypto.params.ParametersWithIV;
import java.security.SecureRandom;
/**
 * 特約商店串接-交易查詢
 * 1. jackson-core 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
 * 2. jackson-databind 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
 * 3. jackson-annotations 下載 https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
 * 4. Spongy Castle 下載 https://mvnrepository.com/artifact/com.madgag.spongycastle/core
 */
public class StoreQuery {
    /**
     * 特約商店商務代號
     */
    String storeUid = "289151880002";
    /**
     * 特約商店金鑰或認證碼
     */
    String storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
    /**
     * 串接交易位置
     */
    String url = "https://pay.usecase.cc/api/init";
    /**
     * 執行
     * @param  args
     */
    public static void main(String[] args) {
        StoreQuery simulator = new StoreQuery();
        String json = simulator.post(simulator.getPostData());
        System.out.print(json);
    }
    @SuppressWarnings(value = { "unchecked", "deprecation" })
    /**
     * 取得串接欄位資料
     * @return 串接原始資料
     */
    public Map getRawData() {
        Map<Object, Object> rawData = new HashMap<Object, Object>();
        rawData.put("uid", "34799");
        rawData.put("key", "c23dd140aa9536eb4c09ef053171110f");
        return rawData;
    }
    /**
     * 取得服務位置
     * @return 串接服務資料
     */
    public Map getService() {
        Map<Object, Object> rawData = new HashMap<Object, Object>();
        rawData.put("service_name", "agent");
        rawData.put("cmd", "api/queryordergroup");
        return rawData;
    }
    /**
     * AES 256 加密
     * @param rawData 原始資料
     * @param AesKey AES256金鑰字串
     * @return 轉換成Base64資料
     */
    public String encrypt(Map rawData, String AesKey) {
        try {
            ObjectMapper objMapper = new ObjectMapper();
            byte[] data = objMapper.writeValueAsString(rawData).getBytes(UTF_8);
            byte[] key = AesKey.getBytes(UTF_8);
            // 16 bytes is the IV size for AES256
            PaddedBufferedBlockCipher cipher = new PaddedBufferedBlockCipher(
                    new CBCBlockCipher(new AESEngine()));
            // Random iv
            SecureRandom rng = new SecureRandom();
            byte[] ivBytes = new byte[16];
            rng.nextBytes(ivBytes);
            cipher.init(true, new ParametersWithIV(new KeyParameter(key),
                    ivBytes));
            byte[] outBuf = new byte[cipher.getOutputSize(data.length)];
            int processed = cipher
                    .processBytes(data, 0, data.length, outBuf, 0);
            processed += cipher.doFinal(outBuf, processed);
            byte[] outBuf2 = new byte[processed + 16]; // Make room for iv
            System.arraycopy(ivBytes, 0, outBuf2, 0, 16); // Add iv
            System.arraycopy(outBuf, 0, outBuf2, 16, processed);
            Base64.Encoder encoder = Base64.getEncoder();
            String base64 = encoder.encodeToString(outBuf2);
            return base64;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 資料 POST 到主機
     * @param qstr 串接資料
     * @return 服務回傳JSON資訊
     */
    public String post(String qstr) {
        String result = "";
        try {
            // 資料
            byte[] qstr_bytes = qstr.getBytes(StandardCharsets.UTF_8);
            URL iurl = new URL(this.url);
            SSLContext sc = SSLContext.getInstance("TLSv1.2"); // $NON-NLS-1$
            sc.init(null, null, new java.security.SecureRandom());
            HttpsURLConnection con = (HttpsURLConnection) iurl.openConnection();
            con.setSSLSocketFactory(sc.getSocketFactory());
            con.setRequestMethod("POST");
            con.setRequestProperty("Content-Type",
                    "application/x-www-form-urlencoded");
            con.setRequestProperty("Content-Length",
                    String.valueOf(qstr_bytes.length));
            con.setRequestProperty("Accept-Charset", "UTF-8");
            con.setDoOutput(true);
            con.setDoInput(true);
            con.getOutputStream()
                    .write(qstr.getBytes(Charset.forName("UTF-8")));
            con.getOutputStream().flush();
            BufferedReader in = new BufferedReader(new InputStreamReader(
                    con.getInputStream(), "UTF-8"));
            String inputLine;
            StringBuffer response = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine + "\r\n");
            }
            try {
                result = response.toString();
            } finally {
                in.close();
            }
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return result;
    }
    /**
     * 取得送出欄位資料
     * @return POST完整資料
     */
    public String getPostData() {
        String postData = "";
        try {
            // Base64需要使用UrlEncode做傳輸
            String data_toUrlEncode = URLEncoder.encode(
                    this.encrypt(this.getRawData(), this.storeKey), "UTF-8");
            String svr_toUrlEncode = URLEncoder.encode(
                    this.encrypt(this.getService(), this.storeKey), "UTF-8");
            postData = "store_uid=" + this.storeUid + "&service="
                    + svr_toUrlEncode + "&encry_data=" + data_toUrlEncode;
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
        return postData;
    }
}
const crypto = require('crypto');
const httpRequest = require('https');
/**
 * 特約商店串接-交易查詢
 */
function StoreQuery() {
    // 特約商店商務代號
    this.storeUid = "289151880002";
    // 特約商店金鑰或認證碼
    this.storeKey = "KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx";
    // 串接交易位置
    this.url = "https://pay.usecase.cc/api/init";
};
/**
 * 取得串接欄位資料
 */
StoreQuery.prototype.getRawData = function () {
    return {
        uid: "34799",
        key: "c23dd140aa9536eb4c09ef053171110f"
    };
};
/**
 * 取得服務位置
 */
StoreQuery.prototype.getService = function () {
    return {
        service_name: "agent",
        cmd: "api/queryordergroup"
    };
};
/**
 * AES 256 加密
 */
StoreQuery.prototype.encrypt = function (fields, key) {
    let eData = JSON.stringify(fields);
    const blockSize = 16;
    const iv = crypto.randomBytes(blockSize);
    const encryptor = crypto.createCipheriv('aes-256-cbc', key, iv);
    let tmpCipher = encryptor.update(Buffer.from(eData));
    let finalCipher = encryptor.final();
    const tempData = Buffer.concat([tmpCipher, finalCipher], tmpCipher.length + finalCipher.length);
    let data = Buffer.concat([iv, tempData], iv.length + tempData.length).toString('base64');
    return data;
};
/**
 * 資料 POST 到主機
 */
StoreQuery.prototype.post = function (postData) {
    return new Promise((res, rej) => {
        let options = {
            method: "POST",
            headers: {
                "Content-Type": "application/json"
            },
            rejectUnauthorized: false
        };
        let send_process = httpRequest.request(this.url, options, (api_res) => {
            let res_data = "";
            api_res.on('data', (tmp_data) => {
                res_data += tmp_data;
            });
            api_res.on('end', () => {
                res(res_data);
            });
        });
        send_process.write(JSON.stringify(postData));
        send_process.end();
    });
};
/**
 * 取得送出欄位資料
 */
StoreQuery.prototype.getPostData = function () {
    return {
        "store_uid": this.storeUid,
        "service": this.encrypt(this.getService(), this.storeKey),
        "encry_data": this.encrypt(this.getRawData(), this.storeKey)
    };
};
/**
 * 執行
 */
StoreQuery.prototype.run = async function () {
    json = await this.post(this.getPostData())
    console.log(json);
};
StoreQuery = new StoreQuery();
StoreQuery.run();
import json
import base64
import requests
from Crypto.Cipher import AES
from Crypto.Util import Padding
from Crypto.Random import get_random_bytes
"""特約商店串接-交易查詢
"""
class StoreQuery:
    # 特約商店商務代號
    storeUid = "289151880002"
    # 特約商店金鑰或認證碼
    storeKey = b"KYTjd9ACcjGaTK6V3zWmMkyrQS08Ndcx"
    # 串接交易位置
    url = "https://pay.usecase.cc/api/init"
    def getRawData(self):
        """取得串接欄位資料
        Returns:
            {dict}: 欄位資料
        """
        rawData = {
            'uid': "34799",
            'key': "c23dd140aa9536eb4c09ef053171110f"
        }
        return rawData
    def getService(self):
        """取得服務位置
        Returns:
            {dict}: 服務位置資料
        """
        return {
            'service_name': 'agent',
            'cmd': 'api/queryordergroup'
        }
    def encrypt(self, fields, key):
        """AES 256 加密
        Args:
            fields {dict}: 欄位資料
            key {bytes}: AES金鑰
        Returns:
            {string}: 加密資料
        """
        data = json.dumps(fields, separators=(',', ':'))
        data = Padding.pad(data.encode('utf-8'), AES.block_size)
        iv = get_random_bytes(AES.block_size)
        cipher = AES.new(key, AES.MODE_CBC, iv)
        data = cipher.encrypt(data)
        data = base64.b64encode(iv + data)
        return data
    def post(self, postData):
        """資料 POST 到主機
        Args:
            postData {dict}: 欄位資料
        Returns:
            {string}: JSON資料
        """
        result = requests.post(self.url, postData)
        return result.text
    def getPostData(self):
        """取得送出欄位資料
        Returns:
            {dict}: 欄位資料
        """
        postData = {
            'store_uid': self.storeUid,
            'service': self.encrypt(self.getService(), self.storeKey),
            'encry_data': self.encrypt(self.getRawData(), self.storeKey)
        }
        return postData
    def run(self):
        """執行
        """
        json = self.post(self.getPostData())
        print(json)
StoreQuery = StoreQuery()
StoreQuery.run()
回傳 JSON 結構如下:
{
    "key": "c011e403fa73b088ca3d50aacfa9c43a",
    "prc": "250",
    "cardno": "493817******0003",
    "acode": "AA1234",
    "issuing_bank": "合作金庫",
    "issuing_bank_uid": "006",
    "is_agent_charge": 0,
    "transaction_mode": 1,
    "supplier_name": "高鉅金融",
    "supplier_code": "T0",
    "order_id": "20200227165CFAB2C9",
    "user_id": "userid",
    "uid": 59665,
    "cost": 10,
    "currency": "TWD",
    "actual_cost": 10,
    "actual_currency": "TWD",
    "love_cost": 0,
    "retmsg": "付款完成",
    "pay_mode_uid": 1,
    "pfn": "CREDITCARD",
    "trans_type": 1,
    "redeem": "",
    "installment": "",
    "finishtime": "20200227165436",
    "store_group_id": "",
    "nois": "",
    "payment_name": "",
    "bank_id": "",
    "result_type": 4,
    "result_content_type": "CREDITCARD",
    "result_content": "{}",
    "expired_date": "",
    "appropriation_date": "20200318",
    "invoice_state": 2,
    "invoice_date": "20200227165440",
    "invoice_wordtrack": "YJ",
    "invoice_number": "00100030",
    "invoice_rand_code": "",
    "invoice_seller_ban": "",
    "invoice_buyer_ban": "",
    "invoice_left_qrcode": "",
    "invoice_middle_barcode": "",
    "invoice_right_qrcode": "",
    "invoice_title_type": 1,
    "invoice_title": "",
    "invoice_amount": "0",
    "invoice_sales_amount": "0",
    "invoice_tax_amount": "0",
    "invoice_order_detail": "[]",
    "invoice_ratetype": 1,
    "invoice_input_type": 2,
    "invoice_allowance": [],
    "echo_0": "",
    "echo_1": "",
    "echo_2": "",
    "echo_3": "",
    "echo_4": ""
}
發動交易後,如果遲遲未接收回報,可透過此方法查詢訂單交易。
特約商店『交易查詢』參數說明
| 欄位 | 型態 | 說明 | 
|---|---|---|
| store_uid | string(16) | 特約商店商務代號 | 
| service | text | {"service_name": "agent", "cmd": "api\/queryordergroup"}JSON格式,AES256加密資料  | 
| encry_data | text | 『交易查詢』欄位參考 JSON格式,AES256加密資料  | 
『交易查詢』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| is_agent_charge | int | 是否為經銷商代收費模式 | 『是否為經銷商代收費模式』值參考 | 
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | string | 付款種類 | 『交易類型定義』值參考 | 
| redeem | string | 紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 虛擬帳號銀行代碼 | |
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| appropriation_date | string | 預計撥款日期(YYYYMMDD) | |
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考  | 
| refund_order | array | 退款訂單資訊(多筆格式) | 每筆『交易查詢-退款資訊』欄位參考 | 
| cancel_order | array | 取消訂單資訊(多筆格式) | 每筆『交易查詢-取消資訊』欄位參考 | 
| invoice_state | integer | 發票開立狀態 | 『電子發票開立狀態類型』值參考 | 
| invoice_date | string | 發票開立日期(YYYYMMDD) | |
| invoice_wordtrack | string | 發票字軌 | |
| invoice_number | string | 發票號碼 | |
| invoice_rand_code | string | 電子發票隨機碼 | |
| invoice_seller_ban | string | 賣方統一編號 | |
| invoice_buyer_ban | string | 買方統一編號 | |
| invoice_left_qrcode | string | 電子發票左邊QrCode內容 | |
| invoice_middle_barcode | string | 電子發票中間Barcode內容(格式Code-39) | |
| invoice_right_qrcode | string | 電子發票右邊QrCode內容 | |
| invoice_title_type | integer | 電子發票列印標題格式 | 『電子發票紙本列印標題類型』值參考 | 
| invoice_title | integer | 電子發票列印標題格式 | 『電子發票紙本列印標題類型』值參考 | 
| invoice_print_type | integer | 電子發票列印類型 | 『電子發票列印類型』值參考 | 
| invoice_print_device | integer | 電子發票列印設備 | 『電子發票列印設備』值參考 | 
| invoice_amount | string | 電子發票銷售總額 | |
| invoice_sales_amount | string | 電子發票銷售額 | |
| invoice_tax_amount | string | 電子發票稅額 | |
| invoice_order_detail | string | 電子發票全部產品明細(JSON格式) | 『商品細項』值參考 | 
| invoice_ratetype | integer | 電子發票稅率別 | 『電子發票稅率別』值參考 | 
| invoice_input_type | integer | 電子發票開立類型 | 『電子發票開立類型』值參考 | 
| invoice_allowance | array | 電子發票折讓資訊 | 每筆『電子發票折讓資訊』欄位參考 | 
| items | array | 訂單商品項目 | 每筆『商品項目』欄位參考 | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
發動交易後,如果遲遲未接收回報,可透過此方法查詢訂單交易。
其他關聯欄位說明
關聯欄位
『商品項目 多訂單用到』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| id | string | 商品編號 | 必填 | 
| name | string | 商品名稱 | 必填 | 
| cost | integer | 商品單價 | 必填 | 
| amount | integer | 商品數量 | 必填 | 
| total | integer | 商品小計 | 必填 | 
| image_url | string | 商品圖片連結(僅LINEPay線上使用) | |
| acquisition_cost | string | 商品成本 | |
| vendor_uid | string | 供應商 | 
『商品項目』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| id | string | 商品編號 | 必填 | 
| name | string | 商品名稱 | 必填 | 
| cost | integer | 商品單價 | 必填 | 
| amount | integer | 商品數量 | 必填 | 
| total | integer | 商品小計 | 必填 | 
| image_url | string | 商品圖片連結(僅LINEPay線上使用) | |
| acquisition_cost | string | 商品成本 | |
| vendor_uid | string | 供應商 | 
『無卡分期消費者資訊』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| ip | string | 消費者登入ip | |
| user_id | string | 該消費者在特店中註冊帳號名稱 | |
| user_name | string | 消費者姓名 | |
| user_real_name | string | 消費者真實姓名 | |
| user_address_post_zone | string | 消費者地址郵遞區號 | |
| user_address | string | 消費者地址 | |
| user_sn_type | string | 證號類型 | 『證號類型』值參考 | 
| user_sn | string | 消費者身份證字號/統一證號/護照號碼 | |
| issue_date | string | 消費者發證(身分證)日期(YYYYMMDD) | |
| issue_place | string | 消費者領補換(身分證)地點 10001:北縣,10002:宜縣,10003:桃縣,10004:竹縣,10005:苗縣,10006:中縣,10007:彰縣,10008:投縣,10009:雲縣,10010:嘉縣,10011:南縣,10012:高縣,10013:屏縣,10014:東縣,10015:花縣,10016:澎縣,10017:基市,10018:竹市,10020:嘉市,09007:連江,09020:金門,63000:北市,64000:高市,65000:新北市,66000:中市,67000:南市,68000:桃市  | 
|
| issue_type | string | 消費者領補換(身分證件)類型 0:領補發,1:初發,2:補發,3:換發  | 
|
| user_phone_code | string | 消費者家用電話(白天電話):國碼(預設886) | |
| user_phone_area_code | string | 消費者家用電話(白天電話):區碼 | |
| user_phone | string | 消費者家用電話(白天電話) | |
| user_phone_ext | string | 消費者家用電話(白天電話):分機 | |
| user_cellphone_code | string | 消費者行動電話國碼(預設886) | |
| user_cellphone | string | 消費者行動電話 | |
| user_email | string | 消費者 E-Mail | |
| user_birthday | string | 消費者生日(格式為 YYYYMMDD,如 20090916) | |
| residence_address_post_zone | string | 消費者戶籍地址:郵遞區號 | |
| residence_address | string | 消費者戶籍地址:路街巷弄號樓室 | |
| residence_phone_area_code | string | 消費者戶籍電話:區碼 | |
| residence_phone | string | 消費者戶籍電話:號碼 | |
| residence_phone_ext | string | 消費者戶籍電話:分機 | |
| bank_code | string | 消費者銀行帳戶:銀行代碼 | |
| bank_branch_code | string | 消費者銀行帳戶: 分行代碼 | |
| bank_account_name | string | 消費者銀行帳戶:銀行帳戶名稱 | |
| bank_account_number | string | 消費者銀行帳戶:銀行帳號 | |
| salary_bank_code | string | 薪轉存摺銀行代碼 | |
| salary_bank_branch_code | string | 薪轉存摺分行代碼 | |
| salary_bank_account_number | string | 薪轉帳號 | |
| house_owner | string | 消費者居住房屋:擁有者 1:自有,2:配偶,3:親人,4租賃  | 
|
| living_years | string | 消費者居住房屋-年數 | |
| living_months | string | 消費者居住房屋-月數 | |
| mailing_address_post_zone | string | 消費者通訊地址:郵遞區號 | |
| mailing_address | string | 消費者通訊地址:路街巷弄號樓室 | |
| marital_status | string | 消費者婚姻狀況 1:單身,2:已婚,3:離婚  | 
|
| children | string | 消費者擁有子女數 | |
| education_level | string | 消費者教育程度 1:博士,2:研究所,3:大學/大專,4:高中職,5:國中/國小  | 
|
| organization_type | string | 工作組織類型 1:公司,2.營登,3:財法,4:社法,5:公職  | 
|
| organization_id | string | 消費者公司統一編號(營登/財法/社法) | |
| organization_name | string | 消費者公司名稱(服務單位) | |
| organization_phone_area_code | string | 消費者公司電話(服務單位電話):區碼 | |
| organization_phone | string | 消費者公司電話(服務單位電話):電話號碼 | |
| organization_phone_ext | string | 消費者公司電話(服務單位電話):分機號碼 | |
| organization_address_post_zone | string | 消費者公司(服務單位)地址:郵遞區號 | |
| organization_address | string | 消費者公司(服務單位)地址 | |
| employment_status | string | 消費者就業狀態 | |
| career | string | 消費者職務類型 | |
| subcareer | string | 消費者次要職務類型 | |
| grade | string | 消費者職等 | |
| working_years | string | 消費者工作年資:年數 | |
| working_months | string | 消費者工作年資:月數 | |
| monthly_salary | string | 消費者月薪 | |
| legal_representative_name | string | 消費者法定代理人:姓名 | |
| legal_representative_personal_id | string | 消費者法定代理人:身分證字號 | |
| legal_representative_birthday | string | 消費者法定代理人:出生日期 | |
| legal_representative_contact_address_post_zone | string | 消費者法定代理人:聯絡地址:郵遞區號 | |
| legal_representative_contact_address | string | 消費者法定代理人:聯絡地址:路街巷弄號樓 | |
| legal_representative_home_phone_area_code | string | 消費者法定代理人:住家電話:區碼 | |
| legal_representative_home_phone | string | 消費者法定代理人:住家電話:電話號碼 | |
| legal_representative_cellphone | string | 消費者法定代理人:行動電話 | |
| contact_time | string | 指定照會時間 | |
| payment_method | string | 消費者繳款方式 (帶冒號後的值) 電子帳單: 1 超商簡訊繳款: 3  | 
|
| creditcard_status | string | 消費者信用卡:狀態 (帶冒號後的值) 沒辦過卡: 1 無卡自停: 2 協商繳款中: 3 其他: 4  | 
|
| creditcard_status_remark | string | 消費者信用卡:狀態說明 | |
| customer_creditcard_bank_code | string | 消費者信用卡:發卡銀行代碼 | |
| creditcard_validdate_month | string | 消費者信用卡:有效日期:月 | |
| creditcard_validdate_year | string | 消費者信用卡:有效日期:年 | |
| contact_person_name | string | 聯絡人:中文姓名 | |
| contact_person_relationship | string | 聯絡人:關係 1配偶 2父母 3兄弟姐妹 4其他親友 5同事 6朋友 7子女 8其他  | 
|
| contact_person_cellphone | string | 聯絡人:行動電話 | |
| contact_person_phone_area_code | string | 聯絡人:住宅電話:區碼 | |
| contact_person_phone | string | 聯絡人:住宅電話:號碼 | |
| contact_person_phone_ext | string | 聯絡人:住宅電話:分機 | |
| contact_person_organization_phone_area_code | string | 聯絡人:公司電話:區碼 | |
| contact_person_organization_phone | string | 聯絡人:公司電話:號碼 | |
| contact_person_organization_phone_ext | string | 聯絡人:公司電話:分機 | |
| contact_person_confidentiality | string | 聯絡人:是否保密照會?(是:1,否:0) | |
| contact_person_meeting_time | string | 聯絡人:照會時間(日期時間 YYYYMMDDHHMM) | |
| contact_person2_name | string | 聯絡人2:中文姓名 | |
| contact_person2_relationship | string | 聯絡人2:關係 1配偶 2父母 3兄弟姐妹 4其他親友 5同事 6朋友 7子女 8其他  | 
|
| contact_person2_cellphone | string | 聯絡人2:行動電話 | |
| contact_person2_phone_area_code | string | 聯絡人2:住宅電話:區碼 | |
| contact_person2_phone | string | 聯絡人2:住宅電話:號碼 | |
| contact_person2_phone_ext | string | 聯絡人2:住宅電話:分機 | |
| contact_person2_organization_phone_area_code | string | 聯絡人2:公司電話:區碼 | |
| contact_person2_organization_phone | string | 聯絡人2:公司電話:號碼 | |
| contact_person2_organization_phone_ext | string | 聯絡人2:公司電話:分機 | |
| contact_person2_confidentiality | string | 聯絡人2:是否保密照會?(是:1,否:0) | |
| contact_person2_meeting_time | string | 聯絡人2:照會時間(日期時間 YYYYMMDDHHMM) | |
| guarantor_option | string | 連帶保人:選項 1.連帶保證人(需附保證人身分證正反面影本) 2.配偶資料僅供參考 3.法定代理人(需於法代欄位簽名) 4.商品實際使用人  | 
|
| guarantor_name | string | 連帶保人:姓名 | |
| guarantor_license_id | string | 連帶保人:身分證字號 | |
| guarantor_issue_date | string | 保證人發證(身分證)日期(YYYYMMDD) | |
| guarantor_issue_place | string | 保證人領補換(身分證)地點 10001:北縣,10002:宜縣,10003:桃縣,10004:竹縣,10005:苗縣,10006:中縣,10007:彰縣,10008:投縣,10009:雲縣,10010:嘉縣,10011:南縣,10012:高縣,10013:屏縣,10014:東縣,10015:花縣,10016:澎縣,10017:基市,10018:竹市,10020:嘉市,09007:連江,09020:金門,63000:北市,64000:高市,65000:新北市,66000:中市,67000:南市,68000:桃市  | 
|
| guarantor_issue_type | string | 保證人領補換(身分證件)類型 0:領補發,1:初發,2:補發,3:換發  | 
|
| guarantor_birthday | string | 連帶保人:出生日期(yyyy-mm-dd) | |
| guarantor_cellphone | string | 連帶保人:行動電話 | |
| guarantor_home_phone_area_code | string | 連帶保人:住家電話:區碼 | |
| guarantor_home_phone | string | 連帶保人:住家電話:號碼 | |
| guarantor_home_phone_ext | string | 連帶保人:分機 | |
| guarantor_relationship | string | 連帶保人:關係 1配偶 2父母 3兄弟姐妹 4其他親友 5同事 6朋友 7子女 8其他  | 
|
| guarantor_address_post_zone | string | 連帶保人:地址:郵遞區號 | |
| guarantor_address | string | 連帶保人:地址 | |
| guarantor_organization_id | string | 連帶保證人公司統編 | |
| guarantor_organization_name | string | 連帶保人:公司名稱 | |
| guarantor_organization_phone_area_code | string | 連帶保人:公司電話:區碼 | |
| guarantor_organization_phone | string | 連帶保人:公司電話:號碼 | |
| guarantor_organization_phone_ext | string | 連帶保人:公司電話:分機 | |
| guarantor_employment_status | string | 連帶保人:就業狀態 | |
| guarantor_career | string | 連帶保人:職務類型 | |
| guarantor_subcareer | string | 連帶保人:次要職務類型 | |
| guarantor_grade | string | 連帶保人:職等 | |
| guarantor_monthly_salary | string | 連帶保證人月薪 | |
| guarantor_working_years | string | 連帶保證人工作年資-年數 | |
| guarantor_working_months | string | 連帶保證人工作年資-月數 | |
| guarantor_meeting_time | string | 連帶保證人聯絡時間 (日期格式YYYYMMDDHHmm) | |
| guarantor_salary_bank_code | string | 連帶保證人薪轉存摺銀行代碼 | |
| guarantor_salary_bank_branch_code | string | 連帶保證人薪轉存摺分行代碼 | |
| guarantor_salary_bank_account_number | string | 連帶保證人薪轉帳號 | |
| motorcycle_license_number | string | 機車行照牌照號碼 | |
| motorcycle_factory_date | string | 機車出廠日期 | |
| motorcycle_displacement | string | 機車排氣量 | |
| motorcycle_license_date | string | 行照發證日期 | |
| dealer_note | string | 經辦商備註欄 | |
| supplier_business_type | string | 業務別代碼 AA21=原車抵押 AA22=借新還舊 AA23=它行代償 CA20=商品圓融  | 
|
| supplier_business_type_projects | string | 專案代碼 AA21 可用代碼為:DN45、DN46、DN47。 AA22 可用代碼為:DM44、DM45。 AA23 可用代碼為:DM66、DM67。 CA20 可用代碼為:DM41、DM42、DN48  | 
『無卡分期檔案』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| id | string | 檔案索引名稱 | |
| path | string | 檔案路徑 | |
| type | string | MIME 檔案類型 | |
| description | string | 說明 | 
『儲值交易項目』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| id | string | 儲值產品編號(最長限32 Bytes) | |
| name | string | 儲值商品名稱 | |
| price | string | 儲值點數 | |
| amount | string | 儲值數量 | |
| total | string | 儲值點數小計 | 
『交易查詢』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| cardno | string | 銀行端口回傳碼 | |
| acode | string | 授權碼 | |
| card_type | string | 信用卡卡別 | 『信用卡別類型』值參考 | 
| issuing_bank | string | 發卡行 | |
| issuing_bank_uid | string | 發卡銀行代碼 | |
| transaction_mode | integer | 交易服務類型 | 『交易服務類型』值參考 | 
| supplier_name | string | 交易之金融服務商 | |
| supplier_code | string | 交易之金融服務商代碼 | 『金流供應商代碼』值參考 | 
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| voucher_paid | array | 有償票券項目 | 每筆『有償票券項目』欄位參考 | 
| voucher_free | array | 無償票券項目 | 每筆『無償票券項目』欄位參考 | 
| price | string | 請求交易點數/金額 | |
| actual_price | string | 實際交易點數/金額 | |
| recharge_code | string | 交易產品代碼 | |
| love_cost | string | 愛心捐款金額 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| trans_type | string | 付款種類 | 『交易類型定義』值參考 | 
| redeem | string | 信用卡紅利資訊 JSON 格式 | 『紅利資訊』值參考 | 
| installment | string | 信用卡分期資訊 JSON 格式 | 『分期資訊』值參考 | 
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| bank_id | string | 虛擬帳號銀行代碼 | |
| expired_date | string | 有效日期(YYYYMMDDHHmmss) 虛擬帳號、超商代碼、無卡分期資訊  | 
|
| appropriation_date | string | 預計撥款日期(YYYYMMDD) | |
| result_type | integer | 虛擬帳號、超商代碼 資料格式類型 | 『閘道內容回傳格式類型』值參考 | 
| result_content_type | string | 資料內容所屬支付名稱 | 『資料內容所屬支付名稱』值參考 | 
| result_content | string | 虛擬帳號、超商代碼 資料內容 | 『虛擬帳號回傳欄位』值參考 『ibon』值參考 『FamiPort』值參考 『Life-ET』值參考 『超商條碼繳費』值參考  | 
| refund_order | array | 退款訂單資訊(多筆格式) | 每筆『交易查詢-退款資訊』欄位參考 | 
| cancel_order | array | 取消訂單資訊(多筆格式) | 每筆『交易查詢-取消資訊』欄位參考 | 
| invoice_state | integer | 發票開立狀態 | 『電子發票開立狀態類型』值參考 | 
| invoice_date | string | 發票開立日期(YYYYMMDD) | |
| invoice_wordtrack | string | 發票字軌 | |
| invoice_number | string | 發票號碼 | |
| invoice_rand_code | string | 電子發票隨機碼 | |
| invoice_seller_ban | string | 賣方統一編號 | |
| invoice_buyer_ban | string | 買方統一編號 | |
| invoice_left_qrcode | string | 電子發票左邊QrCode內容 | |
| invoice_middle_barcode | string | 電子發票中間Barcode內容(格式Code-39) | |
| invoice_right_qrcode | string | 電子發票右邊QrCode內容 | |
| invoice_title_type | integer | 電子發票列印標題格式 | 『電子發票紙本列印標題類型』值參考 | 
| invoice_title | string | 電子發票列印標題格式 | |
| invoice_print_type | integer | 電子發票列印類型 | 『電子發票列印類型』值參考 | 
| invoice_print_device | integer | 電子發票列印設備 | 『電子發票列印設備』值參考 | 
| invoice_amount | string | 電子發票銷售總額 | |
| invoice_sales_amount | string | 電子發票銷售額 | |
| invoice_tax_amount | string | 電子發票稅額 | |
| invoice_order_detail | string | 電子發票全部產品明細(JSON格式) | 『商品細項』值參考 | 
| invoice_ratetype | integer | 電子發票稅率別 | 『電子發票稅率別』值參考 | 
| invoice_input_type | integer | 電子發票開立類型 | 『電子發票開立類型』值參考 | 
| invoice_cloud_type | string | 電子發票開立類型-雲端發票類型 | 『雲端發票類型』值參考 | 
| invoice_mobile_code | string | 當invoice_cloud_type為2時紀錄的手機條碼 | |
| invoice_tax_id | string | 當invoice_cloud_type為2時紀錄的統一編號 | |
| invoice_natural_person | string | 當invoice_cloud_type為3時紀錄的自然人憑證條碼 | |
| invoice_love_code | string | 當invoice_input_type為2時紀錄的愛心碼 | |
| invoice_b2b_title | string | 當invoice_input_type為3時紀錄的發票抬頭 | |
| invoice_b2b_id | string | 當invoice_input_type為3時紀錄的統一編號 | |
| invoice_b2b_post_zone | string | 當invoice_input_type為3時紀錄的郵遞區號 | |
| invoice_b2b_address | string | 當invoice_input_type為3時紀錄的發票地址 | |
| invoice_allowance | array | 電子發票折讓資訊 | 每筆『電子發票折讓資訊』欄位參考 | 
| items | array | 訂單商品項目 | 每筆『商品項目』欄位參考 | 
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
『商品項目』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| id | string | 商品編號 | |
| name | string | 商品名稱 | |
| cost | string | 商品單價 | |
| amount | string | 商品數量 | |
| total | string | 商品小計 | |
| acquisition_cost | string | 商品成本 | |
| vendor_uid | string | 供應商 | 
『交易查詢-退款資訊』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| prc | string | 主要交易回傳碼(retcode) | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| retmsg | string | 回傳訊息 | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | |
| appropriation_date | string | 預計撥款日期(YYYYMMDD) | |
| invoice_state | integer | 發票開立狀態 | 『電子發票開立狀態類型』值參考 | 
| invoice_date | string | 發票開立日期(YYYYMMDD) | |
| invoice_wordtrack | string | 發票字軌 | |
| invoice_number | string | 發票號碼 | |
| invoice_rand_code | string | 電子發票隨機碼 | |
| invoice_seller_ban | string | 賣方統一編號 | |
| invoice_buyer_ban | string | 買方統一編號 | |
| invoice_left_qrcode | string | 電子發票左邊QrCode內容 | |
| invoice_middle_barcode | string | 電子發票中間Barcode內容(格式Code-39) | |
| invoice_right_qrcode | string | 電子發票右邊QrCode內容 | |
| invoice_title_type | integer | 電子發票列印標題格式 | 『電子發票紙本列印標題類型』值參考 | 
| invoice_title | string | 電子發票列印標題內容 | |
| invoice_amount | string | 電子發票銷售總額 | |
| invoice_sales_amount | string | 電子發票銷售額 | |
| invoice_tax_amount | string | 電子發票稅額 | |
| invoice_order_detail | string | 電子發票全部產品明細(JSON格式) | 『商品細項』值參考 | 
| invoice_ratetype | integer | 電子發票稅率別 | 『電子發票稅率別』值參考 | 
| invoice_input_type | integer | 電子發票開立類型 | 『電子發票開立類型』值參考 | 
| invoice_allowance | array | 電子發票折讓資訊 | 每筆『電子發票折讓資訊』欄位參考 | 
『交易查詢-取消資訊』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | Payment Hub之交易流水號 | |
| prc | string | 主要交易回傳碼(retcode) | |
| cost | string | 總交易金額 | |
| currency | string | 原交易幣別 | |
| actual_cost | string | 實際交易金額 | |
| actual_currency | string | 實際交易幣別 | |
| retmsg | string | 回傳訊息 | |
| finishtime | string | 交易完成時間(YYYYMMDDHHmmss) | 
『退款完成回傳資訊』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | 原MYPAYLINK 之交易流水號 | |
| refund_uid | string | 退款之交易流水號(若多次退款,每次皆會不同) | |
| key | string | 交易驗証碼 | |
| prc | string | 主要交易回傳碼(retcode) | |
| finishtime | string | 退款處理完成時間(YYYYMMDDHHmmss) | |
| order_id | string | 貴特店系統的訂單編號 | |
| user_id | string | 消費者帳號 | |
| cost | string | 申請之退款金額 | |
| currency | string | 申請之退款幣別 | |
| actual_cost | string | 實際退款金額 | |
| actual_currency | string | 實際退款幣別 | |
| retmsg | string | 回傳訊息 | |
| pfn | string | 付費方法 | |
| payment_name | string | 定期定額式/定期分期式扣款名稱 | |
| nois | string | 定期定額式/定期分期式扣繳期數 | |
| group_id | string | 1.定期定額式扣款編號 2.定期分期式扣款編號  | 
|
| refund_type | string | 退款類型(1.直接線上退款 2.手動退款(信用卡類) 3.手動退款(現金類) | |
| expected_refund_date | string | 現金退款預計退款日(YYYYMMDD) | |
| echo_0 | string | 自訂回傳參數 1 | |
| echo_1 | string | 自訂回傳參數 2 | |
| echo_2 | string | 自訂回傳參數 3 | |
| echo_3 | string | 自訂回傳參數 4 | |
| echo_4 | string | 自訂回傳參數 5 | 
『商品細項』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| Description | string | 商品名稱 | |
| Quantity | string | 數量 | |
| UnitPrice | string | 單價 | |
| Amount | string | 總金額 | 
『電子發票折讓資訊』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| uid | string | 發生之退款交易流水號(UID) | |
| amount | integer | 電子發票折讓金額 | |
| order_detail | string | 電子發票折讓明細(JSON格式) | 『商品細項』值參考 | 
『虛擬帳號回傳欄位』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| PinCode | string | 虛擬帳號 | |
| LimitDate | string | 繳費有效期限,格式YYYYMMDDHHmmss | |
| BankCode | string | 銀行代碼 | 
『ibon』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| PinCode | string | 超商代碼(可用qrcode被掃) | |
| LimitDate | string | 超商代碼繳費有效期限,格式YYYYMMDDHHmmss | |
| BarCode1 | string | 三段條碼繳費條碼1(格式:Code-39 barcode) | |
| BarCode2 | string | 三段條碼繳費條碼2(格式:Code-39 barcode) | |
| BarCode3 | string | 三段條碼繳費條碼3(格式:Code-39 barcode) | |
| BarcodeEndDate | string | 三段條碼繳費期限,格式YYYYMMDDHHmmss | 
『FamiPort』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| PinCode | string | 繳費代碼(可憑此代碼至設備列印繳費單) | |
| LimitDate | string | 繳費有效期限,格式YYYYMMDDHHmmss | |
| BarCode1 | string | 三段條碼繳費條碼1(格式:Code-39 barcode) | |
| BarCode2 | string | 三段條碼繳費條碼2(格式:Code-39 barcode) | |
| BarCode3 | string | 三段條碼繳費條碼3(格式:Code-39 barcode) | |
| BarcodeEndDate | string | 三段條碼繳費期限,格式YYYYMMDDHHmmss | 
『Life-ET』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| PinCode | string | 繳費代碼(可憑此代碼至設備列印繳費單) | |
| BarCode1 | string | 繳費條碼1(格式:Code-39 barcode) | |
| BarCode2 | string | 繳費條碼2(格式:Code-39 barcode) | |
| BarCode3 | string | 繳費條碼3(格式:Code-39 barcode) | |
| LimitDate | string | 繳費有效期限,格式YYYYMMDDHHmmss | 
『超商條碼繳費』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| BarCode1 | string | 繳費條碼1(格式:Code-39 barcode) | |
| BarCode2 | string | 繳費條碼2(格式:Code-39 barcode) | |
| BarCode3 | string | 繳費條碼3(格式:Code-39 barcode) | |
| LimitDate | string | 繳費有效期限,格式YYYYMMDDHHmmss | 
值的定義
『交易服務類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 尚未進行閘道交易 | |
| 1 | integer | 代收代付 | |
| 2 | integer | 特店模式 | 
『證號類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 身份證字號(預設) | |
| 2 | integer | 統一證號 | |
| 3 | integer | 護照號碼 | 
『幣別類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| TWD | integer | 新台幣(預設) | |
| CNY | integer | 人民幣 | 
『自動換匯』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 關閉(預設) | |
| 1 | integer | 開啟 | 
『分期類型定義』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| W | string | 每週定期扣款 | |
| F | string | 雙週定期扣款 | |
| M | string | 每月定期扣款 | |
| S | string | 每季定期扣款 | |
| H | string | 每半年定期扣款 | |
| A | string | 每一年定期扣款 | |
| O | string | 一次性扣款 | 
『付款方式』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| all | string | 全部可用支付方式(預設) | |
| MobilePayAll | string | 指定下列線上行動支付方式 支付寶、Pi 拍錢包、LINEPay、微信、街口支付、悠遊付  | 
|
| CREDITCARD | string | 信用卡 | |
| CSTORECODE | string | 超商代碼 | |
| WEBATM | string | WEBATM | |
| E_COLLECTION | string | 虛擬帳號 | |
| UNIONPAY | string | 銀聯卡 | |
| SVC | string | 點數卡(GASH ,Imoney) | |
| ABROAD | string | 海外信用卡 | |
| ALIPAY | string | 支付寶 | |
| string | 微信支付 | ||
| DIRECTDEBIT | string | 定期定額扣款 | |
| LINEPAYON | string | LINE Pay線上付款 | |
| LINEPAYOFF | string | LINE Pay線下付款 | |
| WECHATOFF | string | 微信支付線下 | |
| APPLEPAY | string | APPLE PAY | |
| GOOGLEPAY | string | Google Pay | |
| EACH | string | eACH交易 | |
| C_INSTALLMENT | string | 信用卡分期 | |
| C_REDEEM | string | 信用卡紅利 | |
| CARDLESS | string | 無卡分期 | |
| PION | string | Pi 拍錢包線上 | |
| PIOFF | string | Pi 拍錢包線下 | |
| AMEX | string | 美國運通 | |
| JKOON | string | 街口支付線上 | |
| JKOOFF | string | 街口支付線下 | |
| ALIPAYOFF | string | 支付寶線下 | |
| M_RECHARGE | string | 儲值交易 | |
| EASYWALLETON | string | 悠遊付線上 | |
| EASYWALLETOFF | string | 悠遊付線下 | |
| BARCODE | string | 超商條碼繳費 | 
『啟用快速結帳』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 關閉 | |
| 1 | integer | 開啟(預設) | 
『啟用電子錢包』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 關閉(預設) | |
| 1 | integer | 開啟 | 
『電子錢包執行類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 電子錢包前景交易(預設) | |
| 2 | integer | 電子錢包背景交易 | 
『交易類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | string | 網路交易(預設)(消費者直接輸入支付內容) | |
| 2 | string | 實體交易 (商戶面對消費者時,由商戶輸入支付內容做消費) | 
『電子發票是否開立狀態』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 不開立電子發票 | |
| 1 | integer | 開立電子發票 | |
| 2 | integer | 依系統設定(預設) | 
『電子發票稅率別』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 應稅(預設) | |
| 2 | integer | 零稅率 | |
| 3 | integer | 免稅 | 
『雲端發票類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 2 | integer | 手機條碼 | |
| 3 | integer | 自然人憑證條碼 | |
| 4 | integer | 以E-Mail寄送 | 
『電子發票欄位異動』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 可以異動(預設) | |
| 1 | integer | 不可異動 | 
『含不含簡訊費』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 含手續費 | |
| 0 | integer | 不含手續費(預設) | 
『含不含手續費類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 含手續費 | |
| 0 | integer | 不含手續費(預設) | 
『金流供應商代碼』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| A1 | string | 裕富數位資融 | |
| A2 | string | 三環亞洲 | |
| B0 | string | 新光銀行 | |
| B1 | string | 永豐銀行 | |
| B2 | string | 合作金庫 | |
| B3 | string | 台北富邦 | |
| B4 | string | 玉山銀行 | |
| B5 | string | 台新銀行 | |
| B6 | string | 聯合信用卡處理中心 | |
| B7 | string | 台中商銀 | |
| B8 | string | 中國信託商業銀行 | |
| B9 | string | 上海商業儲蓄銀行 | |
| BA | string | 第一銀行 | |
| BB | string | 元大商業銀行 | |
| BC | string | 凱基銀行 | |
| BD | string | 國泰世華商業銀行 | |
| BE | string | 華泰商業銀行 | |
| BF | string | 兆豐銀行 | |
| BG | string | 環滙亞太 | |
| S0 | string | 全網行銷股份有限公司(FamiPort) | |
| S1 | string | 安源資訊股份有限公司(ibon) | |
| S2 | string | 萊爾富國際股份有限公司(Hi-Life) | |
| T0 | string | 高鉅科技 | |
| T1 | string | 藍新金流 | |
| T2 | string | 統一客樂得(黑貓Pay) | |
| W0 | string | 統振 | |
| W1 | string | 遊戲橘子數位 | |
| W2 | string | 台灣連線(LINEPay) | |
| W3 | string | 博經 | |
| W4 | string | 街口電子支付 | |
| W5 | string | 悠遊卡 | |
| W6 | string | 一卡通票證 | |
| W7 | string | iCash | |
| W8 | string | 全支付(PXPay plus) | |
| W9 | string | 拍付國際資訊(Pi錢包) | |
| E0 | string | MYTIX | 
『有償票券項目』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| product_id | string | 票券群組編號(最長限32 Bytes) | |
| serial_number | string | 票券券號(特約商店下的每一個票券群組的票券券號必須是唯一) | |
| name | string | 票券名稱 | |
| cost | integer | 票券金額 | |
| issuer | string | 發行者 | 『有價票券發行者』值參考 | 
| refund_return_type | string | 退款時,票券金額是否歸還 | 『退款時票券金額是否歸還』值參考 | 
『無償票券項目』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| product_id | string | 票券群組編號(最長限32 Bytes) | |
| serial_number | string | 票券券號(特約商店下的每一個票券群組的票券券號必須是唯一) | |
| name | string | 票券名稱 | |
| cost | integer | 票券金額 | |
| issuer | string | 發行者 | 『免費票券發行者』值參考 | 
『交易類型定義』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 一般 (預設) | |
| 2 | integer | 分期 | |
| 3 | integer | 紅利 | 
『紅利資訊』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| type | string | 紅利類型 | 『紅利資訊類型』值參考 | 
| used | string | 紅利折抵點數 | |
| amount | string | 自付金額 | 
『分期資訊』欄位
| 參數名稱 | 型態 | 說明 | 必須 | 
|---|---|---|---|
| period_number | integer | 分期期數 | |
| total | integer | 應付總金額 | |
| first | integer | 第一期應付金額 | |
| every | integer | 第二期起每期應付金額 | 
『閘道內容回傳格式類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 無法辨識 | |
| 1 | integer | 網址 | |
| 2 | integer | 超連結本文 | |
| 3 | integer | xml | |
| 4 | integer | json | |
| 5 | integer | csv | |
| 6 | integer | 串流 | 
『電子發票開立狀態類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 不處理(預設) | |
| 1 | integer | 等候處理中, | |
| 2 | integer | 發票開立成功 | |
| 3 | integer | 發票處理失敗 | |
| 4 | integer | 作癈 | |
| 5 | integer | 系統或特約商店發票號碼設定不正確 | |
| 6 | integer | 折讓 | 
『電子發票紙本列印標題類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 文字 | |
| 2 | integer | 圖形(圖片網址) | 
『電子發票稅率別』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 應稅(預設) | |
| 2 | integer | 零稅率 | |
| 3 | integer | 免稅 | 
『電子發票開立類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 雲端發票 | |
| 2 | integer | 發票捐贈 | |
| 3 | integer | 實體發票 | 1.重要提示,若選擇此模式,商戶需要自行列印實體發票交付給消費者,系統不會寄送mail通知與中獎後也不會通知給消費者。電子發票列印格式,請參考國稅局頒布標準。 2.使用paypage交易與開立發票同時進行時,絕對不可以使用此模式,因為系統會根據消費者在paypage畫面上的選擇,開立捐贈或雲端載具  | 
『紅利資訊類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 全額 | |
| 2 | integer | 部分 | 
『資料內容所屬支付名稱』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| E_COLLECTION | string | 虛擬帳號 | |
| IBON | string | iBON | |
| FAMIPORT | string | FamiPort | |
| LIFEET | string | LIFE-ET | |
| WEBATM | string | WEBATM | |
| CREDITCARD | string | 信用卡 | |
| UNIONPAY | string | 銀聯卡 | |
| SVC | string | 點數卡(GASH ,Imoney) | |
| ABROAD | string | 海外信用卡 | |
| ALIPAY | string | 支付寶 | |
| string | 微信支付 | ||
| LINEPAYON | string | LINE Pay線上付款 | |
| LINEPAYOFF | string | LINE Pay線下付款 | |
| WECHATOFF | string | 微信支付線下 | |
| APPLEPAY | string | APPLE PAY | |
| GOOGLEPAY | string | Google Pay | |
| EACH | string | eACH交易 | |
| CARDLESS | string | 無卡分期 | |
| PION | string | Pi 拍錢包線上 | |
| PIOFF | string | Pi 拍錢包線下 | |
| AMEX | string | 美國運通 | |
| JKOON | string | 街口支付線上 | |
| JKOOFF | string | 街口支付線下 | |
| ALIPAYOFF | string | 支付寶線下 | |
| M_RECHARGE | string | 儲值交易 | |
| EASYWALLETON | string | 悠遊付線上 | |
| EASYWALLETOFF | string | 悠遊付線下 | |
| BARCODE | string | 超商條碼繳費 | 
『信用卡別類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 無法辨識或支付方式為非信用卡類 | |
| 1 | integer | VISA | |
| 2 | integer | MasterCard | |
| 3 | integer | JCB | |
| 4 | integer | AMEX | 
『電子發票退款時使用作廢或折讓』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 4 | integer | 作廢或作廢重開 | 預設 | 
| 6 | integer | 折讓 | 
『電子發票列印類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 不列印 自行處置 | |
| 1 | integer | 列印 電子發票 + 商品明細 | |
| 2 | integer | 只印電子發票 | |
| 3 | integer | 只印商品明細 | 
『電子發票列印設備』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | integer | 自行處理 | |
| 1 | integer | SUNMI V2 PRO | 
『是否為經銷商代收費模式』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 1 | integer | 是經銷商代收費模式 | |
| 0 | integer | 不是經銷商代收費模式 | 
『信用卡授權請款模式類型』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 0 | string | 自行請款 | |
| 1 | string | 自動請款(預設) | 
『電子錢包執行狀態碼』值內容
| 值 | 型態 | 說明 | 備註 | 
|---|---|---|---|
| 100 | string | 資料不正確 | |
| 400 | string | 系統錯誤 | |
| B200 | string | 執行成功 | |
| B500 | string | 執行失敗 | 
附錄一:PFN(支付工具)參數表
資料傳遞可使用編號,也可以使用代碼 。 例如:pfn=27跟pfn=PION,一樣都是使用Pi 拍錢包線上付款支付工具。
| 編號 | 代碼 | 狀態 | 說明 | 
|---|---|---|---|
| 1 | CREDITCARD | 啟用 | 信用卡 | 
| 3 | CSTORECODE | 啟用 | 超商代碼 | 
| 4 | WEBATM | 啟用 | WEBATM | 
| 6 | E_COLLECTION | 啟用 | 虛擬帳號 (ATM轉帳) | 
| 7 | UNIONPAY | 啟用 | 銀聯卡 | 
| 9 | ABROAD | 啟用 | 海外信用卡(非台灣發行信用卡) | 
| 10 | ALIPAY | 啟用 | 支付寶 | 
| 13 | 啟用 | 微信支付 | |
| 14 | DIRECTDEBIT | 啟用 | 定期扣款(國內信用卡) | 
| 15 | LINEPAYON | 啟用 | LINE線上付款(消費者主掃) | 
| 16 | LINEPAYOFF | 啟用 | LINE線下付款(消費者被掃) | 
| 19 | WECHATOFF | 啟用 | 微信支付線下 | 
| 20 | APPLEPAY | 啟用 | Apple Pay | 
| 21 | GOOGLEPAY | 啟用 | Google Pay | 
| 23 | C_INSTALLMENT | 啟用 | 信用卡分期 | 
| 24 | C_REDEEM | 啟用 | 信用卡紅利 | 
| 25 | CARDLESS | 啟用 | 無卡分期(由資融公司提供分期服務) | 
| 27 | PION | 啟用 | Pi 拍錢包線上付款(消費者主掃) | 
| 28 | PIOFF | 啟用 | Pi 拍錢包線下付款(消費者被掃) | 
| 29 | AMEX | 啟用 | 美國運通 | 
| 31 | JKOON | 啟用 | 街口支付線上付款(消費者主掃) | 
| 32 | JKOOF | 啟用 | 街口支付線下付款(消費者被掃) | 
| 33 | ALIPAYOFF | 啟用 | 支付寶線下(消費者被掃) | 
| 34 | M_RECHARGE | 啟用 | 儲值 | 
| 36 | AFP | 啟用 | 後付款 | 
| 37 | CASH | 啟用 | 現金 | 
| 38 | EASYWALLETON | 啟用 | 悠遊付線上付款(消費者主掃) | 
| 39 | EASYWALLETOFF | 啟用 | 悠遊付線下付款(消費者被掃) | 
| 40 | EASYCARD | 啟用 | 悠遊卡 | 
| 41 | IPASS | 啟用 | 一卡通 | 
| 42 | ICASH | 啟用 | iCash | 
| 43 | BARCODE | 啟用 | 超商條碼繳費 | 
| 46 | PXPAYOFF | 啟用 | 全支付線下付款(消費者被掃) | 
| 56 | PXPAYON | 啟用 | 全支付線上付款(消費者主掃) | 
| 51 | DIRECTDEBIT_ABROAD | 啟用 | 定期扣款(國外信用卡) | 
| 52 | PLUSPAYON | 啟用 | 全盈支付線上付款(消費者主掃) | 
| 53 | PLUSPAYOFF | 啟用 | 全盈支付線下付款(消費者被掃 | 
附錄二:交易狀態代碼
以下回傳的狀態代碼均須處理,避免系統連線錯誤,MYPAY LINK回傳時,貴司系統無法判讀
| 狀態代碼 | 狀態說明 | 詳細說明 | 
|---|---|---|
| 100 | 資料錯誤 | MYPAYLINK收到資料,但是格式或資料錯誤 | 
| 200 | 資料正確 | MYPAYLINK收到正確資料,會接續下一步交易 | 

| 220 | 取消成功 | 如申請取消,取消訂單狀態為取消成功 | 
| 230 | 退款成功 | 如申請退款,申請退款成功時狀態。 | 
| 245 | 授權成功 | 若使用信用卡類自行請款模式,則交易後為授權成功。之後進行請款動作,才會轉為付款成功(250) | 
| 247 | 請款進行中 | 若使用信用卡類自行請款模式,閘道為玉山或NCCC(聯信、凱基、元大)等批次處理,發動請款時會為此狀態,等候金融服務商通知請款成功,才會轉為付款成功(250) | 
| 250 | 付款成功 | 此次交易,消費者付款成功 | 
| 260 | 交易成功 尚未付款完成  | 
超商代碼繳費-請等候消費者繳費入帳完成付款或消費者放棄交易,MYPAY LINK會再傳送一次結果: 250:代表消費者付款成功,此為最終結果 380:代表消費者沒有在時限內去繳費,逾期未去繳費,視同交易失敗,此為最終結果  | 
| 265 | 訂單綁定 | 表示訂單編號生效,進入貸款頁面,但尚未註冊 最後會在回傳狀態 A0002:消費者放棄該筆交易,該筆交易視同交易失敗,為最終結果 275:無卡分期-請等候審查通過  | 
| 270 | 交易成功 尚未付款完成  | 
虛擬帳號-請等候消費者繳費入帳 完成付款或消費者放棄交易,MYPAY LINK會再傳送一次結果: 250:代表消費者付款成功,此為最終結果 380:代表消費者沒有在時限內去繳費,逾期未去繳費,視同交易失敗,此為最終結果  | 
| 280 | 交易成功 尚未付款完成  | 
儲值/WEBATM-線上待付款,等待狀態,等到使用者線上完成交易後MYPAY LINK會再傳送一次結果 250:代表消費者付款成功,此為最終結果 300:代表消費者付款失敗  | 
| 282 | 訂單成立待後付款審核確認 尚未付款完成  | 
後付款,等待狀態,等後付款審核通過通知 284:代表後付款審核通過 300:代表審核不通過  | 
| 284 | 訂單成立後付款待請款 尚未付款完成  | 
後付款,等待狀態,等特約商店出貨後,需發動請款告知後付款已出貨請款 250:代表後付款請款成功,此為最終結果 300:代表後付款請款失敗  | 
| 290 | 交易成功 但資訊不符  | 
交易成功,但資訊不符(包含金額不符,如多繳或少繳...等),該類型交易請特別注意 | 

| 300 | 交易失敗 | 金流服務商回傳交易失敗或該筆交易超過風險控管限制規則 | 
| 380 | 逾期交易 | 超商代碼或虛擬帳號交易,超過系統設定繳費期限 若經MYPAY LINK查詢驗證後,有機會在變更狀態 290:交易成功,但資訊不符 原因有可能是服務商的參數規則漏洞或是系統時間差異造成  | 
| 400 | 系統錯誤訊息 | 若MYPAY LINK或上游服務商系統異常時 | 
| 600 | 結帳完成 | 視為付款完成,此狀態為上游服務商確認訂單後的狀態,表示該筆訂單會撥款 透過MYPAY主動查詢或每日對帳機制 操作訂單功能內發動查詢功能  | 
| A0001 | 交易待確認 | MYPAY LINK與金流服務商發生連線異常,待查詢後確認結果,會主動再次回傳交易結果 250:代表消費者確實付款完成 600:結帳完成 300:金流服務商回傳交易失敗或超過風險控管限制規則交易  | 
| A0002 | 放棄交易 | 畫面導向MYPAY LINK後,消費者即放棄該筆交易,該筆交易視同交易失敗,為最終結果 | 
| B200 | 執行成功 | 處理成功執行 | 
| B500 | 執行失敗 | 處理時,資料異常不予以處理 | 
附錄三:設定調整
- 交易回傳設定,通知網址的部分,僅限80跟443 port
 

- 交易金鑰重新發送與變更
 

附錄四:資料加密方式說明
- 所有的API送出HTTPs請求之欄位中,service 和 encry_data 欄位皆進行 AES256+BASE64 加密處理。
 - AES加密,格式為CBC,長度為256bits,金鑰長度32,IV長度16,傳遞內文為加密後組合IV並經過Base64轉換後傳出。
 - IV資料建議隨機產生。
 
PHP加密示意:
AesEncrypt -> base64_ecode($IV . $JSON)C#加密示意:
AesEncrypt -> (bytes)IV+(bytes)Json -> toBase64Java加密示意:
AesEncrypt -> (bytes)IV+(bytes)Json -> toBase64Node.js加密示意:
AesEncrypt -> concat([IV,JSON], [IV_SIZE,JSON_SIZE]) -> toString('base64')Python加密示意:
AesEncrypt -> (bytes)IV+(bytes)Json -> base64.b64encode
附錄五:API模擬串接服務
提供模擬使用HTTP Protocol,透過POST方式傳遞資料到MYPAY, 並且得到回傳結果。
附錄六:測試區測試用信用卡卡號
下面卡號僅限在測試區測試使用
聯合信用卡中心閘道(其中MasterCard/JCB可測分期與紅利)
| Visa | MasterCard | JCB | |
|---|---|---|---|
| 卡號 | 4938170130000003 | 5430450100001219 | 3560500100001218 | 
| 有效日期 | 1228 | 1218 | 1218 | 
| 安全碼 | 985 | 214 | 023 | 
| 3D交易密碼 | nccc1234 | 
永豐銀行信用卡
| Visa | MasterCard | JCB | |
|---|---|---|---|
| 卡號 | 4058650600065507 | 5433760200078009 | 3566703300032801 | 
| 有效日期 | 1022 | 1022 | 0922 | 
| 安全碼 | 395 | 597 | 033 | 
中國信託信用卡 (使用電子錢包功能適用)
| Visa | |
|---|---|
| 一般交易 | 4003618704777729 | 
| 有效日期 | 任意 | 
| 安全碼 | 任意 | 
| 3D交易密碼 | 1234567 | 
高鉅模擬信用卡(成功卡)
| Visa | MasterCard | JCB | |
|---|---|---|---|
| 一般交易 | 4761120010000492 | 5204247750001471 | 3566703300032801 | 
| 有效日期 | 1122 | 1122 | 0922 | 
| 安全碼 | 533 | 111 | 033 | 
高鉅模擬信用卡(失敗卡)
| MasterCard | |
|---|---|
| 一般交易 | 5204247750001471 | 
| 有效日期 | 1122 | 
| 安全碼 | 111 | 
高鉅模擬信用卡(3D)
| 說明 | 卡號 | 
|---|---|
| 3D交易 | 4003618704777729 | 
| 有效日期 | 任意 | 
| 安全碼 | 任意 | 
凱基 (醫療費/捐款費用) 信用卡
| Visa | |
|---|---|
| 一般交易 | 4907060600015101 | 
| 有效日期 | 1226 | 
| 安全碼 | 905 | 
備註:(醫療費/捐款費用)信用卡所使用之訂單編號「order_id」(繳費單號)長度最長為16bytes。(此為上游限制)
土銀/彰銀 (財金閘道適用)
| Visa | MasterCard | JCB | |
|---|---|---|---|
| 卡號 | 4907100520417100 | 5409740002370101 | 3567150051398107 | 
| 有效日期 | 0626 | 0426 | 1027 | 
| 安全碼 | 682 | 318 | 927 | 
| 3D交易密碼 | 123456 | 123456 | 123456 |