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 +4 -4
- data/CHANGELOG.md +13 -4
- data/README.md +9 -7
- data/lib/nihaopay/credit_card.rb +1 -1
- data/lib/nihaopay/query.rb +1 -1
- data/lib/nihaopay/transactions/authorize.rb +1 -1
- data/lib/nihaopay/transactions/base.rb +1 -1
- data/lib/nihaopay/transactions/cancel.rb +1 -1
- data/lib/nihaopay/transactions/capture.rb +2 -2
- data/lib/nihaopay/transactions/refund.rb +2 -2
- data/lib/nihaopay/transactions/release.rb +1 -1
- data/lib/nihaopay/version.rb +1 -1
- data/spec/transactions/authorize_spec.rb +14 -8
- data/spec/transactions/base_spec.rb +1 -1
- data/spec/transactions/cancel_spec.rb +1 -1
- data/spec/transactions/capture_spec.rb +1 -1
- data/spec/transactions/refund_spec.rb +1 -1
- data/spec/transactions/release_spec.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c51db6e7eb5d095fc84393b22004416a765ca3a
|
4
|
+
data.tar.gz: 3c81b8f3620533c0b9143f5b93f1986cac3f6b72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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, {
|
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,
|
333
|
+
express_pay = nihaopay_merchant.authorize(amount, credit_card, client_ip: '192.x.x.x')
|
331
334
|
```
|
332
335
|
|
333
|
-
|
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)
|
data/lib/nihaopay/credit_card.rb
CHANGED
data/lib/nihaopay/query.rb
CHANGED
@@ -61,7 +61,7 @@ module Nihaopay
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def valid_attributes
|
64
|
-
%i
|
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
|
@@ -23,11 +23,11 @@ module Nihaopay
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def valid_options
|
26
|
-
%i
|
26
|
+
%i[amount currency].freeze
|
27
27
|
end
|
28
28
|
|
29
29
|
def valid_attributes
|
30
|
-
%i
|
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
|
12
|
+
(super | %i[reason]).freeze
|
13
13
|
end
|
14
14
|
|
15
15
|
def valid_attributes
|
16
|
-
%i
|
16
|
+
%i[transaction_id status refunded refund_transaction_id time].freeze
|
17
17
|
end
|
18
18
|
|
19
19
|
def response_keys_map
|
data/lib/nihaopay/version.rb
CHANGED
@@ -29,23 +29,25 @@ describe Nihaopay::Transactions::Authorize do
|
|
29
29
|
'captured' => false }
|
30
30
|
end
|
31
31
|
|
32
|
-
context '
|
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
|
'¤cy=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
|
-
{
|
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
|
'¬e=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
|
'¤cy=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
|
'¤cy=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
|
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
|
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
|
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
|
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
|
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.
|
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-
|
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
|