mollie-api-ruby 4.1.1 → 4.1.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
  SHA256:
3
- metadata.gz: fa48b8e1742ed446122f9e2bdc0d883de6d1204af8d535a6b108a1235ab6da6c
4
- data.tar.gz: 05dae67cfb92ee8cbae92f78a7d2cc41b91a3bda95a591bd515239ea3a37c2ee
3
+ metadata.gz: e7b56045be6251dae1feef223df7cb6fde128a7e0dbfba0644e8dfce52b0b461
4
+ data.tar.gz: 31f3621caaaab1d414349d5e431d90802698b8405e2f3ffc1afe1c1fe6b361cf
5
5
  SHA512:
6
- metadata.gz: 442d9f9d45013c5ef1cbc03096e90d0cf78a4a92e116687bab282432c342e83d64b47eb120d2909181f62562fe23ec2004ced9968f72f8d2078c0c02323cb341
7
- data.tar.gz: c5179a4a28677bf31b8a129e20e76298b1536d97146723ab88337d32e659a00e2f63a40e5e0f00b37c2b576cd3258691161e0e0230a3517f3bc8ed728a31ad22
6
+ metadata.gz: cb8cc9bdbbcb699b85b14c86750a3cc8cd7ea4e5182a31c57917f334c8f3ea982773bb443d1a20b4a38f5c5355aa85f88db45bf74fa2b98042dbb409311342cf
7
+ data.tar.gz: aa386b489ebf28c44851d6b6517fb0a2ebc1666af242acc01ce379f7e1f104fda68668b45ce4285662c3296837b433db263932a53f9b5d74479b91f7d0ffcf07
@@ -14,9 +14,12 @@ module Mollie
14
14
  :status,
15
15
  :amount,
16
16
  :times,
17
+ :times_remaining,
17
18
  :interval,
19
+ :next_payment_date,
18
20
  :description,
19
21
  :method,
22
+ :mandate_id,
20
23
  :canceled_at,
21
24
  :webhook_url
22
25
 
@@ -64,6 +67,14 @@ module Mollie
64
67
  @times = times.to_i
65
68
  end
66
69
 
70
+ def next_payment_date=(next_payment_date)
71
+ @next_payment_date = begin
72
+ Date.parse(next_payment_date)
73
+ rescue StandardError
74
+ nil
75
+ end
76
+ end
77
+
67
78
  def customer(options = {})
68
79
  Customer.get(customer_id, options)
69
80
  end
@@ -16,6 +16,7 @@ module Mollie
16
16
  :mode,
17
17
  :created_at,
18
18
  :status,
19
+ :authorized_at,
19
20
  :paid_at,
20
21
  :is_cancelable,
21
22
  :canceled_at,
@@ -23,6 +24,7 @@ module Mollie
23
24
  :expires_at,
24
25
  :failed_at,
25
26
  :amount,
27
+ :amount_captured,
26
28
  :amount_refunded,
27
29
  :amount_remaining,
28
30
  :description,
@@ -74,6 +76,14 @@ module Mollie
74
76
  status == STATUS_AUTHORIZED
75
77
  end
76
78
 
79
+ def refunded?
80
+ if amount_refunded
81
+ amount_refunded.value > 0
82
+ else
83
+ false
84
+ end
85
+ end
86
+
77
87
  def cancelable?
78
88
  is_cancelable
79
89
  end
@@ -104,6 +114,14 @@ module Mollie
104
114
  end
105
115
  end
106
116
 
117
+ def authorized_at=(authorized_at)
118
+ @authorized_at = begin
119
+ Time.parse(authorized_at.to_s)
120
+ rescue StandardError
121
+ nil
122
+ end
123
+ end
124
+
107
125
  def paid_at=(paid_at)
108
126
  @paid_at = begin
109
127
  Time.parse(paid_at.to_s)
@@ -148,6 +166,10 @@ module Mollie
148
166
  @settlement_amount = Mollie::Amount.new(settlement_amount)
149
167
  end
150
168
 
169
+ def amount_captured
170
+ @amount_captured = Mollie::Amount.new(amount_captured)
171
+ end
172
+
151
173
  def amount_remaining=(amount_remaining)
152
174
  @amount_remaining = Mollie::Amount.new(amount_remaining)
153
175
  end
@@ -175,6 +197,10 @@ module Mollie
175
197
  Payment::Chargeback.all(options.merge(payment_id: id))
176
198
  end
177
199
 
200
+ def captures(options = {})
201
+ Payment::Capture.all(options.merge(payment_id: id))
202
+ end
203
+
178
204
  def customer(options = {})
179
205
  return if customer_id.nil?
180
206
  Customer.get(customer_id, options)
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = '4.1.1'.freeze
2
+ VERSION = '4.1.2'.freeze
3
3
  end
@@ -12,9 +12,12 @@ module Mollie
12
12
  status: 'active',
13
13
  amount: { 'value' => '25.00', 'currency' => 'EUR' },
14
14
  times: 4,
15
+ times_remaining: 3,
15
16
  interval: '3 months',
17
+ next_payment_date: '2016-09-01',
16
18
  description: 'Quarterly payment',
17
19
  method: 'creditcard',
20
+ mandate_id: 'mdt_38HS4fsS',
18
21
  canceled_at: '2016-06-01T12:23:34.0Z',
19
22
  webhook_url: 'https://example.org/payments/webhook'
20
23
  }
@@ -29,9 +32,12 @@ module Mollie
29
32
  assert_equal BigDecimal('25.00'), subscription.amount.value
30
33
  assert_equal 'EUR', subscription.amount.currency
31
34
  assert_equal 4, subscription.times
35
+ assert_equal 3, subscription.times_remaining
32
36
  assert_equal '3 months', subscription.interval
37
+ assert_equal Date.parse('2016-09-01'), subscription.next_payment_date
33
38
  assert_equal 'Quarterly payment', subscription.description
34
39
  assert_equal 'creditcard', subscription.method
40
+ assert_equal 'mdt_38HS4fsS', subscription.mandate_id
35
41
  assert_equal Time.parse('2016-06-01T12:23:34.0Z'), subscription.canceled_at
36
42
  assert_equal 'https://example.org/payments/webhook', subscription.webhook_url
37
43
  end
@@ -24,6 +24,7 @@ module Mollie
24
24
  consumer_bic: 'INGBNL2A'
25
25
  },
26
26
  status: 'paid',
27
+ authorized_at: '2018-03-19T09:14:37+00:00',
27
28
  paid_at: '2018-03-20T09:14:37+00:00',
28
29
  is_cancelable: false,
29
30
  expires_at: '2018-03-20T09:28:37+00:00',
@@ -58,6 +59,7 @@ module Mollie
58
59
  assert_equal Time.parse('2018-03-20T09:13:37+00:00'), payment.created_at
59
60
  assert_equal 'paid', payment.status
60
61
  assert_equal true, payment.paid?
62
+ assert_equal Time.parse('2018-03-19T09:14:37+00:00'), payment.authorized_at
61
63
  assert_equal Time.parse('2018-03-20T09:14:37+00:00'), payment.paid_at
62
64
  assert_equal 10.00, payment.amount.value
63
65
  assert_equal 'EUR', payment.amount.currency
@@ -111,6 +113,13 @@ module Mollie
111
113
  assert !Payment.new(status: 'not-authorized').authorized?
112
114
  end
113
115
 
116
+ def test_refunded?
117
+ assert Payment.new(amount_refunded: { value: '10.00', currency: 'EUR' }).refunded?
118
+ assert Payment.new(amount_refunded: { value: '0.01', currency: 'EUR' }).refunded?
119
+ assert_false Payment.new(amount_refunded: { value: '0', currency: 'EUR' }).refunded?
120
+ assert_false Payment.new([]).refunded?
121
+ end
122
+
114
123
  def test_create_payment
115
124
  stub_request(:post, 'https://api.mollie.com/v2/payments')
116
125
  .with(body: %({"amount":{"value":1.95,"currency":"EUR"}}))
@@ -231,6 +240,14 @@ module Mollie
231
240
  assert_equal 'chb-id', chargebacks.first.id
232
241
  end
233
242
 
243
+ def test_list_captures
244
+ stub_request(:get, 'https://api.mollie.com/v2/payments/pay-id/captures')
245
+ .to_return(status: 200, body: %({"_embedded" : {"captures" :[{"id":"cpt-id", "payment_id":"pay-id"}]}}), headers: {})
246
+
247
+ captures = Payment.new(id: 'pay-id').captures
248
+ assert_equal 'cpt-id', captures.first.id
249
+ end
250
+
234
251
  def test_get_settlement
235
252
  stub_request(:get, 'https://api.mollie.com/v2/payments/tr_WDqYK6vllg')
236
253
  .to_return(status: 200, body: %(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mollie-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mollie B.V.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2018-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake