pingpp 2.1.3 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/data/ca-certificates.crt +199 -280
- data/lib/pingpp/api_operations/delete.rb +9 -4
- data/lib/pingpp/app_based_resource.rb +27 -0
- data/lib/pingpp/balance_bonus.rb +14 -0
- data/lib/pingpp/balance_transaction.rb +9 -0
- data/lib/pingpp/balance_transfer.rb +10 -0
- data/lib/pingpp/batch_withdrawal.rb +11 -0
- data/lib/pingpp/channel.rb +8 -0
- data/lib/pingpp/coupon.rb +9 -0
- data/lib/pingpp/coupon_template.rb +29 -0
- data/lib/pingpp/order.rb +69 -0
- data/lib/pingpp/recharge.rb +36 -0
- data/lib/pingpp/royalty.rb +14 -0
- data/lib/pingpp/royalty_settlement.rb +11 -0
- data/lib/pingpp/royalty_template.rb +12 -0
- data/lib/pingpp/royalty_transaction.rb +9 -0
- data/lib/pingpp/settle_account.rb +12 -0
- data/lib/pingpp/singleton_app_based_resource.rb +26 -0
- data/lib/pingpp/sub_app.rb +12 -0
- data/lib/pingpp/sub_app_based_resource.rb +35 -0
- data/lib/pingpp/user.rb +9 -0
- data/lib/pingpp/user_based_resource.rb +35 -0
- data/lib/pingpp/util.rb +19 -1
- data/lib/pingpp/version.rb +1 -1
- data/lib/pingpp/withdrawal.rb +15 -0
- data/lib/pingpp.rb +37 -4
- data/test/balance_bonus_test.rb +51 -0
- data/test/balance_transaction_test.rb +19 -0
- data/test/balance_transfer_test.rb +55 -0
- data/test/batch_refund_test.rb +41 -0
- data/test/batch_transfer_test.rb +61 -0
- data/test/batch_withdrawal_test.rb +76 -0
- data/test/charge_test.rb +51 -0
- data/test/coupon_template_test.rb +68 -0
- data/test/coupon_test.rb +81 -0
- data/test/customs_test_bak.rb +31 -0
- data/test/order_test.rb +181 -0
- data/test/recharge_test.rb +106 -0
- data/test/refund_test.rb +32 -0
- data/test/royalty_settlement_test.rb +68 -0
- data/test/royalty_template_test.rb +102 -0
- data/test/royalty_test.rb +43 -0
- data/test/royalty_transaction_test.rb +24 -0
- data/test/settle_account_test.rb +41 -0
- data/test/sub_app_channel_test.rb +70 -0
- data/test/sub_app_test.rb +60 -0
- data/test/test_assistant.rb +35 -0
- data/test/test_data.rb +191 -0
- data/test/user_test.rb +42 -0
- data/test/withdrawal_test.rb +121 -0
- metadata +72 -7
- data/test/charge_reverse_test.rb +0 -84
- data/test/settle_account_tes.rb +0 -53
data/test/test_data.rb
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
module Pingpp
|
2
|
+
module TestData
|
3
|
+
@charge_id_created = nil
|
4
|
+
|
5
|
+
def get_api_key
|
6
|
+
'sk_test_ibbTe5jLGCi5rzfH4OqPW9KC'
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_api_key_live
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_app_id
|
13
|
+
'app_1Gqj58ynP0mHeX1q'
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_sub_app_id
|
17
|
+
'app_mX1mPSGyTqP4mPCK'
|
18
|
+
end
|
19
|
+
|
20
|
+
def sub_app_id_to_delete
|
21
|
+
'app_ayTqP4mX1PPSGCKm'
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_charge_id(ch_id)
|
25
|
+
@charge_id_created = ch_id
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_charge_id
|
29
|
+
'ch_TanbTO9OmjP4TGW5a1j1mPiL'
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_refund_id
|
33
|
+
're_f1iHq5CuDSSKGCS8y1SeDSqT'
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_bat_re_id
|
37
|
+
'1501702241124307723'
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_bat_tr_id
|
41
|
+
'1801702281011244578'
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_user_id
|
45
|
+
'test_user_001'
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_txn_id
|
49
|
+
'310317022810333800188901'
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_coupon_template_id
|
53
|
+
'300117012016532300016701'
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_unpaid_order_id
|
57
|
+
'2001702280000033651'
|
58
|
+
end
|
59
|
+
|
60
|
+
def make_charges_for_batch_refund
|
61
|
+
[
|
62
|
+
'ch_D8uDO4fPSS40SOSmT4WfTCm9',
|
63
|
+
'ch_rPOO4SbDqP04O8Sa9SaDa9u1'
|
64
|
+
]
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_settle_account_id
|
68
|
+
'test_user_001'
|
69
|
+
end
|
70
|
+
|
71
|
+
# 订单 (order) 相关 ID 信息
|
72
|
+
def existed_order_id
|
73
|
+
'2001709040000026131'
|
74
|
+
end
|
75
|
+
|
76
|
+
def existed_charge_id_of_order
|
77
|
+
['2001709040000026131', 'ch_fbD0SKiPynnLznT0S0zrvDSK']
|
78
|
+
end
|
79
|
+
|
80
|
+
def existed_refund_id_of_order
|
81
|
+
['2001709040000026131', 're_mnX90SPmzjnDvv1CWPyn5arH']
|
82
|
+
end
|
83
|
+
|
84
|
+
def order_to_cancel
|
85
|
+
'2001709040000028901'
|
86
|
+
end
|
87
|
+
|
88
|
+
def order_and_charge_to_refund
|
89
|
+
['2001709040000026131', 'ch_fbD0SKiPynnLznT0S0zrvDSK']
|
90
|
+
end
|
91
|
+
|
92
|
+
def order_to_pay
|
93
|
+
'2001709040000027851'
|
94
|
+
end
|
95
|
+
|
96
|
+
# 充值 (recharge) 相关 ID 信息
|
97
|
+
def existed_recharge_id
|
98
|
+
'220170904816730992640002'
|
99
|
+
end
|
100
|
+
|
101
|
+
def recharge_to_refund
|
102
|
+
'220170904816730992640002'
|
103
|
+
end
|
104
|
+
|
105
|
+
def existed_refund_id_of_recharge
|
106
|
+
['220170904816730992640002', 're_arDqzHPurrHGvD4KeD54O84K']
|
107
|
+
end
|
108
|
+
|
109
|
+
# 用户 user 相关 ID 信息
|
110
|
+
def existed_user_id
|
111
|
+
'user_007'
|
112
|
+
end
|
113
|
+
|
114
|
+
def existed_user_id_for_balance_transfer
|
115
|
+
'test_user_001'
|
116
|
+
end
|
117
|
+
|
118
|
+
# 余额赠送 balance_bonus 相关 ID 信息
|
119
|
+
def existed_balance_bonus_id
|
120
|
+
'650170904814419589120001'
|
121
|
+
end
|
122
|
+
|
123
|
+
# 余额转账 balance_transfer 相关 ID 信息
|
124
|
+
def existed_balance_transfer_id
|
125
|
+
'660170904814247700480002'
|
126
|
+
end
|
127
|
+
|
128
|
+
# 提现 withdrawal 相关 ID 信息
|
129
|
+
def existed_withdrawal_id
|
130
|
+
'1701709081542133945'
|
131
|
+
end
|
132
|
+
|
133
|
+
# 批量提现 batch_withdrawal 相关 ID 信息
|
134
|
+
def existed_batch_withdrawal_id
|
135
|
+
'1901709081656012102'
|
136
|
+
end
|
137
|
+
|
138
|
+
# 分润相关 ID 信息
|
139
|
+
def existed_royalty_template_id
|
140
|
+
'450170908173700001'
|
141
|
+
end
|
142
|
+
|
143
|
+
def royalty_template_id_to_delete
|
144
|
+
'450170908172300001'
|
145
|
+
end
|
146
|
+
|
147
|
+
def get_royalty_ids_to_update
|
148
|
+
[
|
149
|
+
'410170908205700002',
|
150
|
+
'410170908205700001',
|
151
|
+
]
|
152
|
+
end
|
153
|
+
|
154
|
+
def existed_royalty_id
|
155
|
+
'410170908205700001'
|
156
|
+
end
|
157
|
+
|
158
|
+
def get_payer_app
|
159
|
+
'app_1Gqj58ynP0mHeX1q'
|
160
|
+
end
|
161
|
+
|
162
|
+
def existed_royalty_settlement_id
|
163
|
+
'430170908211000001'
|
164
|
+
end
|
165
|
+
|
166
|
+
def existed_royalty_transaction_id
|
167
|
+
'440170908213000001'
|
168
|
+
end
|
169
|
+
|
170
|
+
# 优惠券相关 ID 信息
|
171
|
+
def coupon_id_and_user
|
172
|
+
['300317082315265100025202', 'test_user_001']
|
173
|
+
end
|
174
|
+
|
175
|
+
def coupon_id_and_user_to_delete
|
176
|
+
['300317082315160100056601', 'test_user_001']
|
177
|
+
end
|
178
|
+
|
179
|
+
def coupon_id_and_user_to_update
|
180
|
+
['300317090822145900061202', '488c35c2e06a']
|
181
|
+
end
|
182
|
+
|
183
|
+
def existed_coupon_template_id
|
184
|
+
'300117090822064600031402'
|
185
|
+
end
|
186
|
+
|
187
|
+
def coupon_template_id_to_delete
|
188
|
+
'300117090822195700031902'
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
data/test/user_test.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path('../test_assistant', __FILE__)
|
2
|
+
require "digest/md5"
|
3
|
+
|
4
|
+
module Pingpp
|
5
|
+
class UserTest < Test::Unit::TestCase
|
6
|
+
should "execute should return a new user when passed correct parameters" do
|
7
|
+
user_id = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
|
8
|
+
|
9
|
+
params = {
|
10
|
+
:id => user_id
|
11
|
+
}
|
12
|
+
|
13
|
+
u = Pingpp::User.create(params)
|
14
|
+
|
15
|
+
assert u.object == 'user'
|
16
|
+
assert u.id == user_id
|
17
|
+
end
|
18
|
+
|
19
|
+
should "execute should return an exist user when passed correct id" do
|
20
|
+
u = Pingpp::User.retrieve(get_user_id)
|
21
|
+
|
22
|
+
assert u.object == 'user'
|
23
|
+
assert u.id == get_user_id
|
24
|
+
end
|
25
|
+
|
26
|
+
should "execute should return a list of users when passed correct parameters" do
|
27
|
+
u = Pingpp::User.list(:per_page => 3)
|
28
|
+
|
29
|
+
assert u.object == 'list'
|
30
|
+
assert u.data.count <= 3
|
31
|
+
end
|
32
|
+
|
33
|
+
should "execute should return an updated user" do
|
34
|
+
new_address = 'Shanghai ' + Time.now.iso8601
|
35
|
+
u = Pingpp::User.update(get_user_id, {:address => new_address})
|
36
|
+
|
37
|
+
assert u.object == 'user'
|
38
|
+
assert u.id == get_user_id
|
39
|
+
assert u.address == new_address
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require File.expand_path('../test_assistant', __FILE__)
|
2
|
+
|
3
|
+
module Pingpp
|
4
|
+
class WithdrawalTest < Test::Unit::TestCase
|
5
|
+
# 创建提现
|
6
|
+
should "return an withdrawal object when passed correct parameters" do
|
7
|
+
params = {
|
8
|
+
# 提现用户 ID optional|string
|
9
|
+
:user => existed_user_id,
|
10
|
+
|
11
|
+
# 提现金额 required|integer
|
12
|
+
:amount => 10,
|
13
|
+
|
14
|
+
# 提现用户手续费 optional|integer
|
15
|
+
:user_fee => 0,
|
16
|
+
|
17
|
+
# 描述信息 optional|string
|
18
|
+
:description => "用户提现",
|
19
|
+
|
20
|
+
# 提现渠道 required|string
|
21
|
+
:channel => "alipay",
|
22
|
+
|
23
|
+
# 用户账号相关额外参数 conditional|hash; 使用 settle_account 时不需要此参数
|
24
|
+
:extra => {
|
25
|
+
# 收款账号 conditional|string; alipay 渠道为支付宝账号或 ID
|
26
|
+
:account => "user@gmail.com",
|
27
|
+
|
28
|
+
# 姓名 conditional|string
|
29
|
+
:name => "姓名",
|
30
|
+
},
|
31
|
+
|
32
|
+
# 结算账号 ID conditional|string; 与 user 绑定的结算账号 ID
|
33
|
+
# :settle_account => "SETTLE_ACCOUNT",
|
34
|
+
|
35
|
+
# metadata optional|hash
|
36
|
+
:metadata => {
|
37
|
+
:custom_key => "custom_value",
|
38
|
+
# ...
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
if params[:channel] == "allinpay"
|
43
|
+
params[:order_no] = "301002#{Time.now.to_i.to_s}#{rand(999999).to_s.rjust(6, "0")}"
|
44
|
+
else
|
45
|
+
params[:order_no] = "#{Time.now.to_i.to_s}#{rand(9999).to_s.rjust(4, "0")}"
|
46
|
+
end
|
47
|
+
|
48
|
+
o = Pingpp::Withdrawal.create(
|
49
|
+
params,
|
50
|
+
{
|
51
|
+
# URL 中的 {app_id} optional|string; 用于覆盖 Pingpp.app_id
|
52
|
+
:app => get_app_id
|
53
|
+
}
|
54
|
+
)
|
55
|
+
|
56
|
+
assert o.kind_of?(Pingpp::Withdrawal)
|
57
|
+
assert o.order_no == params[:order_no]
|
58
|
+
assert o.app == get_app_id
|
59
|
+
assert o.amount == params[:amount]
|
60
|
+
assert o.user == params[:user]
|
61
|
+
end
|
62
|
+
|
63
|
+
# 提现确认
|
64
|
+
should "return an pending withdrawal when passed a created withdrawal id" do
|
65
|
+
begin
|
66
|
+
o = Pingpp::Withdrawal.confirm(
|
67
|
+
existed_withdrawal_id,
|
68
|
+
{ :app => get_app_id } # App 信息
|
69
|
+
)
|
70
|
+
|
71
|
+
assert o.id == existed_withdrawal_id
|
72
|
+
assert o.app == get_app_id
|
73
|
+
assert o.kind_of?(Pingpp::Withdrawal)
|
74
|
+
rescue => e
|
75
|
+
assert e.kind_of?(Pingpp::InvalidRequestError)
|
76
|
+
assert e.message.include?("不能被更新状态") || e.message.include?("cannot be updated")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# 提现取消
|
81
|
+
should "return an canceled withdrawal when passed a created withdrawal id" do
|
82
|
+
begin
|
83
|
+
o = Pingpp::Withdrawal.cancel(
|
84
|
+
existed_withdrawal_id,
|
85
|
+
{ :app => get_app_id } # App 信息
|
86
|
+
)
|
87
|
+
|
88
|
+
assert o.id == existed_withdrawal_id
|
89
|
+
assert o.app == get_app_id
|
90
|
+
assert o.status == "canceled"
|
91
|
+
assert o.kind_of?(Pingpp::Withdrawal)
|
92
|
+
rescue => e
|
93
|
+
assert e.kind_of?(Pingpp::InvalidRequestError)
|
94
|
+
assert e.message.include?("不能被更新状态") || e.message.include?("cannot be updated")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# 查询提现
|
99
|
+
should "return an existed withdrawal when passed correct id" do
|
100
|
+
o = Pingpp::Withdrawal.retrieve(
|
101
|
+
existed_withdrawal_id,
|
102
|
+
{ :app => get_app_id } # App 信息
|
103
|
+
)
|
104
|
+
|
105
|
+
assert o.id == existed_withdrawal_id
|
106
|
+
assert o.app == get_app_id
|
107
|
+
assert o.kind_of?(Pingpp::Withdrawal)
|
108
|
+
end
|
109
|
+
|
110
|
+
# 查询提现列表
|
111
|
+
should "return a list object of withdrawal" do
|
112
|
+
o = Pingpp::Withdrawal.list(
|
113
|
+
{ :per_page => 3, :page => 1 },
|
114
|
+
{ :app => get_app_id } # App 信息
|
115
|
+
)
|
116
|
+
|
117
|
+
assert o.kind_of?(Pingpp::ListObject)
|
118
|
+
assert o.data[0].kind_of?(Pingpp::Withdrawal)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xufeng Weng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -46,9 +46,17 @@ files:
|
|
46
46
|
- lib/pingpp/api_operations/request.rb
|
47
47
|
- lib/pingpp/api_operations/update.rb
|
48
48
|
- lib/pingpp/api_resource.rb
|
49
|
+
- lib/pingpp/app_based_resource.rb
|
50
|
+
- lib/pingpp/balance_bonus.rb
|
51
|
+
- lib/pingpp/balance_transaction.rb
|
52
|
+
- lib/pingpp/balance_transfer.rb
|
49
53
|
- lib/pingpp/batch_refund.rb
|
50
54
|
- lib/pingpp/batch_transfer.rb
|
55
|
+
- lib/pingpp/batch_withdrawal.rb
|
56
|
+
- lib/pingpp/channel.rb
|
51
57
|
- lib/pingpp/charge.rb
|
58
|
+
- lib/pingpp/coupon.rb
|
59
|
+
- lib/pingpp/coupon_template.rb
|
52
60
|
- lib/pingpp/customs.rb
|
53
61
|
- lib/pingpp/errors/api_connection_error.rb
|
54
62
|
- lib/pingpp/errors/api_error.rb
|
@@ -60,17 +68,52 @@ files:
|
|
60
68
|
- lib/pingpp/event.rb
|
61
69
|
- lib/pingpp/identification.rb
|
62
70
|
- lib/pingpp/list_object.rb
|
71
|
+
- lib/pingpp/order.rb
|
63
72
|
- lib/pingpp/pingpp_object.rb
|
73
|
+
- lib/pingpp/recharge.rb
|
64
74
|
- lib/pingpp/red_envelope.rb
|
65
75
|
- lib/pingpp/refund.rb
|
76
|
+
- lib/pingpp/royalty.rb
|
77
|
+
- lib/pingpp/royalty_settlement.rb
|
78
|
+
- lib/pingpp/royalty_template.rb
|
79
|
+
- lib/pingpp/royalty_transaction.rb
|
80
|
+
- lib/pingpp/settle_account.rb
|
66
81
|
- lib/pingpp/singleton_api_resource.rb
|
82
|
+
- lib/pingpp/singleton_app_based_resource.rb
|
83
|
+
- lib/pingpp/sub_app.rb
|
84
|
+
- lib/pingpp/sub_app_based_resource.rb
|
67
85
|
- lib/pingpp/transfer.rb
|
86
|
+
- lib/pingpp/user.rb
|
87
|
+
- lib/pingpp/user_based_resource.rb
|
68
88
|
- lib/pingpp/util.rb
|
69
89
|
- lib/pingpp/version.rb
|
70
90
|
- lib/pingpp/webhook.rb
|
91
|
+
- lib/pingpp/withdrawal.rb
|
71
92
|
- lib/pingpp/wx_pub_oauth.rb
|
72
|
-
- test/
|
73
|
-
- test/
|
93
|
+
- test/balance_bonus_test.rb
|
94
|
+
- test/balance_transaction_test.rb
|
95
|
+
- test/balance_transfer_test.rb
|
96
|
+
- test/batch_refund_test.rb
|
97
|
+
- test/batch_transfer_test.rb
|
98
|
+
- test/batch_withdrawal_test.rb
|
99
|
+
- test/charge_test.rb
|
100
|
+
- test/coupon_template_test.rb
|
101
|
+
- test/coupon_test.rb
|
102
|
+
- test/customs_test_bak.rb
|
103
|
+
- test/order_test.rb
|
104
|
+
- test/recharge_test.rb
|
105
|
+
- test/refund_test.rb
|
106
|
+
- test/royalty_settlement_test.rb
|
107
|
+
- test/royalty_template_test.rb
|
108
|
+
- test/royalty_test.rb
|
109
|
+
- test/royalty_transaction_test.rb
|
110
|
+
- test/settle_account_test.rb
|
111
|
+
- test/sub_app_channel_test.rb
|
112
|
+
- test/sub_app_test.rb
|
113
|
+
- test/test_assistant.rb
|
114
|
+
- test/test_data.rb
|
115
|
+
- test/user_test.rb
|
116
|
+
- test/withdrawal_test.rb
|
74
117
|
homepage: https://www.pingxx.com/api
|
75
118
|
licenses:
|
76
119
|
- MIT
|
@@ -91,10 +134,32 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
134
|
version: '0'
|
92
135
|
requirements: []
|
93
136
|
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.5.2
|
95
138
|
signing_key:
|
96
139
|
specification_version: 4
|
97
140
|
summary: Ruby bindings for the PingPlusPlus API
|
98
141
|
test_files:
|
99
|
-
- test/
|
100
|
-
- test/
|
142
|
+
- test/batch_transfer_test.rb
|
143
|
+
- test/batch_withdrawal_test.rb
|
144
|
+
- test/test_assistant.rb
|
145
|
+
- test/sub_app_test.rb
|
146
|
+
- test/batch_refund_test.rb
|
147
|
+
- test/sub_app_channel_test.rb
|
148
|
+
- test/test_data.rb
|
149
|
+
- test/royalty_transaction_test.rb
|
150
|
+
- test/royalty_test.rb
|
151
|
+
- test/charge_test.rb
|
152
|
+
- test/balance_bonus_test.rb
|
153
|
+
- test/withdrawal_test.rb
|
154
|
+
- test/coupon_test.rb
|
155
|
+
- test/royalty_settlement_test.rb
|
156
|
+
- test/order_test.rb
|
157
|
+
- test/recharge_test.rb
|
158
|
+
- test/settle_account_test.rb
|
159
|
+
- test/customs_test_bak.rb
|
160
|
+
- test/balance_transfer_test.rb
|
161
|
+
- test/coupon_template_test.rb
|
162
|
+
- test/royalty_template_test.rb
|
163
|
+
- test/refund_test.rb
|
164
|
+
- test/user_test.rb
|
165
|
+
- test/balance_transaction_test.rb
|
data/test/charge_reverse_test.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
require 'pingpp'
|
4
|
-
require 'test/unit'
|
5
|
-
require 'shoulda/context'
|
6
|
-
|
7
|
-
module Pingpp
|
8
|
-
class ChargeReverseTest < Test::Unit::TestCase
|
9
|
-
|
10
|
-
should "charge reverse" do
|
11
|
-
Pingpp.api_base = "https://apidev.afon.ninja"
|
12
|
-
|
13
|
-
|
14
|
-
Pingpp.api_key = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC"
|
15
|
-
|
16
|
-
order_no = Time.now.to_i.to_s[0,12]
|
17
|
-
channel = "isv_wap"
|
18
|
-
|
19
|
-
extra = {
|
20
|
-
# 必须,终端号,1~8 位英文或数字,要求不同终端此号码不一样,会显示在对账单中。
|
21
|
-
:terminal_id => 'A0000007',
|
22
|
-
|
23
|
-
# 必须,客户端软件中展示的条码值,扫码设备扫描获取。1~32 位字符串。
|
24
|
-
:pay_channel => 'alipay',
|
25
|
-
|
26
|
-
:result_url => 'https://example.com',
|
27
|
-
|
28
|
-
# 可选,商品列表,上送格式参照下面示例。
|
29
|
-
:goods_list => [
|
30
|
-
{
|
31
|
-
'goods_id' => 'iphone6s16G', # 商户定义商品编号(一般为商品条码)。
|
32
|
-
'unified_goods_id' => '1001', # 统一商品编号,可选。
|
33
|
-
'goods_name' => 'iPhone 6s 16G', # 商品名称。
|
34
|
-
'goods_num' => 1, # 商品数量。
|
35
|
-
'price' => 528800, # 商品价格,单位为分。
|
36
|
-
'goods_category' => 'smartphone', # 商品类目,可选。
|
37
|
-
'body' => '苹果手机 iPhone 6s 16G', # 商品描述信息,可选。
|
38
|
-
'show_url' => 'https://www.example.com', # 商品的展示网址,可选。
|
39
|
-
}
|
40
|
-
]
|
41
|
-
}
|
42
|
-
|
43
|
-
ch = Pingpp::Charge.create(
|
44
|
-
:order_no => order_no,
|
45
|
-
:app => { :id => "app_1Gqj58ynP0mHeX1q" },
|
46
|
-
:channel => channel,# 支付使用的第三方支付渠道取值,请参考:https://www.pingxx.com/api#api-c-new
|
47
|
-
:amount => 100,# 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100)
|
48
|
-
:client_ip => "127.0.0.1",# 发起支付请求客户端的 IP 地址,格式为 IPV4,如: 127.0.0.1
|
49
|
-
:currency => "cny",
|
50
|
-
:subject => "Your Subject",
|
51
|
-
:body => "Your Body",
|
52
|
-
:extra => extra # extra 对应各渠道的取值规则请查看 charge_extra 相应方法内说明
|
53
|
-
)
|
54
|
-
puts ch
|
55
|
-
|
56
|
-
ch = Pingpp::Charge.reverse(ch.id)
|
57
|
-
puts ch
|
58
|
-
|
59
|
-
assert ch.object == 'charge'
|
60
|
-
assert ch.order_no == order_no
|
61
|
-
end
|
62
|
-
|
63
|
-
# should "settle_account update" do
|
64
|
-
|
65
|
-
# u = Pingpp::SettleAccount.update(get_settle_account_id, {}, {:user => get_user_id})
|
66
|
-
|
67
|
-
# assert u.object == 'list'
|
68
|
-
# assert u.data.count <= 3
|
69
|
-
# end
|
70
|
-
|
71
|
-
# should "settle_account list" do
|
72
|
-
# l = Pingpp::SettleAccount.list({:per_page => 3}, {:user => get_user_id})
|
73
|
-
#
|
74
|
-
# assert l.object == 'list'
|
75
|
-
# assert l.data.count <= 3
|
76
|
-
# end
|
77
|
-
|
78
|
-
# should "settle_account delete" do
|
79
|
-
# u = Pingpp::SettleAccount.delete(get_settle_account_id, {:user => get_user_id})
|
80
|
-
|
81
|
-
# assert u.object == 'deleted'
|
82
|
-
# end
|
83
|
-
end
|
84
|
-
end
|
data/test/settle_account_tes.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class SettleAccountTest < Test::Unit::TestCase
|
6
|
-
# should "settle_account create" do
|
7
|
-
# user_id = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
|
8
|
-
|
9
|
-
# params = {
|
10
|
-
# :id => user_id
|
11
|
-
# }
|
12
|
-
|
13
|
-
# u = Pingpp::User.create(params)
|
14
|
-
|
15
|
-
# assert u.object == 'user'
|
16
|
-
# assert u.id == user_id
|
17
|
-
# end
|
18
|
-
|
19
|
-
should "settle_account retrieve" do
|
20
|
-
puts RUBY_VERSION
|
21
|
-
puts OpenSSL::OPENSSL_LIBRARY_VERSION
|
22
|
-
puts OpenSSL::OPENSSL_VERSION
|
23
|
-
puts OpenSSL::VERSION
|
24
|
-
|
25
|
-
|
26
|
-
u = Pingpp::User.retrieve(get_user_id)
|
27
|
-
|
28
|
-
assert u.object == 'user'
|
29
|
-
assert u.id == get_user_id
|
30
|
-
end
|
31
|
-
|
32
|
-
# should "settle_account update" do
|
33
|
-
|
34
|
-
# u = Pingpp::SettleAccount.update(get_settle_account_id, {}, {:user => get_user_id})
|
35
|
-
|
36
|
-
# assert u.object == 'list'
|
37
|
-
# assert u.data.count <= 3
|
38
|
-
# end
|
39
|
-
|
40
|
-
should "settle_account list" do
|
41
|
-
l = Pingpp::SettleAccount.list({:per_page => 3}, {:user => get_user_id})
|
42
|
-
|
43
|
-
assert l.object == 'list'
|
44
|
-
assert l.data.count <= 3
|
45
|
-
end
|
46
|
-
|
47
|
-
# should "settle_account delete" do
|
48
|
-
# u = Pingpp::SettleAccount.delete(get_settle_account_id, {:user => get_user_id})
|
49
|
-
|
50
|
-
# assert u.object == 'deleted'
|
51
|
-
# end
|
52
|
-
end
|
53
|
-
end
|