nihaopay-ruby 0.1.0 → 0.1.1

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: 8766c2c6e2a61b1ac8c0cd497e8fe871cc0d34c6
4
- data.tar.gz: 08aaa9b825ad38032cc436061e09b2d0d3a476db
3
+ metadata.gz: 793d37f1e49e2b37efecb06a13c62cac1e2ddacf
4
+ data.tar.gz: 7cbd9cde59ba17ce779fc907e640d9181fa40372
5
5
  SHA512:
6
- metadata.gz: 980bd29de13afa1d13b0664e5a52f1e2ad6df160900031a402691b832780e2ea8abf59f03fd78dd9828893411f7ffdf3befc15dc72a7408a0ab8d2f27faf36e9
7
- data.tar.gz: a818aa490245aa0f9a71ff32c9f667cc14017380d077ccb66cdb9878da19a35129a22293243545c683663a3c8f805e70f35ae3467582fbcb3f4c191549b8dfc3
6
+ metadata.gz: 21b972bb2b50c3c762318dddc4031c8e86fb37bfa9047f0e8a2682b3fff02c9c2af597634fde833e1dda50cde933a0bea9bc84014759006633b02ffec195adce
7
+ data.tar.gz: 00947d8dbe1f6277928fc7b3ffcc40b00dd8af5222d3ae9f3cdade7aeb1db4ece12485b729e34015a5dfde2d1d7b00c3e52fa636af589c2c14263a5a6869cfa3
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.1
4
+
5
+ * Bug Fix: Add time to Nihaopay response if not present (@JagdeepSingh)
6
+
3
7
  ## 0.1.0
4
8
 
5
9
  * Initial release (@JagdeepSingh)
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
@@ -16,7 +16,7 @@ module Nihaopay
16
16
  end
17
17
 
18
18
  def valid_attributes
19
- %i(transaction_id status cancelled cancel_transaction_id)
19
+ %i(transaction_id status cancelled cancel_transaction_id time)
20
20
  end
21
21
 
22
22
  def response_keys_map
@@ -17,7 +17,7 @@ module Nihaopay
17
17
  end
18
18
 
19
19
  def valid_attributes
20
- %i(transaction_id status captured capture_transaction_id)
20
+ %i(transaction_id status captured capture_transaction_id time)
21
21
  end
22
22
 
23
23
  def response_keys_map
@@ -19,7 +19,7 @@ module Nihaopay
19
19
  end
20
20
 
21
21
  def valid_attributes
22
- %i(transaction_id status refunded refund_transaction_id)
22
+ %i(transaction_id status refunded refund_transaction_id time)
23
23
  end
24
24
 
25
25
  def response_keys_map
@@ -16,7 +16,7 @@ module Nihaopay
16
16
  end
17
17
 
18
18
  def valid_attributes
19
- %i(transaction_id status released release_transaction_id)
19
+ %i(transaction_id status released release_transaction_id time)
20
20
  end
21
21
 
22
22
  def response_keys_map
@@ -1,3 +1,3 @@
1
1
  module Nihaopay
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
@@ -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(Nihaopay::TransactionError) }
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(Nihaopay::TransactionError) }
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.0
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: 2016-11-22 00:00:00.000000000 Z
12
+ date: 2017-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty