Module: Allinpay::Payment
Overview
通联支付 支付接口
具体文档请查看 113.108.182.3:8282/techsp/helper/interapi/tlt/interapi0.html
Instance Method Summary collapse
-
#batch_pay(trans, options = {}) ⇒ Object
批量代付 交易代码:100002.
-
#pay(tran, options = {}) ⇒ Object
单笔实时付款 交易代码:100014.
Instance Method Details
#batch_pay(trans, options = {}) ⇒ Object
批量代付 交易代码:100002
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/allinpay/payment.rb', line 50 def batch_pay(trans, = {}) params = set_infomation('100002', {LEVEL: 9}) details = [] index = 1 trans_sum = { BUSINESS_CODE: [:business_code] || '09900', MERCHANT_ID: merchant, SUBMIT_TIME: } trans_sum[:TOTAL_SUM] = trans.inject(0) do |sum, item| sn = index.to_s.rjust(4, '0') amount = (item[:amount].to_f * 100).to_i details << { SN: item[:number] || sn, E_USER_CODE: 1, BANK_CODE: item[:bank_code], ACCOUNT_TYPE: item[:account_type], ACCOUNT_NO: item[:account_number], ACCOUNT_NAME: item[:account_name], ACCOUNT_PROP: item[:account_prop], AMOUNT: amount } index += 1 amount + sum end trans_sum[:TOTAL_ITEM] = index - 1 params[:BODY] = { TRANS_SUM: trans_sum, TRANS_DETAILS: details } res = conn.request(params) res_info = res["INFO"] return result_wrap(:fail, res, params) if res_info["RET_CODE"] != "0000" return result_wrap(:success, res, params) end |
#pay(tran, options = {}) ⇒ Object
单笔实时付款 交易代码:100014
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/allinpay/payment.rb', line 20 def pay(tran, = {}) params = set_infomation('100014') tran_body = { BUSINESS_CODE: [:business_code] || '09900', MERCHANT_ID: merchant, SUBMIT_TIME: , E_USER_CODE: 1, BANK_CODE: tran[:bank_code], ACCOUNT_TYPE: tran[:account_type], ACCOUNT_NO: tran[:account_number], ACCOUNT_NAME: tran[:account_name], ACCOUNT_PROP: tran[:account_prop] } params[:TRANS] = tran_body res = conn.request(params) return result_wrap(:fail, res, params) if res_info["RET_CODE"] != "0000" return result_wrap(:success, res, params) end |