# 3. API Interface

## 3.1. Purchase interface

Merchant could use purchase interface to initiate a transaction, send transaction information to payment channels through AllPay gateway. 

 No. |Field Name  |Max.Length|Type|Parameter Name|Comment 
 -----|-----|----|----|------|------
 1|Message Version|12|Text|version |"VER000000002" 
 2|Character set coding |6|Text|charSet  |"UTF-8" 
 3|Transaction type  |4|Text|transType |"PURC" 
 4|Order Number   |60|Text|orderNum  |The merchant shall define it by itself, and the order number of the same merchant number shall not be repeated 
 5|Order Amount |12|Text|orderAmount   |100 is displayed as 100 or 100.00 
 6|Order Currency   |3|Text|orderCurrency |Fill in "CNY" in RMB and "USD" in USD 
 7|Frontend URL Address |400|Text|frontURL  |Payment results are notified to this address front 
 8|Backend URL Address |400|Text|backURL   |Payment results are notified to this address asynchronously 
 9|Merchant Reserved  |1024 |Text|merReserve    |Merchant reserved content, can pass any content, such as purchase information, account number, etc., but do not pass special symbols, such as commas. 
 10|Merchant ID   |15 |Text|merID     |Merchant ID, assigned by AllPay 
 11|Acquirer ID    |11  |Text|acqID      |"99020344" 
 12|Payment Channel Code    |10  |Text|paymentSchema|UnionPay:"UP",Wechat:"WX,Alipay:"APMP"
 13|Goods Information    |60  |Text|goodsInfo       |Goods Information
 14|Transaction Time    |14  |Text|transTime       |Transaction time, format :" yyymmddhhmmss" 
 15|Signature Type     |3  |Text|signType        |MD5 
 16|Signature Data      |32  |Text|signature         |MD5 signature 

## 3.2. Purchase Response from AllPay 

 No. |Field Name  |Max.Length|Type|Parameter name|Comment 
 -----|-----|----|----|------|------
 1|Message Version|12|Text|version |"VER000000002" 
 2|Character set coding |6|Text|charSet  |"UTF-8" 
 3|Transaction type  |4|Text|transType |"PURC" 
 4|Order Number   |60|Text|orderNum  |The merchant shall define it by itself, and the order number of the same merchant number shall not be repeated 
 5|Order Amount |12|Text|orderAmount   |100 is displayed as 100 or 100.00 
 6|Order Currency   |3|Text|orderCurrency |Fill in "CNY" in RMB and "USD" in USD 
 7|Settlement Amount  |12 |Text|settAmount   |100 is displayed as 100 or 100.00  
 8|Settlement Currency  |3|Text|settCurrency    |Comply with ISO standards and fill in the number type 
 9|Settlement FX Rate   |7|Text|rate     |Real exchange rate, 7 digits  
 10|Merchant Reserved  |1024 |Text|merReserve    |Merchant reserved content, can pass any content, such as purchase information, account number, etc., but do not pass special symbols, such as commas. 
 11|Gateway Transaction ID  |32|Text|transID    |The unique transaction id generated by the gateway.
 12|Merchant ID   |15 |Text|merID     |Merchant ID, assigned by AllPay 
 13|Acquirer ID    |11  |Text|acqID      |"99020344" 
 14|Payment Channel Code    |10  |Text|paymentSchema|UnionPay:"UP",Wechat:"WX,Alipay:"APMP"
 15|Response Code   |2  |Text|RespCode       |00 stands for success; 01 stands for fail.  
 16|Response Message    |20  |Text|RespMsg        |Response message, all English characters 
 17|Transaction Time    |14  |Text|transTime       |Transaction time, format :" yyymmddhhmmss" 
 18|Gateway process time |14  |Text|GWTime |YYYYMMDDHHMMSS this should be a GWtime, currently is local transaction time
 19|Signature Type     |3  |Text|signType        |MD5 
 20|Signature Data      |32  |Text|signature         |MD5 signature 
 
 
## 3.3. Inqiury interface 


 
1. Interface specification
 
 This interface provides the function of inqiury transaction for access merchants.

2. Request message format 

  
 No. |Field Name  |Max.Length|Type|Parameter name|Comment 
 -----|-----|----|----|------|------
 1|Message Version|12|Text|version |"VER000000002" 
 2|Character set coding |6|Text|charSet  |"UTF-8" 
 3|Transaction type  |4|Text|transType |"INQY"  
 4|Order Number   |60|Text|orderNum  |The merchant shall define it by itself, and the order number of the same merchant number shall not be repeated 
 5|Merchant Reserved  |1024 |Text|merReserve    |Merchant reserved content 
 6|Merchant ID   |15 |Text|merID     |Merchant ID, assigned by AllPay 
 7|Acquirer ID    |11  |Text|acqID      |"99020344" 
 8|Payment Channel Code    |10  |Text|paymentSchema|UnionPay:"UP",Wechat:"WX,Alipay:"APMP"
 9|Transaction Time    |14  |Text|transTime       |Transaction time, format :" yyymmddhhmmss" 
 10|Signature Type     |3  |Text|signType        |MD5 
 11|Signature Data      |32  |Text|signature         |MD5 signature 


3. Response message format

  
  No. |Field Name  |Max.Length|Type|Parameter name|Comment 
 -----|-----|----|----|------|------
 1|Message Version|12|Text|version |"VER000000002" 
 2|Character set coding |6|Text|charSet  |"UTF-8" 
 3|Transaction type  |4|Text|transType |"INQY" 
 4|Order Number   |60|Text|orderNum  |The merchant shall define it by itself, and the order number of the same merchant number shall not be repeated 
 5|Gateway Transaction ID  |32|Text|transID    |The unique transaction id generated by the gateway.  
 6|Merchant ID   |15 |Text|merID     |Merchant ID, assigned by AllPay 
 7|Acquirer ID    |11  |Text|acqID      |"99020344" 
 8|Response Code   |2  |Text|RespCode       |00 stands for success; 01 stands for fail.  
 9|Response Message    |20  |Text|RespMsg        |Response message, all English characters 
 10|Transaction Time    |14  |Text|transTime       |Transaction time, format :" yyymmddhhmmss" 
 11|Gateway process time |14  |Text|GWTime |YYYYMMDDHHMMSS this should be a GWtime, currently is local transaction time 
 12|Signature Type     |3  |Text|signType        |MD5 
 13|Signature Data      |32  |Text|signature         |MD5 signature 

## 3.4. Refund interface

1.Interface specification 

This interface provides the function of refund transaction for access merchants. 

2.Request message format 

  No. |Field Name  |Max.Length|Type|Parameter name|Comment 
 -----|-----|----|----|------|------
 1|Message Version|12|Text|version |"VER000000002" 
 2|Character set coding |6|Text|charSet  |"UTF-8" 
 3|Transaction type  |4|Text|transType |"REFD" 
 4|Order Number   |60|Text|orderNum  |The merchant shall define it by itself, and the order number of the same merchant number shall not be repeated 
 5|Return Amount  |12|Text|returnAmount    |100 is displayed as 100 or 100.00 
 6|Order Currency   |3|Text|orderCurrency |Fill in "CNY" in RMB and "USD" in USD 
 7|Merchant Reserved  |1024 |Text|merReserve    |Merchant reserved content, can pass any content, such as purchase information, account number, etc., but do not pass special symbols, such as commas. 
 8|Merchant ID   |15 |Text|merID     |Merchant ID, assigned by AllPay 
 9|Acquirer ID    |11  |Text|acqID      |"99020344" 
 10|Payment Channel Code    |10  |Text|paymentSchema|UnionPay:"UP",Wechat:"WX,Alipay:"APMP"
 11|Transaction Time    |14  |Text|transTime       |Transaction time, format :" yyymmddhhmmss" 
 12|Signature Type     |3  |Text|signType        |MD5 
 13|Signature Data      |32  |Text|signature         |MD5 signature 
 
3.Response message format

  
  No. |Field Name  |Max.Length|Type|Parameter name|Comment 
 -----|-----|----|----|------|------
 1|Message Version|12|Text|version |"VER000000002" 
 2|Character set coding |6|Text|charSet  |"UTF-8" 
 3|Transaction type  |4|Text|transType |"REFD" 
 4|Order Number   |60|Text|orderNum  |The merchant shall define it by itself, and the order number of the same merchant number shall not be repeated 
 5|Gateway Transaction ID  |32|Text|transID    |The unique transaction id generated by the gateway.  
 6|Merchant ID   |15 |Text|merID     |Merchant ID, assigned by AllPay 
 7|Acquirer ID    |11  |Text|acqID      |"99020344" 
 8|Response Code   |2  |Text|RespCode       |00 stands for success; 01 stands for fail.  
 9|Response Message    |20  |Text|RespMsg        |Response message, all English characters 
 10|Transaction Time    |14  |Text|transTime       |Transaction time, format :" yyymmddhhmmss" 
 11|Gateway process time |14  |Text|GWTime |YYYYMMDDHHMMSS this should be a GWtime, currently is local transaction time 
 12|Signature Type     |3  |Text|signType        |MD5 
 13|Signature Data      |32  |Text|signature         |MD5 signature