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)

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

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


128
129
130
131
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 128

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

#api_keyObject


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

def api_key
  @options[:credential1]
end

#check_payment_status(transaction_id) ⇒ Object


133
134
135
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 133

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

#complete?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 87

def complete?
  true
end

#currencyObject


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

def currency
  "EUR"
end

#grossObject

the money amount we received in X.2 decimal.


108
109
110
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 108

def gross
  @params['amount']
end

#gross_centsObject


112
113
114
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 112

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

#item_idObject


91
92
93
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 91

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

#statusObject


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

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

#test?Boolean

Returns:

  • (Boolean)

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

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

#transaction_idObject


95
96
97
# File 'lib/offsite_payments/integrations/mollie_mistercash.rb', line 95

def transaction_id
  params['id']
end