• 周五. 12 月 27th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

银联支付接口之退货

admin

11 月 28, 2021

接收公司的银联支付项目,已经是第三个版本了,现在的是引用了UPOPSDK.dll,使用了封装操作的方法,和官网现在的Demo操作方式不太一样,而且找不到太多的文档资料。任务是增加银联退货的接口,查了很多的资料找到了点感觉,经过无数次的尝试,最后还是执行成功了,下面上接口方法。

     /// <summary>
        /// 银联网关支付退款
        /// </summary>
        /// <param name="newUnionId">新的银联订单编号</param>
        /// <param name="queryIdUnion">要退款的银联流水编号</param>
        /// <param name="orderRefundDate">当前退款操作时间</param>
        /// <param name="payAmount">要退款的金额</param>
        /// <param name="_bank"></param>
        /// <returns></returns>
        public static bool UnionOnlineRefund(string newUnionId, string queryIdUnion, DateTime orderRefundDate, decimal payAmount, BankDomains _bank)
        {
            bool flag = false;
            try
            {
                UPOPSrv.LoadConf(new MemoryStream(byteBuffer));
                var param = new Dictionary<string, string>();

                param["transType"] = UPOPSrv.TransType.REFUND;
                param["orderNumber"] = RefundPre() + newUnionId;
                long amtInt = (int)(payAmount * 100);
          //这个参数让我好找。。。 param[
"origQid"] = queryIdUnion; param["orderAmount"] = amtInt.ToString(); param["orderCurrency"] = UPOPSrv.CURRENCY_CNY; param["orderTime"] = orderRefundDate.ToString("yyyyMMddHHmmss"); param["customerIp"] = _bank.ClientIP(); param["frontEndUrl"] = "http://www.baidu.cn/"; param["backEndUrl"] = "http://www.baidu.cn/"; var srv = new BackPaySrv(param); var resp = srv.Request(); if (resp == null) { return flag; } if (resp.ResponseCode == "00") { flag = true; } else { var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); logger.Error("退款失败代码: " + JsonConvert.SerializeObject(resp)); } } catch (Exception ex) { var logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); logger.Error("错误信息: " + ex.ToString()); } return flag; }

Config中的配置参数,灵感来源这里

  <payParams>
    <string>version</string>
    <string>charset</string>
    <string>transType</string>
    <string>origQid</string>
    <string>merId</string>
    <string>merAbbr</string>
    <string>acqCode</string>
    <string>merCode</string>
    <string>commodityUrl</string>
    <string>commodityName</string>
    <string>commodityUnitPrice</string>
    <string>commodityQuantity</string>
    <string>commodityDiscount</string>
    <string>transferFee</string>
    <string>orderNumber</string>
    <string>orderAmount</string>
    <string>orderCurrency</string>
    <string>orderTime</string>
    <string>customerIp</string>
    <string>customerName</string>
    <string>defaultPayType</string>
    <string>defaultBankNumber</string>
    <string>transTimeout</string>
    <string>frontEndUrl</string>
    <string>backEndUrl</string>
    <string>merReserved</string>
  </payParams>

文档实在不好找。。。昨天还提交了个工单,到下班无人理会,银联老大。。。

发表回复