nihaopay-ruby 0.1.0 → 0.1.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/CHANGELOG.md +4 -0
- data/README.md +5 -0
- data/lib/nihaopay/transactions/base.rb +3 -0
- data/lib/nihaopay/transactions/cancel.rb +1 -1
- data/lib/nihaopay/transactions/capture.rb +1 -1
- data/lib/nihaopay/transactions/refund.rb +1 -1
- data/lib/nihaopay/transactions/release.rb +1 -1
- data/lib/nihaopay/version.rb +1 -1
- data/spec/mixins/api_spec.rb +2 -2
- data/spec/transactions/base_spec.rb +12 -0
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 793d37f1e49e2b37efecb06a13c62cac1e2ddacf
|
4
|
+
data.tar.gz: 7cbd9cde59ba17ce779fc907e640d9181fa40372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21b972bb2b50c3c762318dddc4031c8e86fb37bfa9047f0e8a2682b3fff02c9c2af597634fde833e1dda50cde933a0bea9bc84014759006633b02ffec195adce
|
7
|
+
data.tar.gz: 00947d8dbe1f6277928fc7b3ffcc40b00dd8af5222d3ae9f3cdade7aeb1db4ece12485b729e34015a5dfde2d1d7b00c3e52fa636af589c2c14263a5a6869cfa3
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -146,6 +146,7 @@ express_pay.reference # => "3461fcc31aec471780ad1a4dc6111947"
|
|
146
146
|
express_pay.currency # => "JPY"
|
147
147
|
express_pay.amount # => 1000
|
148
148
|
express_pay.captured # => false
|
149
|
+
express_pay.time # => "2017-01-17T17:51:00+0900"
|
149
150
|
```
|
150
151
|
|
151
152
|
Other methods available are `note` and `time`.
|
@@ -179,6 +180,7 @@ captured.transaction_id # => "20160718111604002633"
|
|
179
180
|
captured.status # => "success"
|
180
181
|
captured.captured # => true
|
181
182
|
captured.capture_transaction_id # => "20160718111529002632" (id of the transaction that was captured)
|
183
|
+
captured.time # => "2017-01-17T17:51:00+0900"
|
182
184
|
```
|
183
185
|
|
184
186
|
If you want to capture a partial amount, you can do:
|
@@ -199,6 +201,7 @@ released.transaction_id # => "20160718111604002633"
|
|
199
201
|
released.status # => "success"
|
200
202
|
released.released # => true
|
201
203
|
released.release_transaction_id # => "20160718111529002632" (id of the transaction that was released)
|
204
|
+
released.time # => "2017-01-17T17:51:00+0900"
|
202
205
|
```
|
203
206
|
|
204
207
|
#### Cancel a transaction
|
@@ -209,6 +212,7 @@ cancelled.transaction_id # => "20160718111604002633"
|
|
209
212
|
cancelled.status # => "success"
|
210
213
|
cancelled.cancelled # => true
|
211
214
|
cancelled.cancel_transaction_id # => "20160718111529002632" (id of the transaction that was cancelled)
|
215
|
+
cancelled.time # => "2017-01-17T17:51:00+0900"
|
212
216
|
```
|
213
217
|
|
214
218
|
Transactions can only be cancelled before the daily settlement deadline. Transactions cannot be cancelled if a partial or full refund on the transaction has already been issued.
|
@@ -285,6 +289,7 @@ refunded.transaction_id # => "20160718111604002633"
|
|
285
289
|
refunded.status # => "success"
|
286
290
|
refunded.refunded # => true
|
287
291
|
refunded.refund_transaction_id # => "20160718111529002632" (id of the transaction that was refunded)
|
292
|
+
refunded.time # => "2017-01-17T17:51:00+0900"
|
288
293
|
```
|
289
294
|
|
290
295
|
You can pass a `reason` when refunding a transaction:
|
@@ -4,6 +4,8 @@ module Nihaopay
|
|
4
4
|
include ::Nihaopay::Api
|
5
5
|
include ::Nihaopay::Queryable
|
6
6
|
|
7
|
+
TIME_FORMAT = '%Y-%m-%dT%H:%M:%S%z'.freeze
|
8
|
+
|
7
9
|
attr_accessor :token, :transaction_id, :type, :status
|
8
10
|
attr_accessor :captured, :reference, :currency, :amount, :note, :time
|
9
11
|
|
@@ -55,6 +57,7 @@ module Nihaopay
|
|
55
57
|
options = Nihaopay::HashUtil.symbolize_keys(options)
|
56
58
|
attributes = Nihaopay::HashUtil.slice(options, *valid_attributes)
|
57
59
|
attributes[:token] ||= merchant_token
|
60
|
+
attributes[:time] ||= Time.now.strftime(TIME_FORMAT)
|
58
61
|
response_keys_map.each { |k, v| attributes[v] = options[k] }
|
59
62
|
new(attributes)
|
60
63
|
end
|
data/lib/nihaopay/version.rb
CHANGED
data/spec/mixins/api_spec.rb
CHANGED
@@ -58,7 +58,7 @@ describe Nihaopay::Api do
|
|
58
58
|
|
59
59
|
context 'when parsed_response contains :id' do
|
60
60
|
let(:parsed_response) { { 'id' => '20160714132438002485', 'code' => 200 } }
|
61
|
-
it { expect { ApiTest.validate_resource!(response) }.to_not raise_error
|
61
|
+
it { expect { ApiTest.validate_resource!(response) }.to_not raise_error }
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -74,7 +74,7 @@ describe Nihaopay::Api do
|
|
74
74
|
|
75
75
|
context 'when parsed_response contains :transactions' do
|
76
76
|
let(:parsed_response) { { 'transactions' => [{ 'id' => '20160714132438002485', 'code' => 200 }] } }
|
77
|
-
it { expect { ApiTest.validate_collection!(response) }.to_not raise_error
|
77
|
+
it { expect { ApiTest.validate_collection!(response) }.to_not raise_error }
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -142,6 +142,7 @@ describe Nihaopay::Transactions::Base do
|
|
142
142
|
it { expect(subject.transaction_id).to eq '123456' }
|
143
143
|
it { expect(subject.token).to eq 'merchanttoken2' }
|
144
144
|
it { expect(subject.captured).to be true }
|
145
|
+
it { expect(subject.time).to eq '2016-06-01T01:00:00Z' }
|
145
146
|
end
|
146
147
|
|
147
148
|
context 'with options with string keys' do
|
@@ -168,6 +169,17 @@ describe Nihaopay::Transactions::Base do
|
|
168
169
|
it { is_expected.to be_a Nihaopay::Transactions::Base }
|
169
170
|
it { expect(subject.token).to eq 'merchanttoken1' }
|
170
171
|
end
|
172
|
+
|
173
|
+
context 'when time not returned in response' do
|
174
|
+
let(:options) do
|
175
|
+
opts = attrs.merge(id: '123456')
|
176
|
+
opts.delete(:time)
|
177
|
+
opts
|
178
|
+
end
|
179
|
+
before { allow(Time).to receive_message_chain(:now, :strftime) { '2017-01-17T16:00:00+0900' } }
|
180
|
+
subject { described_class.build(options) }
|
181
|
+
it { expect(subject.time).to eq '2017-01-17T16:00:00+0900' }
|
182
|
+
end
|
171
183
|
end
|
172
184
|
|
173
185
|
describe '.valid_attributes' do
|
@@ -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) }
|
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
|
|
@@ -74,7 +74,7 @@ describe Nihaopay::Transactions::Capture do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe '.valid_attributes' do
|
77
|
-
let(:expectation) { %i(transaction_id status captured capture_transaction_id) }
|
77
|
+
let(:expectation) { %i(transaction_id status captured capture_transaction_id time) }
|
78
78
|
it { expect(described_class.valid_attributes).to eq expectation }
|
79
79
|
end
|
80
80
|
|
@@ -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) }
|
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) }
|
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.1.
|
4
|
+
version: 0.1.1
|
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:
|
12
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|