mandarin-api 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1643d81e6774e7c811abcf111b636a289aa8839a
4
- data.tar.gz: 63300bd786765890c7111e1d8d820c3d5fbe2558
3
+ metadata.gz: 0d8c32b764a06d6f92e22c34b1d0fb9c4f83da00
4
+ data.tar.gz: 45cf6c66143f1d691ef20293f4d91ba2f27585c1
5
5
  SHA512:
6
- metadata.gz: 122c5becef312f7e3a912e6c507dfb73b35e7a967acf70609996d6187c05989fc415344277b92ed964a6a4ac85c45d3c26c2aa19fedb0aa476420f19bace4817
7
- data.tar.gz: 8be0eb3138d8d5fc5e176d9b84cad6ac4e36e8df9d6bd4b5a80255ae6087f325ab6ec64d5cddec7ce104f860add2275d63e0660a670574112818ec0b80c9a913
6
+ metadata.gz: df00ea5909bad4ab9028976ba2cd0a1cdc84657ee67a49cce9a709997a8097054626fd80ba4b3ea0a252ed5c5297b68505a69994ed2f6f9a09fc7ce7a14fbb23
7
+ data.tar.gz: da75dc387ff5c3271c16b24303498dfd6035beb6c64f657bfddbe6b7d5eb86298a63dac89ccd9f8adb43ed92133fb52c2d1aa651e605daabe08dc3476d8b6d19
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mandarin-api (0.2.0)
4
+ mandarin-api (0.2.1)
5
5
  rest-client (>= 2.0, < 3.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -65,7 +65,7 @@ Oneway binded card can only be used for payouts.
65
65
  # order_id - id of order/bill, etc. in your system.
66
66
  # amount - sum of payout
67
67
  # assigned_card_uuid - the id you received assigning the card
68
- # extra - an hash to keep your additional data
68
+ # extra - an array of hashes to keep your additional data
69
69
  MandarinApi.payment(order_id, amount, assigned_card_uuid, extra)
70
70
  ```
71
71
  `#payment` will return a hash with transaction id.
@@ -81,7 +81,7 @@ MandarinApi.payment(order_id, amount, assigned_card_uuid, extra)
81
81
  # order_id - id of order/bill, etc. in your system.
82
82
  # amount - sum of payout
83
83
  # assigned_card_uuid - the id you received assigning the card
84
- # extra - an hash to keep your additional data
84
+ # extra - an array of hashes to keep your additional data
85
85
  MandarinApi.payout(order_id, amount, assigned_card_uuid, extra)
86
86
  ```
87
87
  `#payout` will return a hash with transaction id.
@@ -107,8 +107,10 @@ MandarinApi.charge(order_id, amount, user, optional)
107
107
  return: 'https://www.your-page-to-return-user-to.com',
108
108
  callback: 'https:/www.your-endpoint-for-callbacks.com'
109
109
  },
110
- visible: { a: 'This value will be visible during payment process on Mandarin page' },
111
- invisible: { some_additional_id: 12} # this value won't be visible and will be returned in callback
110
+ custom_values: [
111
+ { name: 'A name for value', value: 'This value will be visible during payment process on Mandarin page and return in callback' },
112
+ { name: 'Another value name', value: 'another value' }
113
+ ]
112
114
  }
113
115
  ```
114
116
  `#charge` will return a hash.
@@ -34,9 +34,9 @@ module MandarinApi
34
34
  def normal_request_body(params, action)
35
35
  body = {
36
36
  payment: payment(params, action),
37
- target: { card: params[:assigned_card_uuid] },
37
+ target: { card: params[:assigned_card_uuid] }
38
38
  }
39
- body[:extra] = systemize(params[:extra]) unless params[:extra].empty?
39
+ body[:custom_values] = params[:custom_values] unless params[:custom_values].empty?
40
40
  body
41
41
  end
42
42
 
@@ -45,9 +45,8 @@ module MandarinApi
45
45
  payment: payment(params, action),
46
46
  customer_info: { email: params[:email], phone: phone(params[:phone]) }
47
47
  }
48
- body[:custom_values] = systemize(params[:custom_values]) if params[:custom_values]
48
+ body[:custom_values] = params[:custom_values] if params[:custom_values]
49
49
  body[:urls] = params[:urls] if params[:urls]
50
- body[:extra] = systemize(params[:extra]) if params[:extra]
51
50
  body
52
51
  end
53
52
 
@@ -69,14 +68,6 @@ module MandarinApi
69
68
  { order_id: params[:order_id], action: action, price: params[:amount] }
70
69
  end
71
70
 
72
- def systemize(options)
73
- result = []
74
- options.each do |key, value|
75
- result << { name: key.to_s, value: value }
76
- end
77
- result
78
- end
79
-
80
71
  def phone(phone)
81
72
  if phone.nil?
82
73
  '+70000000000'
data/lib/mandarin_api.rb CHANGED
@@ -16,24 +16,23 @@ module MandarinApi
16
16
  def self.charge(order_id, amount, user, extra = {})
17
17
  params = {
18
18
  order_id: order_id, amount: amount, email: user.email, phone: user.phone,
19
- urls: extra[:urls], custom_values: extra[:visible],
20
- extra: extra[:invisible]
19
+ urls: extra[:urls], custom_values: extra[:custom_values]
21
20
  }
22
21
  MandarinApi::PaymentManager.new.perform_charge params
23
22
  end
24
23
 
25
- def self.pay(order_id, amount, assigned_card_uuid, extra = {})
24
+ def self.pay(order_id, amount, assigned_card_uuid, custom_values = [])
26
25
  params = {
27
- order_id: order_id, amount: amount, extra: extra,
26
+ order_id: order_id, amount: amount, custom_values: custom_values,
28
27
  assigned_card_uuid: assigned_card_uuid
29
28
  }
30
29
  MandarinApi::PaymentManager.new.perform_payment params
31
30
  end
32
31
 
33
- def self.payout(order_id, amount, assigned_card_uuid, extra = {})
32
+ def self.payout(order_id, amount, assigned_card_uuid, custom_values = [])
34
33
  params = {
35
34
  order_id: order_id, amount: amount,
36
- assigned_card_uuid: assigned_card_uuid, extra: extra
35
+ assigned_card_uuid: assigned_card_uuid, custom_values: custom_values
37
36
  }
38
37
  MandarinApi::PaymentManager.new.perform_payout params
39
38
  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.2.0'
4
+ s.version = '0.2.1'
5
5
  s.authors = ['Vladimir Bogaevsky']
6
6
  s.email = 'gitvbogaevsky@gmail.com'
7
7
  s.licenses = ['MIT']
@@ -7,14 +7,14 @@ RSpec.describe MandarinApi::PaymentManager do
7
7
  {
8
8
  order_id: 123_321, amount: 35_000,
9
9
  assigned_card_uuid: '0eb51e74-e704-4c36-b5cb-8f0227621518',
10
- extra: { a: 'A', b: 'B' }
10
+ custom_values: [{ name: 'a', value: 'A'}, { name: 'b', value: 'B' }]
11
11
  }
12
12
  end
13
13
  let(:normal_request_body) do
14
14
  {
15
15
  payment: { order_id: 123_321, action: action, price: 35_000 },
16
16
  target: { card: '0eb51e74-e704-4c36-b5cb-8f0227621518' },
17
- extra: [{ name: 'a', value: 'A' }, { name: 'b', value: 'B' }]
17
+ custom_values: [{ name: 'a', value: 'A'}, { name: 'b', value: 'B' }]
18
18
  }
19
19
  end
20
20
  let(:charge_request_body) do
@@ -22,7 +22,6 @@ RSpec.describe MandarinApi::PaymentManager do
22
22
  payment: { order_id: 123_321, action: action, price: 35_000 },
23
23
  customer_info: { email: email, phone: phone },
24
24
  custom_values: [{ name: 'a', value: 'A'}, { name: 'b', value: 'B' }],
25
- extra: [{ name: 'one', value: 'One'}, { name: 'two', value: 'Two' }],
26
25
  urls: { callback: 'callback', return: 'return' }
27
26
  }
28
27
  end
@@ -34,7 +33,7 @@ RSpec.describe MandarinApi::PaymentManager do
34
33
  let(:params) do
35
34
  {
36
35
  order_id: 123_321, amount: 35_000, email: email, phone: phone,
37
- custom_values: { a: 'A', b: 'B' }, extra: { one: 'One', two: 'Two' },
36
+ custom_values: [{ name: 'a', value: 'A'}, { name: 'b', value: 'B' }],
38
37
  urls: { callback: 'callback', return: 'return' }
39
38
  }
40
39
  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.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Bogaevsky