商家平台可以通過API發起支付訂單,PassToPasy網關會根據配置路由支付通道。支付網關根據不同的支付方式返回對應的支付參數,商家通過這些支付參數向客戶發起收款。


請求路徑 : api/pay/unifiedOrder

請求方式 : POST

請求類型 : application/json or application/x-www-form-urlencoded

請求參數

參數描述範例
mchNo必填.商家編號,在管理後台可查看。M1621873433953
appId必填.在管理後台可查看。60cc09bce4b0f1c0b83761c9
mchOrderNo必填。商家產生的訂單號碼。20160427210604000490
wayCode必填。付款方式,具體參考支付方式ALI_QR
amount必填.付款金額, 單位分。注意請使用Integer類型。100
currency必填。三位數貨幣代碼cny
reqTime必填。請求API時間,13位時間戳。1622016572190
version必填 版本號,當前版本為:1.1。1.1
signType必填。簽名類型,目前僅支援MD5方式。MD5
sign必填。簽名值,詳細請參考請求簽名。C380BEC2BFD727A4B6845133519F3AD6
subject必填。產品標題,固定值:商品商品
body必填。產品描述,固定值: 00
clientIp必填。用戶端 IPV4 位址。注意非大陆IP将会返回失败210.73.10.148
custNo必填.客戶唯一編號(V1.1.0新增)C200492312
registerTime必填.客戶註冊時間(V1.1.0新增)1622016572190
userName發起付款用戶的真實姓名張三
mbrTel發起付款用戶的手機號碼13812341234
idNo發起付款用戶的身份證號碼320681198603213312
notifyUrl支付結果回調通知URL,只有傳入該值才會啟動通知https://www.yourserver.com/notify.htm
returnUrl支付完成後跳轉URLhttps://www.yourserver.com/return.htm
expiredTime訂單過期時間,單位秒,默認過期時間為2小時。3600
channelExtra特定通道發起的附加參數,json格式字串。有關詳細信息,請參閱 支付方式 描述{"auth_code":"13920933111042"}
extParam商家擴充參數,回調時原樣返回134586944573118714

請求範例:

{ "amount": 8, "extParam": "", "mchOrderNo": "mho1624005107281", "subject": "商品", "wayCode": "ALI_BAR", "sign": "84F606FA25A6EC4783BECC08D4FDC681", "reqTime": "1624005107", "body": "0", "version": "1.0", "channelExtra": "{\"authCode\":\"280812820366966512\"}", "appId": "60cc09bce4b0f1c0b83761c9", "clientIp": "192.166.1.132", "notifyUrl": "https://www.paypass.com", "signType": "MD5", "currency": "cny", "userName": "zhangsan", "returnUrl": "", "mchNo": "M1623984572", "custNo": "C200492312", "registerTime": "1622016572190" }

回應參數

參數必填範例描述
code00-處理成功,其他-處理錯誤,具體參見錯誤碼
msgSigning failure具體錯誤原因,如:簽名失敗、參數格式校驗錯誤
signCCD9083A6DAD9A2DA9F668C3D4517A84對資料中的資料進行簽名。如果資料為空,則不會傳回。
data{}返回支付訂單,json格式資料。請參閱下面支付訂單

支付訂單:

參數名稱範例描述
payOrderIdU12021022311124442600必填.返回付款系統訂單編號
mchOrderNo20160427210604000490必填返回商家傳入的訂單編號
orderState2必填付款訂單狀態
0-已產生訂單
1-付款中
2-付款成功
3-付款失敗
4-已取消
5-已退款
6-訂單已關閉
payDataTypepayUrl必填付款參數類型
payUrl-跳轉連結方式
form-表單方式
codeUrl-二維碼位址
codeImgUrl-二維碼圖片位址
none-null支付參數
payDatahttps://pay.pass2pay.io/api/scan/imgs/aa.png根据payDataType返回对应的支付数据
payOrderInfo{}訂單訊息,直接支付成功時會返回此數據
errCodeACQ.PAYMENT_AUTH_CODE_INVALID通道傳回的錯誤碼
errMsgBusiness Failed通道傳回的錯誤描述

回應樣本

{ "code": 0, "data": { "errCode": "ACQ.PAYMENT_AUTH_CODE_INVALID", "errMsg": "Business Failed", "mchOrderNo": "mho1624005752661", "orderState": 3, "payData": "https://pay.pass2pay.io/api/scan/imgs/aa.png", "payOrderId": "P202106181642329900002" }, "msg": "SUCCESS", "sign": "F4DA202C516D1F33A12F1E547C5004FD" }

下面是使用不同語言發起支付訂單的代碼片段,可以作為參考:

(注意代碼中為對異常場景做處理,請結合業務場景自行處理)

Map<String, Object> map = new HashMap<>(); map.put("mchNo", "Merchant Number..."); map.put("appId", "App ID..."); map.put("mchOrderNo", "Unique Order Number..."); map.put("wayCode", "ALI_QR"); map.put("amount", 10000); map.put("currency", "cny"); map.put("userName", "zhang san..."); map.put("reqTime", 1711021401000l); map.put("version", "1.0"); map.put("subject", "商品"); map.put("body", "0"); map.put("notifyUrl", "https://www..."); JSONObject extParams = new JSONObject(); extParams.put("payDataType", "codeImgUrl"); map.put("channelExtra", extParams); map.put("signType", "MD5"); map.put("sign", "5182B5B0..."); HttpResponse response = HttpRequest .post("http://api.pass2pay.com/api/pay/unifiedOrder") .form(map).execute(); JSONObject responseJson = JSON.parseObject(response.body()); if(responseJson.getIntValue("code") != 0){ // failed, Please check the configuration or contact us }else{ //successful, return customer payment order info }
Copy <?php $map = array( "mchNo" => "Merchant Number...", "appId" => "App ID...", "mchOrderNo" => "Unique Order Number...", "wayCode" => "ALI_QR", "amount" => 10000, "currency" => "cny", "userName" => "zhang san...", "reqTime" => 1711021401000, "version" => "1.0", "signType" => "MD5", "sign" => "5182B5B0...", "subject" => "Children's clothing...", "body" => "A red down jacket...", "notifyUrl" => "https://www..." ); $extParams = array( "payDataType" => "codeImgUrl" ); $map["channelExtra"] = $extParams; $response = Requests::post('http://api.pass2pay.com/api/pay/unifiedOrder', array(), $map); $responseJson = json_decode($response->body, true); if ($responseJson["code"] != 0) { // failed, Please check the configuration or contact us } else { // successful, return customer payment order info } ?>
const axios = require('axios'); const requestData = { mchNo: "Merchant Number...", appId: "App ID...", mchOrderNo: "Unique Order Number...", wayCode: "ALI_QR", amount: 10000, currency: "cny", userName: "zhang san...", reqTime: 1711021401000, version: "1.0", signType: "MD5", sign: "5182B5B0...", subject: "Children's clothing...", body: "A red down jacket...", notifyUrl: "https://www...", channelExtra: { payDataType: "codeImgUrl" } }; axios.post('http://api.pass2pay.com/api/pay/unifiedOrder', requestData) .then(response => { const responseJson = response.data; if (responseJson.code !== 0) { // failed, Please check the configuration or contact us } else { // successful, return customer payment order info } }) .catch(error => { // handle error });
import requests requestData = { "mchNo": "Merchant Number...", "appId": "App ID...", "mchOrderNo": "Unique Order Number...", "wayCode": "ALI_QR", "amount": 10000, "currency": "cny", "userName": "zhang san...", "reqTime": 1711021401000, "version": "1.0", "signType": "MD5", "sign": "5182B5B0...", "subject": "Children's clothing...", "body": "A red down jacket...", "notifyUrl": "https://www...", "channelExtra": { "payDataType": "codeImgUrl" } } response = requests.post('http://api.pass2pay.com/api/pay/unifiedOrder', json=requestData) responseJson = response.json() if responseJson["code"] != 0: # failed, Please check the configuration or contact us else: # successful, return customer payment order info
package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) func main() { requestData := map[string]interface{}{ "mchNo": "Merchant Number...", "appId": "App ID...", "mchOrderNo": "Unique Order Number...", "wayCode": "ALI_QR", "amount": 10000, "currency": "cny", "userName": "zhang san...", "reqTime": 1711021401000, "version": "1.0", "signType": "MD5", "sign": "5182B5B0...", "subject": "Children's clothing...", "body": "A red down jacket...", "notifyUrl": "https://www...", "channelExtra": map[string]string{ "payDataType": "codeImgUrl", }, } requestBody, err := json.Marshal(requestData) if err != nil { fmt.Println("Error marshaling request body:", err) return } resp, err := http.Post("http://api.pass2pay.com/api/pay/unifiedOrder", "application/json", bytes.NewBuffer(requestBody)) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() responseBody, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } var responseJson map[string]interface{} err = json.Unmarshal(responseBody, &responseJson) if err != nil { fmt.Println("Error unmarshaling response body:", err) return } if responseJson["code"].(float64) != 0 { // failed, Please check the configuration or contact us fmt.Println("Request failed:", responseJson["message"]) } else { // successful, return customer payment order info fmt.Println("Request succeeded:", responseJson["data"]) } }