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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d8c32b764a06d6f92e22c34b1d0fb9c4f83da00
4
- data.tar.gz: 45cf6c66143f1d691ef20293f4d91ba2f27585c1
3
+ metadata.gz: 9e9576e2892048c3af437090d2d15ebaff7ea4b0
4
+ data.tar.gz: 16a9517e2d100d244fea63b9135f18bed333d9ce
5
5
  SHA512:
6
- metadata.gz: df00ea5909bad4ab9028976ba2cd0a1cdc84657ee67a49cce9a709997a8097054626fd80ba4b3ea0a252ed5c5297b68505a69994ed2f6f9a09fc7ce7a14fbb23
7
- data.tar.gz: da75dc387ff5c3271c16b24303498dfd6035beb6c64f657bfddbe6b7d5eb86298a63dac89ccd9f8adb43ed92133fb52c2d1aa651e605daabe08dc3476d8b6d19
6
+ metadata.gz: 749fb5554f98bfe87449f9a0ce4f8d48f43db7f5c4397b61d2795cfec8721d61f3248bf68146831085320c6f4211a67ede0ba2e093c1c83ed4c05491d23c28da
7
+ data.tar.gz: 5deba8e26f6d8926cd49559ed5d7f5649a8278a99a22e27bec945c0115d4b84b3bb51e8c69f9baf06267dad17241cd92e4f4ba72b1e89931ba6fe10f6f68158b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mandarin-api (0.2.1)
4
+ mandarin-api (0.2.2)
5
5
  rest-client (>= 2.0, < 3.0)
6
6
 
7
7
  GEM
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 = { order_id: order_id, transaction_uuid: transaction_uuid }
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'mandarin-api'
4
- s.version = '0.2.1'
4
+ s.version = '0.2.2'
5
5
  s.authors = ['Vladimir Bogaevsky']
6
6
  s.email = 'gitvbogaevsky@gmail.com'
7
7
  s.licenses = ['MIT']
@@ -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.1
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-01-12 00:00:00.000000000 Z
11
+ date: 2017-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: webmock