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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -4
- data/lib/mandarin_api/payment_manager.rb +3 -12
- data/lib/mandarin_api.rb +5 -6
- data/mandarin-api.gemspec +1 -1
- data/spec/lib/mandarin_api/payment_manager_spec.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d8c32b764a06d6f92e22c34b1d0fb9c4f83da00
|
4
|
+
data.tar.gz: 45cf6c66143f1d691ef20293f4d91ba2f27585c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df00ea5909bad4ab9028976ba2cd0a1cdc84657ee67a49cce9a709997a8097054626fd80ba4b3ea0a252ed5c5297b68505a69994ed2f6f9a09fc7ce7a14fbb23
|
7
|
+
data.tar.gz: da75dc387ff5c3271c16b24303498dfd6035beb6c64f657bfddbe6b7d5eb86298a63dac89ccd9f8adb43ed92133fb52c2d1aa651e605daabe08dc3476d8b6d19
|
data/Gemfile.lock
CHANGED
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
|
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
|
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
|
-
|
111
|
-
|
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[:
|
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] =
|
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[:
|
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,
|
24
|
+
def self.pay(order_id, amount, assigned_card_uuid, custom_values = [])
|
26
25
|
params = {
|
27
|
-
order_id: order_id, amount: amount,
|
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,
|
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,
|
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
@@ -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
|
-
|
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
|
-
|
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: {
|
36
|
+
custom_values: [{ name: 'a', value: 'A'}, { name: 'b', value: 'B' }],
|
38
37
|
urls: { callback: 'callback', return: 'return' }
|
39
38
|
}
|
40
39
|
end
|