• 开发指导


    支付服务的响应参数说明:
    支付服务的所有接口,返回的参数结构基本是一致的:
    code:接口的响应状态,不能作为业务成功与否的的判断依据
    data:code为success时,存放业务数据,业务逻辑的判断应以此数据作为判断依据
    msg:code为failure时,存放错误信息

    1.1 支付宝支付相关

    报文示例:

    {
      "paymentAmount": "0.01",                              支付金额
      "currencyCode": "CNY",                                币种
      "paymentCustomer": "12345",                           支付客户
      "paymentSubject": "测试订单",                         商品名称/交易标题/订单标题/订单关键字等
      "paymentDescription": "测试商品",                     商品名称/交易标题/订单标题/订单描述等
      "returnUrl":"http://hzerodevf.saas.hand-china.com",   支付完成后返回的页面,若不指定使用支付配置定义的回调地址
      "merchantOrderNum": "21781782",                       商户支付订单号,单号相同不会创建新订单
      "channelTrxType": "PC",                               渠道事务类型  PC(网页支付)WAP(手机网站支付)APP(APP支付)BAR(条码支付)
      "expireTime":"2019-06-20 10:10:10"                    到期时间
    }
    

    响应示例:

    {
        "code": "success",
        "data": "<form id=\"_alipaysubmit_\" name=\"alipaysubmit\" action=\"https://openapi.alipay.com/gateway.do?app_id=2018110561993668&charset=UTF-8&format=json&method=alipay.trade.page.pay&notify_url=http%3A%2F%2Fhzeronb.saas.hand-china.com%2Fhpay%2Fv1%2F0%2Falipay%2FALIPAY%2Fcallback&return_url=http%3A%2F%2Fhzeronf.saas.hand-china.com&sign=k82GOoztI6SczR8y9JtgQa0ipSCoxqyR%2BMQYgfOMd9wuICViOHj2OfOJ1HgJy1Uz%2F2Qmu8F%2FLsjs4oOr7sIoEhQCW%2FpM4ZVeesS2VBsinEM9l8JSuRNvGPwrUyVHTr2UnrfUr7VeqiOgIQ1vNRG%2F06n%2FeBqMWywRR9XmFz9XCCQrZdT0qEe%2FQT6gJGN8%2BmcZgXifX5LjxJofxupVZ9I%2FZzRMvZOaxw5CB2UAO7w5Q2i%2BbPFbIan1wra%2FeudzTl0klp23FcPTWD6Dt0uNv9s0mV4J%2BZ2QIPS5q9LsLiPZESZeHmWWHJ8CyLNJaFZdQzOQkkxcW81P2AqNpMbMDC%2FJBQ%3D%3D&sign_type=RSA2&timestamp=2019-07-24+11%3A34%3A37&version=1.0\" method=\"post\"><input type=\"hidden\" name=\"biz_content\" value='{\"body\":\"测试商品\",\"out_trade_no\":\"21781783\",\"product_code\":\"FAST_INSTANT_TRADE_PAY\",\"subject\":\"测试订单\",\"total_amount\":\"0.01\"}'/></form><script>document.forms['_alipaysubmit_'].submit();</script>"
    }
    

    前端根据data中的标签渲染即可得到支付页面

    获取支付页面方法:

    // index.js
    
    constructor(props) {
      super(props);
      this.payBox = React.createRef();
    }
    
    // 支付功能
    @Bind()
    handlePay(record) {
      const { dispatch } = this.props;
      dispatch({
        type: 'paymentOrder/pay',
        payload: {
          paymentOrderNum: record.paymentOrderNum,
        },
      }).then(res => {
        if (res) {
          notification.success({
            message: intl.get('hzero.common.notification.success'),
            description: '即将前往支付...',
          });
          if (this.payBox.current.children[0]) {
            this.payBox.current.children[0].submit();
          }
        }
      });
    }
    
    render() {
      const {
        paymentOrder: {
          payData = '', //在model里面存储的变量,即响应报文中返回的data
        },
      } = this.props;
      const columns = [
        // ...
        {
          title: '操作',
          key: 'action',
          render: (_, record) => {
            return (
              <Popconfirm
                title={intl.get('hzero.common.message.confirm.pay').d('是否确定支付?')}
                onConfirm={() => {
                  this.handlePay(record);
                }}
              >
                <a>{intl.get('hzero.common.button.pay').d('支付')}</a>
              </Popconfirm>
            )
          }
        }
      ];
      return (
        <React.Fragment>
          <Table columns={columns}>
          {payData && <div ref={this.payBox} dangerouslySetInnerHTML={{ __html: payData }} />}
        </React.Fragment>
      )
    }
    
    // model.js
    import { pay } from '../services/paymentOrderService';
    
    export default {
      namespace: 'paymentOrder',
    
      state: {
        payData: "", // 支付数据
      },
    
      effects: {
        // ...
    
        // 支付
        * pay({payload}, {call, put}) {
          const res = yield call(pay, payload);
          const result = res;
          if (result) {
            yield put({
              type: 'updateState',
              payload: {
                payData: result,
              },
            });
          }
          return result;
        },
      },
    
      reducers: {
        updateState(state, {payload}) {
          return {
            ...state,
            ...payload,
          };
        },
      },
    };
    
    // service.js
    import request from 'utils/request';
    import {HZERO_HPAY} from 'utils/config';
    import {getCurrentOrganizationId} from 'utils/utils';
    
    /**
     * 付款
     * @async
     * @function pay
     * @param {Object} params - 查询参数
     */
    export async function pay(params) {
      return request(`${HZERO_HPAY}/v1/${organizationId}/alipay/pay/${params.paymentOrderNum}`,
        {
          method: 'GET',
          responseType: 'text',
        }
      );
    }
    

    报文示例:

    {
      "paymentAmount": "0.01",
      "currencyCode": "CNY",
      "paymentCustomer": "12345",
      "paymentSubject": "支付测试订单",
      "returnUrl":"http://hzerodevf.saas.hand-china.com",
      "merchantOrderNum": "21781782",
      "paymentDescription": "测试支付"
    }
    

    报文示例:

    {
      "paymentAmount": "0.01",
      "currencyCode": "CNY",
      "paymentCustomer": "12345",
      "paymentSubject": "支付测试订单",
      "returnUrl":"http://hzerodevf.saas.hand-china.com",
      "merchantOrderNum": "21781782",
      "paymentDescription": "测试支付"
    }
    

    报文示例:

    {
      "outTradeNo": "21781782"                      商户支付订单号
    }
    

    报文示例:

    {
      "outTradeNo": "21781782 ",                    商户支付订单号
      "tradeNo": "2019061222001478271043735658"     支付流水号
    }
    

    报文示例:

    {
      "outTradeNo": "21781782",                     商家支付订单号
      "refundAmount": 0.01                          退款金额
    }
    

    报文示例:

    {
      "outTradeNo": "21781782",                     商家支付订单号
      "tradeNo": "2019061222001478271043735658",    支付流水号
      "refundAmount": 0.01,                         退款金额
      "refundNo": "R02019061319094520800"           退款订单号
    }
    

    报文示例:

    {
    "billDate":"2019-06-18 13:56:01",               账单时间:具体请查看对应支付平台
    "billType":"trade"                              账单类型:具体请查看对应支付平台
    }
    

    平台记录的订单数据也可用于对账,但不保证数据的绝对准确!!

    1.2 微信支付与银联支付

    接口调用与支付宝相似

    声明:银联支付没有经过充分测试

    1.3 通用支付

    可以通过channelCode动态指定支付方式, alipay支付宝 wxpay微信 unionpay银联