mandarin-api 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/mandarin_api.rb +5 -2
- data/lib/mandarin_api/payment_manager.rb +3 -1
- data/mandarin-api.gemspec +1 -1
- data/spec/lib/mandarin_api/payment_manager_spec.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e9576e2892048c3af437090d2d15ebaff7ea4b0
|
4
|
+
data.tar.gz: 16a9517e2d100d244fea63b9135f18bed333d9ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 749fb5554f98bfe87449f9a0ce4f8d48f43db7f5c4397b61d2795cfec8721d61f3248bf68146831085320c6f4211a67ede0ba2e093c1c83ed4c05491d23c28da
|
7
|
+
data.tar.gz: 5deba8e26f6d8926cd49559ed5d7f5649a8278a99a22e27bec945c0115d4b84b3bb51e8c69f9baf06267dad17241cd92e4f4ba72b1e89931ba6fe10f6f68158b
|
data/Gemfile.lock
CHANGED
data/lib/mandarin_api.rb
CHANGED
@@ -37,8 +37,11 @@ module MandarinApi
|
|
37
37
|
MandarinApi::PaymentManager.new.perform_payout params
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.refund(order_id, transaction_uuid)
|
41
|
-
params = {
|
40
|
+
def self.refund(order_id, transaction_uuid, amount)
|
41
|
+
params = {
|
42
|
+
order_id: order_id, transaction_uuid: transaction_uuid,
|
43
|
+
amount: amount
|
44
|
+
}
|
42
45
|
MandarinApi::PaymentManager.new.perform_refund params
|
43
46
|
end
|
44
47
|
|
@@ -51,10 +51,12 @@ module MandarinApi
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def refund_request_body(params, action)
|
54
|
-
{
|
54
|
+
body = {
|
55
55
|
payment: { order_id: params[:order_id], action: action },
|
56
56
|
target: { transaction: params[:transaction_uuid] }
|
57
57
|
}
|
58
|
+
body[:payment][:price] = params[:price] if params[:price]
|
59
|
+
body
|
58
60
|
end
|
59
61
|
|
60
62
|
def rebill_request_body(params, action)
|
data/mandarin-api.gemspec
CHANGED
@@ -87,11 +87,26 @@ RSpec.describe MandarinApi::PaymentManager do
|
|
87
87
|
target: { transaction: '43913ddc000c4d3990fddbd3980c1725' }
|
88
88
|
}
|
89
89
|
end
|
90
|
+
|
91
|
+
let(:refund_request_body_w_price) do
|
92
|
+
{
|
93
|
+
payment: { order_id: 123_321, action: 'reversal', price: 1_000 },
|
94
|
+
target: { transaction: '43913ddc000c4d3990fddbd3980c1725' }
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
90
98
|
let(:params) do
|
91
99
|
{
|
92
100
|
order_id: 123_321, transaction_uuid: '43913ddc000c4d3990fddbd3980c1725'
|
93
101
|
}
|
94
102
|
end
|
103
|
+
|
104
|
+
let(:params_w_price) do
|
105
|
+
{
|
106
|
+
order_id: 123_321, transaction_uuid: '43913ddc000c4d3990fddbd3980c1725',
|
107
|
+
price: 1_000
|
108
|
+
}
|
109
|
+
end
|
95
110
|
it 'calls wrapper instance with args' do
|
96
111
|
allow(MandarinApi).to \
|
97
112
|
receive_message_chain(:config, :merchant_id).and_return(merchant_id)
|
@@ -103,6 +118,18 @@ RSpec.describe MandarinApi::PaymentManager do
|
|
103
118
|
.with('/api/transactions', refund_request_body)
|
104
119
|
payment_manager.perform_refund params
|
105
120
|
end
|
121
|
+
|
122
|
+
it 'add price to body if price was passed' do
|
123
|
+
allow(MandarinApi).to \
|
124
|
+
receive_message_chain(:config, :merchant_id).and_return(merchant_id)
|
125
|
+
allow(MandarinApi).to \
|
126
|
+
receive_message_chain(:config, :secret).and_return(merchant_id)
|
127
|
+
allow_any_instance_of(MandarinApi::Wrapper).to receive(:request)
|
128
|
+
.with('/api/transactions', refund_request_body)
|
129
|
+
expect_any_instance_of(MandarinApi::Wrapper).to receive(:request)
|
130
|
+
.with('/api/transactions', refund_request_body_w_price)
|
131
|
+
payment_manager.perform_refund params_w_price
|
132
|
+
end
|
106
133
|
end
|
107
134
|
|
108
135
|
describe '#perform_rebill' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mandarin-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Bogaevsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|