Class: SuningPay::EntService

Inherits:
Object
  • Object
show all
Defined in:
lib/suning_pay/ent_service.rb

Constant Summary collapse

CURRENCY_CNY =
'CNY'
PAY_CHARGE_MODE_OUT =
'01'
PAY_CHARGE_MODE_IN =
'02'
PAY_CHARGE_MODE_TRAN =
'03'
ACCOUNT_TYPE_PERSON =
'PERSON'
ACCOUNT_TYPE_CORP =
'CORP'

Class Method Summary collapse

Class Method Details

.post_transfer_acquire(batch_no, product_code, charge_mode, goods_type, batch_order_name, batch_list = [], notify_url = '', tunnel_data = '', options = {}) ⇒ Object

1.批量转账下单接口 batch_list格式为交易数组。 [

[转账流水号1, 收款方易付宝登录名, 收款方商户号, 收款方姓名, 转账金额, 收款方类型, 备注信息, 订单名称],
[转账流水号2, 收款方易付宝登录名, 收款方商户号, 收款方姓名, 转账金额, 收款方类型, 备注信息, 订单名称],
..

]

Raises:

  • (ArgumentError)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/suning_pay/ent_service.rb', line 20

def self.post_transfer_acquire(batch_no, product_code, charge_mode, goods_type, batch_order_name, batch_list = [], notify_url = '', tunnel_data = '', options = {})

  raise ArgumentError, "Argument batch_list error" if batch_list.nil? or batch_list.empty?

  raise ArgumentError, "Argument batch_list count limit 1000" if batch_list.size > 1000

  body = {}
  detail_data = []
  #合计交易数据
  total_num = batch_list.size
  total_amount = 0
  batch_list.each {|x| total_amount += x[4]}
  raise ArgumentError, "Argument batch_list total_amount limit 100000000000 yuan" if total_amount > 10000000000000

  batch_list.each do |tran|
    detail_line = {
        "serialNo" => tran[0],
        "receiverLoginName" => tran[1],
        "receiverNo" => tran[2],
        "receiverName" => tran[3],
        "amount" => tran[4],
        "receiverType" => tran[5],
        "remark" => tran[6],
        "orderName" => tran[7]
    }
    detail_data << detail_line
  end

  #body参数
  body = {
      :batchNo => batch_no,
      :merchantNo => SuningPay.merchant_no,
      :productCode => product_code,
      :totalNum => total_num,
      :totalAmount => total_amount,
      :currency => SuningPay::EntService::CURRENCY_CNY,
      :chargeMode => charge_mode,
      :payDate => Time.now.strftime("%Y%m%d"),
      :tunnelData => tunnel_data,
      :detailData => detail_data,
      :goodsType => goods_type,
      :batchOrderName => batch_order_name,
      :notifyUrl => notify_url
  }

  input_hash = {:merchantNo => SuningPay.merchant_no,
                :body => body.to_json.to_s.gsub("\\", '')}
  post_params = SuningPay.ent_options.merge(options).merge(input_hash)

  #调用查询接口
  msg = SuningPay::Util.send_post('transferAcquire.htm', post_params, SuningPay::API_CODE_TRANSFER)
  msg
end

.post_transfer_query(batch_no, pay_merchant_no, options = {}) ⇒ Object

3.转账批次查询接口



140
141
142
143
144
145
146
147
148
149
# File 'lib/suning_pay/ent_service.rb', line 140

def self.post_transfer_query(batch_no, pay_merchant_no, options = {})
  input_hash = {:merchantNo => SuningPay.merchant_no,
                :batchNo => batch_no,
                :payMerchantNo => pay_merchant_no}
  post_params = SuningPay.ent_options.merge(options).merge(input_hash)

  #调用查询接口
  msg = SuningPay::Util.send_post('transferQuery.htm', post_params, SuningPay::API_CODE_TRANSFER)
  msg
end

.post_withdraw(batch_no, product_code, charge_mode, goods_type, batch_order_name, batch_list = [], notify_url = '', tunnel_data = '', options = {}) ⇒ Object

2.批量出款到卡接口 batch_list格式为交易数组。 [

[流水号1, 收款方卡号, 收款方户名, 收款方类型, 收款方币种, 开户行名称, 开户行编号, 开户行省, 开户行市, 联行号, 付款金额, 备注, 订单名称],
[流水号2, 收款方卡号, 收款方户名, 收款方类型, 收款方币种, 开户行名称, 开户行编号, 开户行省, 开户行市, 联行号, 付款金额, 备注, 订单名称],
..

]

Raises:

  • (ArgumentError)


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/suning_pay/ent_service.rb', line 81

def self.post_withdraw(batch_no, product_code, charge_mode, goods_type, batch_order_name, batch_list = [], notify_url = '', tunnel_data = '', options = {})

  raise ArgumentError, "Argument batch_list error" if batch_list.nil? or batch_list.empty?

  raise ArgumentError, "Argument batch_list count limit 1000" if batch_list.size > 1000

  body = {}
  detail_data = []
  #合计交易数据
  total_num = batch_list.size
  total_amount = 0
  batch_list.each {|x| total_amount += x[10]}
  raise ArgumentError, "Argument batch_list total_amount limit 100000000000 yuan" if total_amount > 10000000000000

  batch_list.each do |tran|
    detail_line = {
        "serialNo" => tran[0],
        "receiverCardNo" => tran[1],
        "receiverName" => tran[2],
        "receiverType" => tran[3],
        "receiverCurrency" => tran[4],
        "bankName" => tran[5],
        "bankCode" => tran[6],
        "bankProvince" => tran[7],
        "bankCity" => tran[8],
        "payeeBankLinesNo" => tran[9],
        "amount" => tran[10],
        "remark" => tran[11],
        "orderName" => tran[12]
    }
    detail_data << detail_line
  end
  #body参数
  body =[{
             :batchNo => batch_no,
             :merchantNo => SuningPay.merchant_no,
             :productCode => product_code,
             :totalNum => total_num,
             :totalAmount => total_amount,
             :currency => SuningPay::EntService::CURRENCY_CNY,
             :chargeMode => charge_mode,
             :payDate => Time.now.strftime("%Y%m%d"),
             :tunnelData => tunnel_data,
             :detailData => detail_data,
             :goodsType => goods_type,
             :batchOrderName => batch_order_name,
             :notifyUrl => notify_url
         }]

  input_hash = {:merchantNo => SuningPay.merchant_no,
                :body => body.to_json.to_s.gsub("\\", '')}
  post_params = SuningPay.ent_options.merge(options).merge(input_hash)

  #调用查询接口
  msg = SuningPay::Util.send_post('withdraw.htm', post_params, SuningPay::API_CODE_TRANSFER_CARD)
  msg
end

.post_withdraw_query(batch_no, pay_merchant_no, options = {}) ⇒ Object

4.出款批次查询接口



152
153
154
155
156
157
158
159
160
161
# File 'lib/suning_pay/ent_service.rb', line 152

def self.post_withdraw_query(batch_no, pay_merchant_no, options = {})
  input_hash = {:merchantNo => SuningPay.merchant_no,
                :batchNo => batch_no,
                :payMerchantNo => pay_merchant_no}
  post_params = SuningPay.ent_options.merge(options).merge(input_hash)

  #调用查询接口
  msg = SuningPay::Util.send_post('withdrawQuery.htm', post_params, SuningPay::API_CODE_TRANSFER_CARD)
  msg
end