mandarin-api 0.0.4 → 0.0.5

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: 9a6ae4c3a5ebe5e9a08ea002ed1d93c42d72432d
4
- data.tar.gz: 9eb2052849656b16cc2c54af1f4f57c2ab4eae19
3
+ metadata.gz: 3d4aba3edfeb7aff40572958bc18fbd887d24f5d
4
+ data.tar.gz: 9b25030128e058ae9667b536fd2c25c791f20be9
5
5
  SHA512:
6
- metadata.gz: ff7b51c2a95501e21272ee44e861da921d9cddca993d9a139bec5823e78d63ee2e3bec22d80c390f08cf5370f2274ad84f9aa08498edfe2457a80697850febe3
7
- data.tar.gz: 9df49f1d4a9d2c99bea8f28fd71276de13399beb2fbf6aa0e020cace04b5d42af0843411c0ebd886937c9ff2018893dfadc0dbe45635602c1673c304bb9081bb
6
+ metadata.gz: 6005b7c975f0107838f5afcc80052e9b7d3904cfe3d915bd39679e43803ef0c29dca23005e78d841b93b38e48cc5cec1851f6c3dfd50d80d5964fab9832bf953
7
+ data.tar.gz: 1828e3bc0bf0b9eac13f719f08732eedf7bd2887923de13750b60e394bb9ebd8bc2687d9ea87a3337add2d6ac4d045d9d23c5d4005d7dec778e1cc158948f75f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mandarin-api (0.0.4)
4
+ mandarin-api (0.0.5)
5
5
  rest-client (>= 2.0, < 3.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -30,6 +30,23 @@ MandarinApi.assign_card user
30
30
  ```
31
31
  Keep id, it will be used for pay/payouts requests. Use userWebLink to redirect user to Mandarin page for card data input.
32
32
 
33
+ ###**Example of oneway card binding:**
34
+ ```ruby
35
+ MandarinApi.oneway_assign_card user, card_number
36
+ ```
37
+ `user` should be an instance or a Struct, and should respond to `#email` and `#phone` methods
38
+ `#phone` should be serialized, for example '+79091234567' is correctly serialized number.
39
+ `#assign_card` will return a hash.
40
+ ###**Example:**
41
+ ```ruby
42
+ {
43
+ 'id' => '0eb51e74-e704-4c36-b5cb-8f0227621518',
44
+ }
45
+ ```
46
+ Keep id, it will be used for pay/payouts requests. Use userWebLink to redirect user to Mandarin page for card data input.
47
+ Oneway binded card can only be used for payouts.
48
+
49
+
33
50
  ###**Example of performing payment:**
34
51
  ```ruby
35
52
  # order_id - id of order/bill, etc. in your system.
data/lib/mandarin_api.rb CHANGED
@@ -8,6 +8,10 @@ module MandarinApi
8
8
  MandarinApi::CardManager.new.assign_card user
9
9
  end
10
10
 
11
+ def self.oneway_assign_card(user, card)
12
+ MandarinApi::CardManager.new.one_side_assign_card user, card
13
+ end
14
+
11
15
  def self.pay(order_id, amount, assigned_card_uuid)
12
16
  params = {
13
17
  order_id: order_id, amount: amount,
@@ -36,9 +40,9 @@ module MandarinApi
36
40
  }
37
41
  MandarinApi::PaymentManager.new.perform_rebill params
38
42
  end
39
-
43
+
40
44
  def self.process_callback(request_params, response_handler)
41
- response = MandarinApi::Responder.new.process(request_params)
45
+ response = MandarinApi::Responder.new(request_params)
42
46
  response_handler.success(response.data) if response.success
43
47
  response_handler.failure(response.data) if response.failure
44
48
  end
@@ -8,5 +8,15 @@ module MandarinApi
8
8
  secret: MandarinApi.config.secret)
9
9
  .request('/api/card-bindings', params)
10
10
  end
11
+
12
+ def one_side_assign_card(user, card)
13
+ params = {
14
+ customer_info: { email: user.email, phone: user.phone },
15
+ target: { known_card_number: card }
16
+ }
17
+ MandarinApi::Wrapper.new(merchant_id: MandarinApi.config.merchant_id,
18
+ secret: MandarinApi.config.secret)
19
+ .request('/api/card-bindings', params)
20
+ end
11
21
  end
12
22
  end
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.0.4'
4
+ s.version = '0.0.5'
5
5
  s.authors = ['Vladimir Bogaevsky', 'Boris Kraportov']
6
6
  s.email = 'gitvbogaevsky@gmail.com'
7
7
  s.licenses = ['MIT']
@@ -1,14 +1,15 @@
1
1
  RSpec.describe MandarinApi::CardManager do
2
+ let(:card_manager) { MandarinApi::CardManager.new }
3
+ let(:merchant_id) { 234 }
4
+ let(:secret) { 'secret' }
5
+ let(:user) { User.new('ololo@gmail.com', '8-909-999-88-77') }
6
+
7
+ User = Struct.new('User', :email, :phone)
2
8
  describe 'assign_card' do
3
- let(:card_manager) { MandarinApi::CardManager.new }
4
- let(:merchant_id) { 234 }
5
- let(:secret) { 'secret' }
6
9
  let(:params) do
7
10
  { customer_info: { email: 'ololo@gmail.com', phone: '8-909-999-88-77' } }
8
11
  end
9
12
  it 'calls wrapper instance with args' do
10
- User = Struct.new('User', :email, :phone)
11
- user = User.new('ololo@gmail.com', '8-909-999-88-77')
12
13
  allow(MandarinApi).to \
13
14
  receive_message_chain(:config, :merchant_id).and_return(merchant_id)
14
15
  allow(MandarinApi).to \
@@ -20,4 +21,23 @@ RSpec.describe MandarinApi::CardManager do
20
21
  card_manager.assign_card user
21
22
  end
22
23
  end
24
+
25
+ describe 'oneside_assign_card' do
26
+ let(:card) { '4012888888881881' }
27
+ let(:params) do
28
+ { customer_info: { email: 'ololo@gmail.com', phone: '8-909-999-88-77' },
29
+ target: { known_card_number: card } }
30
+ end
31
+ it 'calls wrapper instance with args' do
32
+ allow(MandarinApi).to \
33
+ receive_message_chain(:config, :merchant_id).and_return(merchant_id)
34
+ allow(MandarinApi).to \
35
+ receive_message_chain(:config, :secret).and_return(merchant_id)
36
+ allow_any_instance_of(MandarinApi::Wrapper).to receive(:request)
37
+ .with('/api/card-bindings', params)
38
+ expect_any_instance_of(MandarinApi::Wrapper).to receive(:request)
39
+ .with('/api/card-bindings', params)
40
+ card_manager.one_side_assign_card user, card
41
+ end
42
+ end
23
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandarin-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Bogaevsky
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-10-22 00:00:00.000000000 Z
12
+ date: 2016-10-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: webmock