nihaopay-ruby 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: b7b4c64acc91099c56a7c9aa62ead290eeeb578b
4
- data.tar.gz: d93246938e0dcfda73a733ea91ab71acb94a0be8
3
+ metadata.gz: 5c51db6e7eb5d095fc84393b22004416a765ca3a
4
+ data.tar.gz: 3c81b8f3620533c0b9143f5b93f1986cac3f6b72
5
5
  SHA512:
6
- metadata.gz: cd977863d45dadb49ea0a0035a32835cd28533e40931d68df91cc4a9ff9677e1c5a129e0c333a3308575ca48d493fce93fd935e08b63bbe92e1e95dba2093c2a
7
- data.tar.gz: d90b8510e72895eb4864f4e04c2066fa4db41dab443834a5202ce89b99cf0d7d57f7c6c84d07808c28be995128779969993d9971cf01de60400e13b05623a144
6
+ metadata.gz: d549e0b6fe92e697f5d692469fccc17aec27ae44d7cb8b170af90a967af81f62f8f60ee84ae0257432de93f4bcd5099a9caa85a2ea88d30894c3de7989bdf050
7
+ data.tar.gz: 71b909b6ca9e42f1a73c9a5b6c87b7afe3027f4a88e27ee395672fe0198d77ff5596382288cb3a64a708412295af72b8292379936f7f35ef61c50af37b5419e9
data/CHANGELOG.md CHANGED
@@ -1,17 +1,26 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Upcoming
4
+
5
+ * Your changes here
6
+
7
+ ## 0.2.2
8
+
9
+ * API Update: Support client IP to be passed in ExpressPay transactions ([@JagdeepSingh](https://github.com/JagdeepSingh))
10
+ * Rubocop: Upgrade percent array literal syntax to use brackets ([@johnnyshields](https://github.com/johnnyshields))
11
+
3
12
  ## 0.2.1
4
13
 
5
- * API Addition: Allow sub_mid parameter (@JagdeepSingh)
14
+ * API Addition: Allow sub_mid parameter ([@JagdeepSingh](https://github.com/JagdeepSingh))
6
15
 
7
16
  ## 0.2.0
8
17
 
9
- * API Change: Time should be returned as a Ruby time object (@JagdeepSingh)
18
+ * API Change: Time should be returned as a Ruby time object ([@JagdeepSingh](https://github.com/JagdeepSingh))
10
19
 
11
20
  ## 0.1.1
12
21
 
13
- * Bug Fix: Add time to Nihaopay response if not present (@JagdeepSingh)
22
+ * Bug Fix: Add time to Nihaopay response if not present ([@JagdeepSingh](https://github.com/JagdeepSingh))
14
23
 
15
24
  ## 0.1.0
16
25
 
17
- * Initial release (@JagdeepSingh)
26
+ * Initial release ([@JagdeepSingh](https://github.com/JagdeepSingh))
data/README.md CHANGED
@@ -134,9 +134,11 @@ Acceptable values for `expiry_month` are `01` through `12`.
134
134
  Now initiate the transaction using above credit card.
135
135
 
136
136
  ```ruby
137
- express_pay = Nihaopay::Transactions::Authorize.start(amount, credit_card)
137
+ express_pay = Nihaopay::Transactions::Authorize.start(amount, credit_card, client_ip: '192.x.x.x')
138
138
  ```
139
139
 
140
+ NOTE: `client_ip` is a required parameter and replace its value with actual IP address.
141
+
140
142
  This returns an instance of `Nihaopay::Transactions::ExpressPay` on which you can access following methods:
141
143
 
142
144
  ```ruby
@@ -154,7 +156,7 @@ Other methods available are `note` and `time`.
154
156
  #### Purchase transaction on ExpressPay
155
157
 
156
158
  ```ruby
157
- express_pay = Nihaopay::Transactions::Purchase.start(amount, credit_card)
159
+ express_pay = Nihaopay::Transactions::Purchase.start(amount, credit_card, client_ip: '192.x.x.x')
158
160
  ```
159
161
 
160
162
  This again returns an instance of `Nihaopay::Transactions::ExpressPay`.
@@ -164,7 +166,8 @@ This again returns an instance of `Nihaopay::Transactions::ExpressPay`.
164
166
  For `authorize` and `purchase`, you can pass `currency`, `description`, `note`, and `reference` as options.
165
167
 
166
168
  ```ruby
167
- express_pay = Nihaopay::Transactions::Authorize.start(amount, credit_card, { currency: 'USD',
169
+ express_pay = Nihaopay::Transactions::Authorize.start(amount, credit_card, { client_ip: '192.x.x.x', # Required
170
+ currency: 'JPY',
168
171
  description: 'Your order description',
169
172
  note: 'Something to remember',
170
173
  reference: 'A unique alphanumeric string',
@@ -327,10 +330,10 @@ express_pay = nihaopay_merchant.authorize(amount, credit_card)
327
330
  OR
328
331
 
329
332
  ```ruby
330
- express_pay = nihaopay_merchant.authorize(amount, credit_card, options)
333
+ express_pay = nihaopay_merchant.authorize(amount, credit_card, client_ip: '192.x.x.x')
331
334
  ```
332
335
 
333
- `options` may include `currency`, `description`, `reference`, `note`, and `sub_mid`.
336
+ Other options include `currency`, `description`, `reference`, `note`, and `sub_mid`.
334
337
 
335
338
  Similarly, you can do other transactions directly on `Nihaopay::Merchant` object:
336
339
 
@@ -339,8 +342,7 @@ Similarly, you can do other transactions directly on `Nihaopay::Merchant` object
339
342
  express_pay = nihaopay_merchant.capture(transaction_id, amount, currency)
340
343
 
341
344
  # purchase
342
- express_pay = nihaopay_merchant.purchase(amount, credit_card)
343
- express_pay = nihaopay_merchant.purchase(amount, credit_card, options)
345
+ express_pay = nihaopay_merchant.purchase(amount, credit_card, client_ip: '192.x.x.x')
344
346
 
345
347
  # release
346
348
  express_pay = nihaopay_merchant.release(transaction_id)
@@ -1,6 +1,6 @@
1
1
  module Nihaopay
2
2
  class CreditCard
3
- ATTRIBUTES = %i(number expiry_year expiry_month cvv).freeze
3
+ ATTRIBUTES = %i[number expiry_year expiry_month cvv].freeze
4
4
 
5
5
  attr_accessor(*ATTRIBUTES)
6
6
 
@@ -2,7 +2,7 @@ module Nihaopay
2
2
  class Query
3
3
  include ::Nihaopay::Api
4
4
 
5
- VALID_OPTIONS = %i(limit starting_after ending_before).freeze
5
+ VALID_OPTIONS = %i[limit starting_after ending_before].freeze
6
6
 
7
7
  def limit(num)
8
8
  @limit = num
@@ -26,7 +26,7 @@ module Nihaopay
26
26
  end
27
27
 
28
28
  def valid_options
29
- %i(currency description note reference)
29
+ %i[currency description note reference client_ip].freeze
30
30
  end
31
31
 
32
32
  def capture_param
@@ -61,7 +61,7 @@ module Nihaopay
61
61
  end
62
62
 
63
63
  def valid_attributes
64
- %i(token transaction_id type status captured currency reference amount note time)
64
+ %i[token transaction_id type status captured currency reference amount note time].freeze
65
65
  end
66
66
 
67
67
  def response_keys_map
@@ -21,7 +21,7 @@ module Nihaopay
21
21
  end
22
22
 
23
23
  def valid_attributes
24
- %i(transaction_id status cancelled cancel_transaction_id time)
24
+ %i[transaction_id status cancelled cancel_transaction_id time].freeze
25
25
  end
26
26
 
27
27
  def response_keys_map
@@ -23,11 +23,11 @@ module Nihaopay
23
23
  end
24
24
 
25
25
  def valid_options
26
- %i(amount currency)
26
+ %i[amount currency].freeze
27
27
  end
28
28
 
29
29
  def valid_attributes
30
- %i(transaction_id status captured capture_transaction_id time)
30
+ %i[transaction_id status captured capture_transaction_id time].freeze
31
31
  end
32
32
 
33
33
  def response_keys_map
@@ -9,11 +9,11 @@ module Nihaopay
9
9
  end
10
10
 
11
11
  def valid_options
12
- super | %i(reason)
12
+ (super | %i[reason]).freeze
13
13
  end
14
14
 
15
15
  def valid_attributes
16
- %i(transaction_id status refunded refund_transaction_id time)
16
+ %i[transaction_id status refunded refund_transaction_id time].freeze
17
17
  end
18
18
 
19
19
  def response_keys_map
@@ -9,7 +9,7 @@ module Nihaopay
9
9
  end
10
10
 
11
11
  def valid_attributes
12
- %i(transaction_id status released release_transaction_id time)
12
+ %i[transaction_id status released release_transaction_id time].freeze
13
13
  end
14
14
 
15
15
  def response_keys_map
@@ -1,3 +1,3 @@
1
1
  module Nihaopay
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
@@ -29,23 +29,25 @@ describe Nihaopay::Transactions::Authorize do
29
29
  'captured' => false }
30
30
  end
31
31
 
32
- context 'without options' do
32
+ context 'with client_ip' do
33
33
  let(:body) do
34
34
  'card_number=6221558812340000'\
35
35
  '&card_exp_year=17'\
36
36
  '&card_exp_month=11'\
37
37
  '&card_cvv=123'\
38
+ '&client_ip=192.168.0.1'\
38
39
  '&capture=false'\
39
40
  '&amount=1000'\
40
41
  '&currency=USD'
41
42
  end
42
43
  it { expect(HTTParty).to receive(:post).with(url, headers: headers, body: body) }
43
- after { described_class.start(1000, cc) }
44
+ after { described_class.start(1000, cc, client_ip: '192.168.0.1') }
44
45
  end
45
46
 
46
- context 'with options' do
47
+ context 'with other options' do
47
48
  let(:options) do
48
- { currency: 'USD',
49
+ { client_ip: '192.168.0.1',
50
+ currency: 'USD',
49
51
  description: 'Lorem ipsum',
50
52
  note: 'To self',
51
53
  reference: '111111' }
@@ -59,6 +61,7 @@ describe Nihaopay::Transactions::Authorize do
59
61
  '&description=Lorem ipsum'\
60
62
  '&note=To self'\
61
63
  '&reference=111111'\
64
+ '&client_ip=192.168.0.1'\
62
65
  '&capture=false'\
63
66
  '&amount=1000'
64
67
  end
@@ -67,12 +70,13 @@ describe Nihaopay::Transactions::Authorize do
67
70
  end
68
71
 
69
72
  context 'with invalid options' do
70
- let(:options) { { foo: :bar } }
73
+ let(:options) { { client_ip: '192.168.0.1', foo: :bar } }
71
74
  let(:body) do
72
75
  'card_number=6221558812340000'\
73
76
  '&card_exp_year=17'\
74
77
  '&card_exp_month=11'\
75
78
  '&card_cvv=123'\
79
+ '&client_ip=192.168.0.1'\
76
80
  '&capture=false'\
77
81
  '&amount=1000'\
78
82
  '&currency=USD'
@@ -82,7 +86,7 @@ describe Nihaopay::Transactions::Authorize do
82
86
  end
83
87
 
84
88
  context 'with :token in options' do
85
- let(:options) { { token: 'ec471780ad1' } }
89
+ let(:options) { { client_ip: '192.168.0.1', token: 'ec471780ad1' } }
86
90
  let(:headers) do
87
91
  { 'Authorization' => 'Bearer ec471780ad1',
88
92
  'Content-Type' => 'application/x-www-form-urlencoded' }
@@ -92,6 +96,7 @@ describe Nihaopay::Transactions::Authorize do
92
96
  '&card_exp_year=17'\
93
97
  '&card_exp_month=11'\
94
98
  '&card_cvv=123'\
99
+ '&client_ip=192.168.0.1'\
95
100
  '&capture=false'\
96
101
  '&amount=1000'\
97
102
  '&currency=USD'
@@ -104,12 +109,13 @@ describe Nihaopay::Transactions::Authorize do
104
109
  end
105
110
 
106
111
  context 'with :sub_mid in options' do
107
- let(:options) { { sub_mid: 'foobar' } }
112
+ let(:options) { { client_ip: '192.168.0.1', sub_mid: 'foobar' } }
108
113
  let(:body) do
109
114
  'card_number=6221558812340000'\
110
115
  '&card_exp_year=17'\
111
116
  '&card_exp_month=11'\
112
117
  '&card_cvv=123'\
118
+ '&client_ip=192.168.0.1'\
113
119
  '&capture=false'\
114
120
  '&amount=1000'\
115
121
  '&reserved={"sub_mid":"foobar"}'\
@@ -121,7 +127,7 @@ describe Nihaopay::Transactions::Authorize do
121
127
 
122
128
  describe '.build_from_response!' do
123
129
  it 'should return transaction object' do
124
- txn = described_class.start(1000, cc)
130
+ txn = described_class.start(1000, cc, client_ip: '192.168.0.1')
125
131
  expect(txn).to be_a Nihaopay::Transactions::Base
126
132
  expect(txn.transaction_id).to eq '20160714132438002485'
127
133
  expect(txn.status).to eq 'success'
@@ -185,7 +185,7 @@ describe Nihaopay::Transactions::Base do
185
185
 
186
186
  describe '.valid_attributes' do
187
187
  let(:expectation) do
188
- %i(token transaction_id type status captured currency reference amount note time)
188
+ %i[token transaction_id type status captured currency reference amount note time]
189
189
  end
190
190
  it { expect(described_class.valid_attributes).to eq expectation }
191
191
  end
@@ -72,7 +72,7 @@ describe Nihaopay::Transactions::Cancel do
72
72
  end
73
73
 
74
74
  describe '.valid_attributes' do
75
- let(:expectation) { %i(transaction_id status cancelled cancel_transaction_id time) }
75
+ let(:expectation) { %i[transaction_id status cancelled cancel_transaction_id time] }
76
76
  it { expect(described_class.valid_attributes).to eq expectation }
77
77
  end
78
78
 
@@ -81,7 +81,7 @@ describe Nihaopay::Transactions::Capture do
81
81
  end
82
82
 
83
83
  describe '.valid_attributes' do
84
- let(:expectation) { %i(transaction_id status captured capture_transaction_id time) }
84
+ let(:expectation) { %i[transaction_id status captured capture_transaction_id time] }
85
85
  it { expect(described_class.valid_attributes).to eq expectation }
86
86
  end
87
87
 
@@ -87,7 +87,7 @@ describe Nihaopay::Transactions::Refund do
87
87
  end
88
88
 
89
89
  describe '.valid_attributes' do
90
- let(:expectation) { %i(transaction_id status refunded refund_transaction_id time) }
90
+ let(:expectation) { %i[transaction_id status refunded refund_transaction_id time] }
91
91
  it { expect(described_class.valid_attributes).to eq expectation }
92
92
  end
93
93
 
@@ -72,7 +72,7 @@ describe Nihaopay::Transactions::Release do
72
72
  end
73
73
 
74
74
  describe '.valid_attributes' do
75
- let(:expectation) { %i(transaction_id status released release_transaction_id time) }
75
+ let(:expectation) { %i[transaction_id status released release_transaction_id time] }
76
76
  it { expect(described_class.valid_attributes).to eq expectation }
77
77
  end
78
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nihaopay-ruby
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
  - JagdeepSingh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-30 00:00:00.000000000 Z
12
+ date: 2017-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: '0.48'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: '0.48'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec
86
86
  requirement: !ruby/object:Gem::Requirement