Class: OffsitePayments::Integrations::MollieMistercash::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/offsite_payments/integrations/mollie_mistercash.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)


70
71
72
73
74
75
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 70

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



118
119
120
121
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 118

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

#api_keyObject



89
90
91
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 89

def api_key
  @options[:credential1]
end

#check_payment_status(transaction_id) ⇒ Object



123
124
125
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 123

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

#complete?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 77

def complete?
  true
end

#currencyObject



93
94
95
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 93

def currency
  "EUR"
end

#grossObject

the money amount we received in X.2 decimal.



98
99
100
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 98

def gross
  @params['amount']
end

#gross_centsObject



102
103
104
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 102

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

#item_idObject



81
82
83
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 81

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

#statusObject



106
107
108
109
110
111
112
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 106

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

#test?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 114

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

#transaction_idObject



85
86
87
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 85

def transaction_id
  params['id']
end