Kaynağa Gözat

澳门中行支付对接

tags/v1.4.8
jiaoboxiang 2 yıl önce
ebeveyn
işleme
baea355fdb
4 değiştirilmiş dosya ile 108 ekleme ve 24 silme
  1. +18
    -18
      lib/boc/api.go
  2. +28
    -0
      lib/boc/api_macao.go
  3. +30
    -0
      md/boc.go
  4. +32
    -6
      test/boc_pay_test.go

+ 18
- 18
lib/boc/api.go Dosyayı Görüntüle

@@ -7,22 +7,22 @@ const SignType = "RSA2"
const CreateBocCashier = "CreateBocCashier" //【中銀收銀台】創建支付交易
const CreateAASAppTrade = "CreateAASAppTrade" //【中銀收银台】聚合APP支付統一下單

const CardBinding = "CardBinding " //【商戶收銀台】银行卡綁定
const CardBindingQueryList = "CardBindingQueryList " //【商戶收銀台】查询绑定银行卡列表
const RemoveBankCard = "removeBankCard " //【商戶收銀台】移除綁定銀行卡
const CardBindingNotify = "CardBindingNotify " //【商戶收銀台】银行卡绑定结果后台通知
const CreateEMVTrade = "CreateEMVTrade " //【商戶收銀台】創建EMV二维码支付交易
const CreateCardTrade = "CreateCardTrade " //【商戶收銀台】創建银行卡交易
const CreateQRTrade = "CreateQRTrade " //【商戶收銀台】創建聚合碼支付交易
const CreateWeChatTrade = "CreateWeChatTrade" //【商户收银台】微信公众号/小程序支付统一下单
const CreateBocPayAppTrade = "CreateBocPayAppTrade" //【商户收银台】手機銀行APP支付統一下單
const CreateWeChatAppTrade = "CreateWeChatAppTrade" //【商户收银台】微信APP支付統一下單
const CreateAlipayAppTrade = "CreateAlipayAppTrade" //【商户收银台】支付寶APP支付統一下單
const CardBinding = "CardBinding" //【商戶收銀台】银行卡綁定
const CardBindingQueryList = "CardBindingQueryList" //【商戶收銀台】查询绑定银行卡列表
const RemoveBankCard = "removeBankCard" //【商戶收銀台】移除綁定銀行卡
const CardBindingNotify = "CardBindingNotify" //【商戶收銀台】银行卡绑定结果后台通知
const CreateEMVTrade = "CreateEMVTrade" //【商戶收銀台】創建EMV二维码支付交易
const CreateCardTrade = "CreateCardTrade" //【商戶收銀台】創建银行卡交易
const CreateQRTrade = "CreateQRTrade" //【商戶收銀台】創建聚合碼支付交易
const CreateWeChatTrade = "CreateWeChatTrade" //【商户收银台】微信公众号/小程序支付统一下单
const CreateBocPayAppTrade = "CreateBocPayAppTrade" //【商户收银台】手機銀行APP支付統一下單
const CreateWeChatAppTrade = "CreateWeChatAppTrade" //【商户收银台】微信APP支付統一下單
const CreateAlipayAppTrade = "CreateAlipayAppTrade" //【商户收银台】支付寶APP支付統一下單

const OrderRefund = "OrderRefund " //【基礎服務】退款
const OrderQuery = "OrderQuery " //【基礎服務】訂單查詢
const OfflineResult = "OfflineResult " //【基礎服務】支付結果後台通知
const PageResult = "PageResult " //【基礎服務】支付結果頁面通知
const Statement = "Statement " //【基礎服務】對賬文件下載
const Settlement = "Settlement " //【基礎服務】結算單下載
const OrderRelationQuery = "OrderRelationQuery " //【基礎服務】訂單关联查詢
const OrderRefund = "OrderRefund" //【基礎服務】退款
const OrderQuery = "OrderQuery" //【基礎服務】訂單查詢
const OfflineResult = "OfflineResult" //【基礎服務】支付結果後台通知
const PageResult = "PageResult" //【基礎服務】支付結果頁面通知
const Statement = "Statement" //【基礎服務】對賬文件下載
const Settlement = "Settlement" //【基礎服務】結算單下載
const OrderRelationQuery = "OrderRelationQuery" //【基礎服務】訂單关联查詢

+ 28
- 0
lib/boc/api_macao.go Dosyayı Görüntüle

@@ -98,3 +98,31 @@ func CreateWeChatTradeReq(prd bool, privateKeyStr, merchantId, terminalNo string
resp, _ := php2go.URLDecode(send)
return resp, nil
}

func CreateQRTradeReq(prd bool, privateKeyStr, merchantId, terminalNo string, createQRTradeReq *md.CreateQRTradeReq) (string, error) {
//基础信息,必填
createQRTradeReq.Version = Version
createQRTradeReq.Service = CreateQRTrade
createQRTradeReq.SignType = SignType
createQRTradeReq.MerchantId = merchantId
createQRTradeReq.TerminalNo = terminalNo
createQRTradeReq.RequestId = createQRTradeReq.MercOrderNo + zhios_pay_utils.AnyToString(time.Now().Unix())
//按照接口类型选填信息
//createBocPayAppTradeReq.Amount = "100"
//createBocPayAppTradeReq.OriginalAmount = "100"
//createBocPayAppTradeReq.MercOrderNo = "2022101401"
//createBocPayAppTradeReq.OrderDate = "20221013"
//createBocPayAppTradeReq.OrderTime = "175600"
//createBocPayAppTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
//createBocPayAppTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
// "mid":"123456",
//})
param := make(map[string]string)
zhios_pay_utils.Unserialize(zhios_pay_utils.Serialize(createQRTradeReq), &param)
send, err := Send(prd, privateKeyStr, param)
if err != nil {
return "", err
}
resp, _ := php2go.URLDecode(send)
return resp, nil
}

+ 30
- 0
md/boc.go Dosyayı Görüntüle

@@ -65,3 +65,33 @@ type CreateWeChatTradeReq struct {
Reserved2 string `json:"reserved2" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"`
Reserved3 string `json:"reserved3" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"`
}

type CreateQRTradeReq struct {
MacaoBOCPublicParameter
Amount string `json:"amount" name:"订单金額" label:"以分爲單位,如1元表示爲100"`
OriginalAmount string `json:"originalAmount" name:"原订单金额" label:"以分爲單位,如1元表示爲100若无优惠请跟订单金额【amount】一致"`
MerchantPreferentialCnName string `json:"merchantPreferentialCnName" name:"商户系统优惠活动中文名称" label:"非必传"`
MerchantPreferentialEnName string `json:"merchantPreferentialEnName" name:"商户系统优惠活动英文名称" label:"非必传"`
Subject string `json:"subject" name:"訂單標題" label:"非必传,用戶支付完成後顯示在手機上的訂單名稱"`
ProductDesc string `json:"productDesc" name:"商品描述" label:"非必传,對一筆交易的具體描述信息,如果是多種商品,請將商品描述字符串累加傳給body。特殊字符不支持"`
PayChannel string `json:"payChannel" name:"支付方式" label:"BOCPAY - 澳门中银手机银行ALIPAY - 支付宝WECHATPAY - 微信支付TAIFUNGPAY - 豐付寶ICBCEPAY - 工銀E支付MPAY - 澳門通LUSOPAY - 國際銀行UEPAY - 極易付CGBPAY - 廣發MPGS - 銀行卡支付網關UNIONPAYQR - 雲閃付ALL -以上渠道聚合码支持多選使用|分割注:當本接口上送的productCode為MOBILEWEB時,payChannel只能單選,且不能上送ALL"`
ProductCode string `json:"productCode" name:"產品渠道编码" label:"PCWEB網站支付MOBILEWEB-移動支付AUTO-根据UA信息自动识别"`
MercOrderNo string `json:"mercOrderNo" name:"商戶系統消費訂單號" label:"商戶系統必須確保該訂單號在商戶系統是唯一的不能包含單引號“’”、尖括號“<”“>”和逗號“,”"`
OrderDate string `json:"orderDate" name:"訂單創建日期" label:"格式:yyyyMMdd"`
OrderTime string `json:"orderTime" name:"訂單創建時間" label:"格式:HHmmss"`
ValidNumber string `json:"validNumber" name:"有效期" label:"單位:秒 默認值1200"`
NotifyUrl string `json:"notifyUrl" name:"支付結果後台通知地址" label:"支付通知地址(后缀),商户在商戶服務管理後台配置好通知地址(域名)后,聚合平台会将域名和后缀拼接组成完整的通知地址,并在订单支付成后向此通知地址发送支付结果通知。"`
Reserved1 string `json:"reserved1" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"`
Reserved2 string `json:"reserved2" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"`
Reserved3 string `json:"reserved3" name:"商戶備用字段" label:"交易成功后原樣返回給商戶"`
Supplier string `json:"supplier" name:"供貨商名字" label:"非必传,顯示供貨商名字"`
ReferUrl string `json:"referUrl" name:"二級商戶網址" label:""`
BusinessType string `json:"businessType" name:"業務類型" label:"業務類型。該欄位僅支持以下5類入參:
1:飯店
2:航空
3:留學
4:貿易
5:其他,包含所有不屬於前四類的其他業務類型。例如,流量充值,機場接機服務等。若業務類型超過一種,則傳入多個且用分隔號(|)分隔。"`
GoodsInfo string `json:"goodsInfo" name:"商品信息" label:"包含商品的SKU名和相应的数量,格式为 SKU_名^数量。若存在超过一件商品,用竖线(|)分隔。备注:仅在businessType字段值为4时,本字段为必填。"`
TotalQuantity string `json:"totalQuantity" name:"備註:僅在businessType欄位值為4時,本欄位為必填"`
}

+ 32
- 6
test/boc_pay_test.go Dosyayı Görüntüle

@@ -50,9 +50,9 @@ func TestCreateBocPayAppTradeReq(t *testing.T) {
//按照接口类型选填信息
createBocPayAppTradeReq.Amount = "100"
createBocPayAppTradeReq.OriginalAmount = "100"
createBocPayAppTradeReq.MercOrderNo = "2022101402"
createBocPayAppTradeReq.OrderDate = "20221013"
createBocPayAppTradeReq.OrderTime = "175600"
createBocPayAppTradeReq.MercOrderNo = "2022101404"
createBocPayAppTradeReq.OrderDate = time.Now().Format("20060102")
createBocPayAppTradeReq.OrderTime = time.Now().Format("150105")
createBocPayAppTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
createBocPayAppTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
"mid": "123456",
@@ -69,9 +69,9 @@ func TestCreateWeChatTradeReq(t *testing.T) {
//按照接口类型选填信息
CreateWeChatTradeReqReq.Amount = "100"
CreateWeChatTradeReqReq.OriginalAmount = "100"
CreateWeChatTradeReqReq.MercOrderNo = "2022101403"
CreateWeChatTradeReqReq.OrderDate = "20221013"
CreateWeChatTradeReqReq.OrderTime = "175600"
CreateWeChatTradeReqReq.MercOrderNo = "2022101404"
CreateWeChatTradeReqReq.OrderDate = time.Now().Format("20060102")
CreateWeChatTradeReqReq.OrderTime = time.Now().Format("150105")
CreateWeChatTradeReqReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
CreateWeChatTradeReqReq.SubAppId = "wx987580a9437354d1"
CreateWeChatTradeReqReq.SubOpenId = "oEk7V5hNLxQXoTpOcvzRdGJQKnjM"
@@ -85,3 +85,29 @@ func TestCreateWeChatTradeReq(t *testing.T) {
}
t.Logf("回调信息:%s", send)
}

func TestCreateQRTradeReq(t *testing.T) {
var createQRTradeReq md.CreateQRTradeReq
//按照接口类型选填信息
createQRTradeReq.Amount = "100"
createQRTradeReq.OriginalAmount = "100"
createQRTradeReq.PayChannel = "WECHATPAY"
createQRTradeReq.ProductCode = "PCWEB"
createQRTradeReq.MercOrderNo = "2022101405"
createQRTradeReq.OrderDate = time.Now().Format("20060102")
createQRTradeReq.OrderTime = time.Now().Format("150105")
createQRTradeReq.NotifyUrl = "/api/v1/mall/pay/ada/sub_callback"
createQRTradeReq.Reserved1 = zhios_pay_utils.SerializeStr(map[string]string{
"mid": "123456",
})
createQRTradeReq.Supplier = "澳門世寶一人有限公司"
createQRTradeReq.ReferUrl = "https://www.baidu.com"
createQRTradeReq.BusinessType = "4"
createQRTradeReq.GoodsInfo = "测试商品^1"
createQRTradeReq.TotalQuantity = "1"
send, err := boc.CreateQRTradeReq(false, boc.PrivateKeyStr, boc.MerchantId, boc.TerminalNo, &createQRTradeReq)
if err != nil {
t.Error(err)
}
t.Logf("回调信息:%s", send)
}

Yükleniyor…
İptal
Kaydet