Class: OffsitePayments::Integrations::MollieIdeal::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/mollie_ideal.rb

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #iso_currency, #valid_sender?

Constructor Details

#initialize(post_arguments, options = {}) ⇒ Notification

Returns a new instance of Notification

Raises:

  • (ArgumentError)

154
155
156
157
158
159
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 154

def initialize(post_arguments, options = {})
  super

  raise ArgumentError, "The transaction_id needs to be included in the query string." if transaction_id.nil?
  raise ArgumentError, "The credential1 option needs to be set to the Mollie API key." if api_key.blank?
end

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object


202
203
204
205
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 202

def acknowledge(authcode = nil)
  @params = check_payment_status(transaction_id)
  true
end

#api_keyObject


173
174
175
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 173

def api_key
  @options[:credential1]
end

#check_payment_status(transaction_id) ⇒ Object


207
208
209
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 207

def check_payment_status(transaction_id)
  MollieIdeal.check_payment_status(@options[:credential1], transaction_id)
end

#complete?Boolean


161
162
163
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 161

def complete?
  true
end

#currencyObject


177
178
179
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 177

def currency
  "EUR"
end

#grossObject

the money amount we received in X.2 decimal.


182
183
184
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 182

def gross
  @params['amount']
end

#gross_centsObject


186
187
188
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 186

def gross_cents
  (BigDecimal.new(@params['amount'], 2) * 100).to_i
end

#item_idObject


165
166
167
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 165

def item_id
  params['metadata']['order']
end

#statusObject


190
191
192
193
194
195
196
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 190

def status
  case @params['status']
    when 'open';                 'Pending'
    when 'paidout', 'paid';      'Completed'
    else                         'Failed'
  end
end

#test?Boolean


198
199
200
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 198

def test?
  @params['mode'] == 'test'
end

#transaction_idObject


169
170
171
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 169

def transaction_id
  params['id']
end