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)


132
133
134
135
136
137
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 132

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



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

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

#api_keyObject



151
152
153
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 151

def api_key
  @options[:credential1]
end

#check_payment_status(transaction_id) ⇒ Object



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

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

#complete?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 139

def complete?
  true
end

#currencyObject



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

def currency
  "EUR"
end

#grossObject

the money amount we received in X.2 decimal.



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

def gross
  @params['amount']
end

#gross_centsObject



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

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

#item_idObject



143
144
145
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 143

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

#statusObject



168
169
170
171
172
173
174
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 168

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

#test?Boolean

Returns:

  • (Boolean)


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

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

#transaction_idObject



147
148
149
# File 'lib/offsite_payments/integrations/mollie_ideal.rb', line 147

def transaction_id
  params['id']
end