pingpp 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pingpp/charge.rb +6 -0
- data/lib/pingpp/version.rb +1 -1
- data/test/charge_reverse_test.rb +84 -0
- data/test/settle_account_tes.rb +53 -0
- metadata +6 -34
- data/test/balance_test.rb +0 -34
- data/test/balance_transaction_test.rb +0 -20
- data/test/batch_refund_test.rb +0 -41
- data/test/batch_transfer_test.rb +0 -71
- data/test/batch_withdrawal_test.rb +0 -20
- data/test/charge_test.rb +0 -51
- data/test/coupon_template_test.rb +0 -34
- data/test/customs_test_bak.rb +0 -32
- data/test/order_refund_test.rb +0 -19
- data/test/order_test.rb +0 -57
- data/test/refund_test.rb +0 -33
- data/test/ruby_version_test.rb +0 -9
- data/test/test_assistant.rb +0 -34
- data/test/test_data.rb +0 -61
- data/test/transaction_statistics_test.rb +0 -14
- data/test/user_test.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc6394fa864c1f39316db1bc68852f0cb76e7114
|
4
|
+
data.tar.gz: b907b63c9e78210fdc6f00fe618572d0fd76f870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8da71ea0b8e5e857fcb007848c7dcd8f0605dcf0e479ec1662ec5b8f79edcbc5a28f1dbc0bb80e93e10179b33e00e30d6946dfc6332f15485df2633ab3c70b3
|
7
|
+
data.tar.gz: 7de858368d3c26c570a79c1c03d1ca8df5b3a07bd41bf6f14b54fa6cf6bee108096aab6dd0c1c8cdbcaf16c24f8e9bd792cdd5a44b7f3458edfad94bee41d3d0
|
data/lib/pingpp/charge.rb
CHANGED
@@ -3,6 +3,12 @@ module Pingpp
|
|
3
3
|
extend Pingpp::APIOperations::Create
|
4
4
|
extend Pingpp::APIOperations::List
|
5
5
|
|
6
|
+
def self.reverse(id, opts={})
|
7
|
+
id, reverse_params = Util.normalize_id(id)
|
8
|
+
response, opts = request(:post, "#{resource_url(opts)}/#{CGI.escape(id)}/reverse", reverse_params, opts)
|
9
|
+
Util.convert_to_pingpp_object(response, opts)
|
10
|
+
end
|
11
|
+
|
6
12
|
private
|
7
13
|
|
8
14
|
def refund_url
|
data/lib/pingpp/version.rb
CHANGED
@@ -0,0 +1,84 @@
|
|
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
|
@@ -0,0 +1,53 @@
|
|
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
|
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.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xufeng Weng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -69,22 +69,8 @@ files:
|
|
69
69
|
- lib/pingpp/version.rb
|
70
70
|
- lib/pingpp/webhook.rb
|
71
71
|
- lib/pingpp/wx_pub_oauth.rb
|
72
|
-
- test/
|
73
|
-
- test/
|
74
|
-
- test/batch_refund_test.rb
|
75
|
-
- test/batch_transfer_test.rb
|
76
|
-
- test/batch_withdrawal_test.rb
|
77
|
-
- test/charge_test.rb
|
78
|
-
- test/coupon_template_test.rb
|
79
|
-
- test/customs_test_bak.rb
|
80
|
-
- test/order_refund_test.rb
|
81
|
-
- test/order_test.rb
|
82
|
-
- test/refund_test.rb
|
83
|
-
- test/ruby_version_test.rb
|
84
|
-
- test/test_assistant.rb
|
85
|
-
- test/test_data.rb
|
86
|
-
- test/transaction_statistics_test.rb
|
87
|
-
- test/user_test.rb
|
72
|
+
- test/charge_reverse_test.rb
|
73
|
+
- test/settle_account_tes.rb
|
88
74
|
homepage: https://www.pingxx.com/api
|
89
75
|
licenses:
|
90
76
|
- MIT
|
@@ -110,19 +96,5 @@ signing_key:
|
|
110
96
|
specification_version: 4
|
111
97
|
summary: Ruby bindings for the PingPlusPlus API
|
112
98
|
test_files:
|
113
|
-
- test/
|
114
|
-
- test/
|
115
|
-
- test/batch_refund_test.rb
|
116
|
-
- test/batch_transfer_test.rb
|
117
|
-
- test/batch_withdrawal_test.rb
|
118
|
-
- test/charge_test.rb
|
119
|
-
- test/coupon_template_test.rb
|
120
|
-
- test/customs_test_bak.rb
|
121
|
-
- test/order_refund_test.rb
|
122
|
-
- test/order_test.rb
|
123
|
-
- test/refund_test.rb
|
124
|
-
- test/ruby_version_test.rb
|
125
|
-
- test/test_assistant.rb
|
126
|
-
- test/test_data.rb
|
127
|
-
- test/transaction_statistics_test.rb
|
128
|
-
- test/user_test.rb
|
99
|
+
- test/charge_reverse_test.rb
|
100
|
+
- test/settle_account_tes.rb
|
data/test/balance_test.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class BalanceTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a transfer balance_transaction" do
|
7
|
-
obj = Pingpp::Balance.create_transfer(
|
8
|
-
:user => 'test_user_001',
|
9
|
-
:recipient => 'test_user_004',
|
10
|
-
:description => 'Balance transfer description.',
|
11
|
-
:amount => 200
|
12
|
-
)
|
13
|
-
|
14
|
-
puts obj
|
15
|
-
|
16
|
-
assert obj.object == 'balance_transaction'
|
17
|
-
end
|
18
|
-
|
19
|
-
should "execute should return a receipts balance_transaction list" do
|
20
|
-
obj = Pingpp::Balance.create_receipts(
|
21
|
-
:type => 'receipts_earning',
|
22
|
-
:description => 'Balance receipts description.',
|
23
|
-
:receipts => [
|
24
|
-
{ :user => 'test_user_001', :amount => 500 },
|
25
|
-
{ :user => 'test_user_003', :amount => 700 }
|
26
|
-
]
|
27
|
-
)
|
28
|
-
|
29
|
-
puts obj
|
30
|
-
|
31
|
-
assert obj.object == 'list'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class BalanceTransactionTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a balance_transaction list when passed correct parameters" do
|
7
|
-
txns = Pingpp::BalanceTransaction.list({:per_page => 3}, {:user => get_user_id})
|
8
|
-
|
9
|
-
assert txns.object == 'list'
|
10
|
-
assert txns.data.count <= 3
|
11
|
-
end
|
12
|
-
|
13
|
-
should "execute should return an exist balance_transaction when passed correct id" do
|
14
|
-
txn = Pingpp::BalanceTransaction.retrieve(get_txn_id, {:user => get_user_id})
|
15
|
-
|
16
|
-
assert txn.object == 'balance_transaction'
|
17
|
-
assert txn.id == get_txn_id
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/test/batch_refund_test.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class BatchRefundTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a new batch_refund when passed correct parameters" do
|
7
|
-
batch_no = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
|
8
|
-
|
9
|
-
params = {
|
10
|
-
:app => get_app_id,
|
11
|
-
:batch_no => batch_no,
|
12
|
-
:charges => make_charges_for_batch_refund,
|
13
|
-
:description => 'This is a batch_refund test.',
|
14
|
-
:metadata => {
|
15
|
-
:custom_key => 'custom_content'
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
batre = Pingpp::BatchRefund.create(params)
|
20
|
-
assert batre.object == 'batch_refund'
|
21
|
-
|
22
|
-
assert batre.charges == params[:charges]
|
23
|
-
assert batre.batch_no = params[:batch_no]
|
24
|
-
end
|
25
|
-
|
26
|
-
should "execute should return a batch_refund list" do
|
27
|
-
batres = Pingpp::BatchRefund.list(:per_page => 3)
|
28
|
-
|
29
|
-
assert batres.object == 'list'
|
30
|
-
assert batres.url.start_with?('/v1/batch_refunds')
|
31
|
-
assert batres.data.length <= 3
|
32
|
-
end
|
33
|
-
|
34
|
-
should "execute should return an exist batch_refund when passed correct id" do
|
35
|
-
batre = Pingpp::BatchRefund.retrieve(get_bat_re_id)
|
36
|
-
|
37
|
-
assert batre.id == get_bat_re_id
|
38
|
-
assert batre.object == 'batch_refund'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/test/batch_transfer_test.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class BatchTransferTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a new batch_transfer when passed correct parameters" do
|
7
|
-
batch_no = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
|
8
|
-
|
9
|
-
params = {
|
10
|
-
:app => get_app_id,
|
11
|
-
:batch_no => batch_no,
|
12
|
-
:channel => 'unionpay',
|
13
|
-
:amount => 700,
|
14
|
-
:type => 'b2c',
|
15
|
-
:description => 'This is a batch_transfer test.',
|
16
|
-
:metadata => {
|
17
|
-
:custom_key => 'custom_content'
|
18
|
-
},
|
19
|
-
:currency => 'cny',
|
20
|
-
:recipients => [
|
21
|
-
{
|
22
|
-
:amount => 300,
|
23
|
-
:name => 'name01',
|
24
|
-
:open_bank_code => '0102',
|
25
|
-
:account => '6226000022223333'
|
26
|
-
}, {
|
27
|
-
:amount => 400,
|
28
|
-
:name => 'name02',
|
29
|
-
:open_bank_code => '0102',
|
30
|
-
:account => '622600002222334'
|
31
|
-
}
|
32
|
-
]
|
33
|
-
}
|
34
|
-
|
35
|
-
battr = Pingpp::BatchTransfer.create(params)
|
36
|
-
|
37
|
-
puts battr
|
38
|
-
|
39
|
-
assert battr.object == 'batch_transfer'
|
40
|
-
assert battr.amount == params[:amount]
|
41
|
-
assert battr.batch_no = params[:batch_no]
|
42
|
-
assert battr.app == params[:app]
|
43
|
-
assert battr.recipients.count == params[:recipients].count
|
44
|
-
end
|
45
|
-
|
46
|
-
should "execute should return a batch_transfer list" do
|
47
|
-
batres = Pingpp::BatchTransfer.list(:per_page => 3)
|
48
|
-
|
49
|
-
assert batres.object == 'list'
|
50
|
-
assert batres.url.start_with?('/v1/batch_transfers')
|
51
|
-
assert batres.data.count <= 3
|
52
|
-
end
|
53
|
-
|
54
|
-
should "execute should return an exist batch_transfer when passed correct id" do
|
55
|
-
batre = Pingpp::BatchTransfer.retrieve("1801612271223448888")
|
56
|
-
puts batre
|
57
|
-
|
58
|
-
assert batre.id == get_bat_tr_id
|
59
|
-
assert batre.object == 'batch_transfer'
|
60
|
-
end
|
61
|
-
|
62
|
-
should "execute should return a canceled batch_transfer" do
|
63
|
-
# # batres = Pingpp::BatchTransfer.list(:per_page => 3)
|
64
|
-
# # puts batres
|
65
|
-
# batre = Pingpp::BatchTransfer.retrieve('1811612271212521002')
|
66
|
-
# puts batre
|
67
|
-
# batre = Pingpp::BatchTransfer.cancel('1811612271212521002')
|
68
|
-
# puts batre
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class BatchWithdrawalTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a batch_withdrawal object when passed correct parameters" do
|
7
|
-
params = {
|
8
|
-
:withdrawals => [
|
9
|
-
'1701611160206541729',
|
10
|
-
'1701611160207110403'
|
11
|
-
]
|
12
|
-
}
|
13
|
-
bw = Pingpp::BatchWithdrawal.create(params)
|
14
|
-
|
15
|
-
puts bw
|
16
|
-
|
17
|
-
assert bw.object == 'batch_withdrawal'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/test/charge_test.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class ChargeTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a new, fully executed charge when passed correct parameters" do
|
7
|
-
order_no = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
|
8
|
-
channel = 'wx'
|
9
|
-
|
10
|
-
params = {
|
11
|
-
:order_no => order_no,
|
12
|
-
:app => { :id => get_app_id },
|
13
|
-
:channel => channel, # 支付使用的第三方支付渠道取值,请参考:https://www.pingxx.com/api#api-c-new
|
14
|
-
:amount => 128000, # 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100)
|
15
|
-
:client_ip => "127.0.0.1", # 发起支付请求客户端的 IP 地址,格式为 IPV4,如: 127.0.0.1
|
16
|
-
:currency => "cny",
|
17
|
-
:subject => "Your Subject",
|
18
|
-
:body => "Your Body",
|
19
|
-
:extra => {}
|
20
|
-
}
|
21
|
-
|
22
|
-
c = Pingpp::Charge.create(params)
|
23
|
-
|
24
|
-
assert c.order_no == params[:order_no]
|
25
|
-
assert c.app == get_app_id
|
26
|
-
assert c.channel == params[:channel]
|
27
|
-
assert c.amount == params[:amount]
|
28
|
-
assert c.paid == false
|
29
|
-
end
|
30
|
-
|
31
|
-
should "execute should return a charge list when passed correct parameters" do
|
32
|
-
l = Pingpp::Charge.list(
|
33
|
-
:app => { :id => get_app_id },
|
34
|
-
:limit => 3,
|
35
|
-
:paid => true,
|
36
|
-
:refunded => false
|
37
|
-
)
|
38
|
-
|
39
|
-
assert l.object == 'list'
|
40
|
-
assert l.data.count <= 3
|
41
|
-
end
|
42
|
-
|
43
|
-
should "execute should return an exist charge when passed correct charge id" do
|
44
|
-
ch_id = get_charge_id # 'ch_0mLyb5KmffX5yrnb1OvLKKSO'
|
45
|
-
c = Pingpp::Charge.retrieve(ch_id)
|
46
|
-
|
47
|
-
assert c.object == 'charge'
|
48
|
-
assert c.id == ch_id
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class CouponTemplateTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a coupon_template list when passed correct parameters" do
|
7
|
-
ctmpl = Pingpp::CouponTemplate.list({:per_page => 3})
|
8
|
-
|
9
|
-
assert ctmpl.object == 'list'
|
10
|
-
assert ctmpl.data.count <= 3
|
11
|
-
end
|
12
|
-
|
13
|
-
should "execute should return an exist coupon_template when passed correct id" do
|
14
|
-
ctmpl = Pingpp::CouponTemplate.retrieve(get_coupon_template_id)
|
15
|
-
|
16
|
-
assert ctmpl.object == 'coupon_template'
|
17
|
-
assert ctmpl.id == get_coupon_template_id
|
18
|
-
end
|
19
|
-
|
20
|
-
should "execute should return a coupon list made from coupon_template when passed correct coupon_template_id" do
|
21
|
-
coupons = Pingpp::CouponTemplate.list_coupons(get_coupon_template_id, {:per_page => 3})
|
22
|
-
|
23
|
-
assert coupons.object == 'list'
|
24
|
-
assert coupons.data.count <= 3
|
25
|
-
end
|
26
|
-
|
27
|
-
# should "execute should return a coupon list made from coupon_template when passed correct coupon_template_id and parameters" do
|
28
|
-
# coupons = Pingpp::CouponTemplate.create_coupons(get_coupon_template_id, {:users => [get_user_id]})
|
29
|
-
#
|
30
|
-
# assert coupons.object == 'list'
|
31
|
-
# assert coupons.data.count <= 3
|
32
|
-
# end
|
33
|
-
end
|
34
|
-
end
|
data/test/customs_test_bak.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class CustomsTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a new customs when passed correct parameters" do
|
7
|
-
order_no = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
|
8
|
-
channel = 'upacp'
|
9
|
-
|
10
|
-
params = {
|
11
|
-
:app => get_app_id,
|
12
|
-
:charge => get_charge_id,
|
13
|
-
:channel => channel,
|
14
|
-
:trade_no => order_no,
|
15
|
-
:customs_code => 'GUANGZHOU',
|
16
|
-
:amount => 10,
|
17
|
-
:transport_amount => 1,
|
18
|
-
:is_split => true,
|
19
|
-
:sub_order_no => 'subord11010002',
|
20
|
-
:extra => {
|
21
|
-
:pay_account => '1234567890',
|
22
|
-
:certif_type => '02',
|
23
|
-
:customer_name => 'name',
|
24
|
-
:certif_id => '1234',
|
25
|
-
:tax_amount => 1
|
26
|
-
}
|
27
|
-
}
|
28
|
-
cu = Pingpp::Customs.create(params)
|
29
|
-
puts cu
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/test/order_refund_test.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class OrderRefundTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a order_refund list when passed correct order id" do
|
7
|
-
l = Pingpp::OrderRefund.list('2001609130000002762')
|
8
|
-
puts l
|
9
|
-
assert l.object == 'list'
|
10
|
-
assert l.data.count <= 3
|
11
|
-
end
|
12
|
-
|
13
|
-
should "execute should return an exist order_refund when passed correct id" do
|
14
|
-
o = Pingpp::OrderRefund.retrieve('2001609130000002762', '2001609130000002763')
|
15
|
-
|
16
|
-
assert o.object == 'order_order'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/order_test.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class OrderTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a new, fully executed order when passed correct parameters" do
|
7
|
-
order_no = Digest::MD5.hexdigest(Time.now.to_i.to_s)[0,12]
|
8
|
-
|
9
|
-
params = {
|
10
|
-
:merchant_order_no => order_no,
|
11
|
-
:app => get_app_id,
|
12
|
-
:amount => 100, # 订单总金额, 人民币单位:分(如订单总金额为 1 元,此处请填 100)
|
13
|
-
:client_ip => "127.0.0.1", # 发起支付请求客户端的 IP 地址,格式为 IPV4,如: 127.0.0.1
|
14
|
-
:currency => "cny",
|
15
|
-
:subject => "Your Subject",
|
16
|
-
:body => "Your Body",
|
17
|
-
:uid => get_user_id
|
18
|
-
}
|
19
|
-
|
20
|
-
o = Pingpp::Order.create(params)
|
21
|
-
|
22
|
-
assert o.merchant_order_no == params[:merchant_order_no]
|
23
|
-
assert o.app == get_app_id
|
24
|
-
assert o.amount == 100
|
25
|
-
assert o.paid == false
|
26
|
-
end
|
27
|
-
|
28
|
-
should "execute should return an order list when passed correct parameters" do
|
29
|
-
l = Pingpp::Order.list(:app => get_app_id, :per_page => 3, :paid => true)
|
30
|
-
|
31
|
-
assert l.object == 'list'
|
32
|
-
assert l.data.count <= 3
|
33
|
-
end
|
34
|
-
|
35
|
-
should "execute should return an canceled order when passed correct id" do
|
36
|
-
o = Pingpp::Order.cancel(get_unpaid_order_id)
|
37
|
-
|
38
|
-
assert o.object == 'order'
|
39
|
-
assert o.status == 'canceled'
|
40
|
-
end
|
41
|
-
|
42
|
-
should "execute should return an exist order when passed correct id" do
|
43
|
-
o = Pingpp::Order.retrieve('2001609130000002762')
|
44
|
-
|
45
|
-
assert o.object == 'order'
|
46
|
-
end
|
47
|
-
|
48
|
-
should "execute should return an order with credential when passed correct id and parameters" do
|
49
|
-
o = Pingpp::Order.pay('2001609130000002762', {:balance_amount => 0,
|
50
|
-
:charge_amount => 10,
|
51
|
-
:channel => 'alipay'})
|
52
|
-
|
53
|
-
assert o.object == 'order'
|
54
|
-
assert o.has_key?('charge_essentials')
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/test/refund_test.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
require "digest/md5"
|
3
|
-
|
4
|
-
module Pingpp
|
5
|
-
class RefundTest < Test::Unit::TestCase
|
6
|
-
should "execute should return a refund list when passed correct parameters" do
|
7
|
-
l = Pingpp::Refund.list(get_charge_id, {:limit => 3})
|
8
|
-
|
9
|
-
assert l.object == 'list'
|
10
|
-
assert l.data.count <= 3
|
11
|
-
end
|
12
|
-
|
13
|
-
should "execute should return a refund when passed correct parameters" do
|
14
|
-
ch_id = get_charge_id
|
15
|
-
|
16
|
-
r = Pingpp::Refund.create(ch_id, {:amount => 1, :description => 'Refund amount test.'})
|
17
|
-
|
18
|
-
assert r.object == 'refund'
|
19
|
-
assert r.charge == ch_id
|
20
|
-
end
|
21
|
-
|
22
|
-
should "execute should return an exist refund when passed correct charge id and refund id" do
|
23
|
-
re_id = get_refund_id
|
24
|
-
ch_id = get_charge_id
|
25
|
-
|
26
|
-
r = Pingpp::Refund.retrieve(ch_id, re_id)
|
27
|
-
|
28
|
-
assert r.object == 'refund'
|
29
|
-
assert r.id == re_id
|
30
|
-
assert r.charge == ch_id
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
data/test/ruby_version_test.rb
DELETED
data/test/test_assistant.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'pingpp'
|
2
|
-
require 'test/unit'
|
3
|
-
require 'mocha/setup'
|
4
|
-
require 'stringio'
|
5
|
-
require 'shoulda/context'
|
6
|
-
require File.expand_path('../test_data', __FILE__)
|
7
|
-
|
8
|
-
module Pingpp
|
9
|
-
@mock_rest_client = nil
|
10
|
-
|
11
|
-
def self.mock_rest_client=(mock_client)
|
12
|
-
@mock_rest_client = mock_client
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Test::Unit::TestCase
|
17
|
-
include Pingpp::TestData
|
18
|
-
include Mocha
|
19
|
-
|
20
|
-
setup do
|
21
|
-
@mock = mock
|
22
|
-
# Pingpp.mock_rest_client = @mock
|
23
|
-
Pingpp.api_base = 'https://apidev.afon.ninja'
|
24
|
-
Pingpp.api_key = get_api_key_live
|
25
|
-
Pingpp.app_id = get_app_id
|
26
|
-
|
27
|
-
Pingpp.private_key_path = File.expand_path('../rsa_private_key.pem', __FILE__)
|
28
|
-
end
|
29
|
-
|
30
|
-
teardown do
|
31
|
-
Pingpp.mock_rest_client = nil
|
32
|
-
Pingpp.api_key = nil
|
33
|
-
end
|
34
|
-
end
|
data/test/test_data.rb
DELETED
@@ -1,61 +0,0 @@
|
|
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
|
-
'sk_live_vjfr90jj1q985KuPO84iP8KO'
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_app_id
|
14
|
-
# 'app_1Gqj58ynP0mHeX1q'
|
15
|
-
'app_LibTW1n1SOq9Pin1'
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_charge_id(ch_id)
|
19
|
-
@charge_id_created = ch_id
|
20
|
-
end
|
21
|
-
|
22
|
-
def get_charge_id
|
23
|
-
'ch_rXvbvHyfLmWD0aSGKG488WnT'
|
24
|
-
end
|
25
|
-
|
26
|
-
def get_refund_id
|
27
|
-
're_iXrDb5qF54OCz9mnH0844G0S'
|
28
|
-
end
|
29
|
-
|
30
|
-
def get_bat_re_id
|
31
|
-
'1501611031340575011'
|
32
|
-
end
|
33
|
-
|
34
|
-
def get_bat_tr_id
|
35
|
-
'1801611031338284973'
|
36
|
-
end
|
37
|
-
|
38
|
-
def get_user_id
|
39
|
-
'test_user_001'
|
40
|
-
end
|
41
|
-
|
42
|
-
def get_txn_id
|
43
|
-
'310216101213443000003501'
|
44
|
-
end
|
45
|
-
|
46
|
-
def get_coupon_template_id
|
47
|
-
'300116082416033500000800'
|
48
|
-
end
|
49
|
-
|
50
|
-
def get_unpaid_order_id
|
51
|
-
'2001611040000002171'
|
52
|
-
end
|
53
|
-
|
54
|
-
def make_charges_for_batch_refund
|
55
|
-
[
|
56
|
-
'ch_PyfLSGLiHKS0rDunTO4W9y18',
|
57
|
-
'ch_bfbjr5TaPG8CarLyHG1eHGK0'
|
58
|
-
]
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require File.expand_path('../test_assistant', __FILE__)
|
2
|
-
|
3
|
-
module Pingpp
|
4
|
-
class TransactionStatisticsTest < Test::Unit::TestCase
|
5
|
-
should "execute should return a transaction_statistics object" do
|
6
|
-
ts = Pingpp::TransactionStatistics.retrieve(
|
7
|
-
:time_start => Time.now.to_i - 86400 * 60,
|
8
|
-
:time_end => Time.now.to_i - 86400 * 30
|
9
|
-
)
|
10
|
-
|
11
|
-
assert ts.object == 'transaction_statistics'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/test/user_test.rb
DELETED
@@ -1,33 +0,0 @@
|
|
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
|
-
end
|
33
|
-
end
|