cmb_pay 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/cmb_pay.rb +57 -10
- data/lib/cmb_pay/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +2 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19a26d9fd5d53fda1e1ed76c238698f1ed5c89c8
|
4
|
+
data.tar.gz: c20644e92e5f1495888d1977e6a2f172f655ffdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f69018d96dcc1320f6282a13f7146bc3020ab8d4d714fd331fbe3e45205db1552de9330de4745a279524b2ee6385fcd9a85e3d3b827456cae7f332eae9dfef4a
|
7
|
+
data.tar.gz: d0ab70616384d7b3266b7a56736753187ecb567d4fc365e7ff57f78c1ca8cd281b6a27bd19cd7d44df0160d62ed7f21c507996083f5d3cfbe5bcefc737c18d85
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cmb_pay.rb
CHANGED
@@ -14,15 +14,17 @@ module CmbPay
|
|
14
14
|
autoload(:BillRecordsMessage, File.expand_path('cmb_pay/message/bill_records_message', __dir__))
|
15
15
|
|
16
16
|
class << self
|
17
|
-
attr_accessor :branch_id
|
18
|
-
attr_accessor :co_no
|
19
|
-
attr_accessor :co_key
|
20
|
-
attr_accessor :mch_no
|
21
|
-
attr_accessor :operator
|
22
|
-
attr_accessor :operator_password
|
23
|
-
attr_accessor :expire_in_minutes
|
24
|
-
attr_accessor :environment
|
25
|
-
attr_accessor :default_payee_id
|
17
|
+
attr_accessor :branch_id # 开户分行号
|
18
|
+
attr_accessor :co_no # 支付商户号/收单商户号
|
19
|
+
attr_accessor :co_key # 商户校验码/商户密钥,测试环境为空
|
20
|
+
attr_accessor :mch_no # 协议商户企业编号,或者说是8位虚拟企业网银编号
|
21
|
+
attr_accessor :operator # 操作员号,一般是9999
|
22
|
+
attr_accessor :operator_password # 操作员的密码,默认是支付商户号,但建议修改。
|
23
|
+
attr_accessor :expire_in_minutes # 会话有效时间
|
24
|
+
attr_accessor :environment # 调用的招商银行支付环境,默认生产,测试填test
|
25
|
+
attr_accessor :default_payee_id # 默认收款方的用户标识
|
26
|
+
attr_accessor :default_goods_type # 默认收款方的商品类型
|
27
|
+
attr_accessor :one_cent_as_newspaper # 仅支付一分钱,商品类型直接归类到书报杂志,方便在生产上做快速测试和对账,默认启用
|
26
28
|
end
|
27
29
|
@co_key = ''
|
28
30
|
@mch_no = ''
|
@@ -30,6 +32,7 @@ module CmbPay
|
|
30
32
|
@operator_password = ''
|
31
33
|
@expire_in_minutes = 30
|
32
34
|
@environment = :production
|
35
|
+
@one_cent_as_newspaper = true
|
33
36
|
|
34
37
|
SUPPORTED_BANK = {
|
35
38
|
'招商银行' => nil,
|
@@ -60,6 +63,40 @@ module CmbPay
|
|
60
63
|
'上海银行' => 313
|
61
64
|
}.freeze
|
62
65
|
|
66
|
+
GOODS_TYPE = {
|
67
|
+
'网上支付' => 54_011_600,
|
68
|
+
'充值缴费' => 54_011_610,
|
69
|
+
'彩票' => 54_011_611,
|
70
|
+
'话费' => 54_011_612,
|
71
|
+
'虚拟商品' => 54_011_620,
|
72
|
+
'游戏点卡' => 54_011_621,
|
73
|
+
'旅游出行' => 54_010_6,
|
74
|
+
'酒店' => 54_010_650,
|
75
|
+
'机票' => 54_010_651,
|
76
|
+
'服装' => 54_010_5,
|
77
|
+
'文化教育' => 54_011_630,
|
78
|
+
'书报杂志' => 54_011_631,
|
79
|
+
'考试培训' => 54_011_632,
|
80
|
+
'数码产品' => 54_011_640,
|
81
|
+
'护肤化妆' => 54_010_7,
|
82
|
+
'母婴用品' => 54_011_650,
|
83
|
+
'生活日用' => 54_010_111,
|
84
|
+
'食品' => 54_010_112,
|
85
|
+
'汽车费用' => 54_010_2,
|
86
|
+
'信用卡还款' => 54_010_306, # 此商品类型只允许使用借记卡支付
|
87
|
+
'保险' => 54_011_1,
|
88
|
+
'家居物品' => 54_011_2,
|
89
|
+
'医疗保健' => 54_012_2,
|
90
|
+
'礼品' => 54_012_3,
|
91
|
+
'办公设备' => 54_011_660,
|
92
|
+
'家用电器' => 54_011_670,
|
93
|
+
'体育用品' => 54_011_680,
|
94
|
+
'娱乐休闲' => 54_010_8,
|
95
|
+
'网络服务' => 54_011_690,
|
96
|
+
'收藏爱好' => 54_011_691,
|
97
|
+
'投资理财' => 54_011_692
|
98
|
+
}.freeze
|
99
|
+
|
63
100
|
def self.uri_of_pre_pay_euserp(payer_id:, bill_no:, amount_in_cents:, merchant_url:, merchant_para: nil,
|
64
101
|
protocol:, merchant_ret_url:, merchant_ret_para: nil,
|
65
102
|
options: {})
|
@@ -186,6 +223,11 @@ module CmbPay
|
|
186
223
|
cmb_merchant_para = Service.encode_merchant_para(merchant_para)
|
187
224
|
trade_date = options.delete(:trade_date) || Time.now.strftime('%Y%m%d')
|
188
225
|
payee_id = options.delete(:payee_id) || CmbPay.default_payee_id
|
226
|
+
goods_type = if amount_in_cents == 1 && CmbPay.one_cent_as_newspaper == true
|
227
|
+
'书报杂志'
|
228
|
+
else
|
229
|
+
options.delete(:goods_type) || CmbPay.default_goods_type
|
230
|
+
end
|
189
231
|
random = options.delete(:random)
|
190
232
|
if protocol.is_a?(Hash) && !payer_id.nil?
|
191
233
|
cmb_reserved_xml = "<Protocol><PNo>#{protocol['PNo']}</PNo><TS>#{protocol['TS'] || Time.now.strftime('%Y%m%d%H%M%S')}</TS><MchNo>#{CmbPay.mch_no}</MchNo><Seq>#{protocol['Seq']}</Seq><MUID>#{payer_id}</MUID><URL>#{merchant_url}</URL><Para>#{cmb_merchant_para}</Para></Protocol>"
|
@@ -197,7 +239,7 @@ module CmbPay
|
|
197
239
|
branch_id: branch_id, co_no: co_no,
|
198
240
|
bill_no: cmb_bill_no, amount: pay_amount,
|
199
241
|
merchant_para: cmb_merchant_para, merchant_url: merchant_url,
|
200
|
-
payer_id: payer_id, payee_id: payee_id,
|
242
|
+
payer_id: payer_id, payee_id: payee_id, goods_type: encode_goods_type(goods_type),
|
201
243
|
reserved: cmb_reserved_xml)
|
202
244
|
uri_params = {
|
203
245
|
'BranchID' => branch_id,
|
@@ -220,4 +262,9 @@ module CmbPay
|
|
220
262
|
return nil if SUPPORTED_BANK[card_bank].nil?
|
221
263
|
"<CardBank>#{format('%04d', SUPPORTED_BANK[card_bank])}</CardBank>"
|
222
264
|
end
|
265
|
+
|
266
|
+
def self.encode_goods_type(goods_type)
|
267
|
+
return goods_type if /^\d+$/ =~ goods_type.to_s
|
268
|
+
GOODS_TYPE[goods_type]
|
269
|
+
end
|
223
270
|
end
|
data/lib/cmb_pay/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmb_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Guo
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
R5k6Ma92sW8jupX4cqbSu9rntdVQkNRpoHIrfU0MZT0cKsg/D1zMteylxrO3KMsz
|
31
31
|
SPQRv+nrI1J0zevFqb8010heoR8SDyUA0Mm3+Q==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2016-
|
33
|
+
date: 2016-09-06 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: http
|
metadata.gz.sig
CHANGED
@@ -1,4 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
=x�YdP},�i�e��sПY\3�J%�R�ᑩ-�NV�c�s��́���X�W|֮�+��!??��j�r̙� ���-���:�+x�Yżt��=C��
|
4
|
-
CK�F����
|
1
|
+
���R*��*P��9� ~��G����ƒ�S�u2-�%�IGq����&3E��I�p�X����6������H���M�)���BA ��
|
2
|
+
���d���+�/s2��ZM|]z���F4�\���v�ߧ��6GhC��&h��A����U��;/Υ ~mM<D)%�$;~�i��kd�i�!�����e�f&�D�q�]�ĸ���A��Os�1t엾��r�A��V���š�>$x�q肤+̤�nh���&3UC<�
|