Class: OffsitePayments::Integrations::Platron::Notification

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

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#empty!, #gross, #gross_cents, #iso_currency, #status, #test?, #valid_sender?

Constructor Details

#initialize(*args) ⇒ Notification

Returns a new instance of Notification.



49
50
51
52
# File 'lib/offsite_payments/integrations/platron.rb', line 49

def initialize(*args)
  super
  @signature = params.delete('pg_sig')
end

Instance Method Details

#acknowledge(authcode = nil) ⇒ Object



134
135
136
# File 'lib/offsite_payments/integrations/platron.rb', line 134

def acknowledge(authcode = nil)
  signature == Platron.generate_signature(params, path, secret)
end

#amountObject



122
123
124
# File 'lib/offsite_payments/integrations/platron.rb', line 122

def amount
  Money.from_amount(BigDecimal(params['pg_amount']), currency)
end

#capturedObject



82
83
84
# File 'lib/offsite_payments/integrations/platron.rb', line 82

def captured
  params['pg_captured']
end

#card_brandObject



78
79
80
# File 'lib/offsite_payments/integrations/platron.rb', line 78

def card_brand
  params['pg_card_brand']
end

#complete?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/offsite_payments/integrations/platron.rb', line 54

def complete?
  params['pg_result']
end

#currencyObject



66
67
68
# File 'lib/offsite_payments/integrations/platron.rb', line 66

def currency
  params['pg_ps_currency']
end

#failure_codeObject



90
91
92
# File 'lib/offsite_payments/integrations/platron.rb', line 90

def failure_code
  params['pg_failure_code']
end

#failure_descriptionObject



94
95
96
# File 'lib/offsite_payments/integrations/platron.rb', line 94

def failure_description
  params['pg_failure_description']
end

#net_amountObject



110
111
112
# File 'lib/offsite_payments/integrations/platron.rb', line 110

def net_amount
  params['pg_net_amount']
end

#order_idObject



58
59
60
# File 'lib/offsite_payments/integrations/platron.rb', line 58

def order_id
  params['pg_order_id']
end

#overpaymentObject



86
87
88
# File 'lib/offsite_payments/integrations/platron.rb', line 86

def overpayment
  params['pg_overpayment']
end

#pathObject



130
131
132
# File 'lib/offsite_payments/integrations/platron.rb', line 130

def path
  @options[:path]
end

#payment_dateObject



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

def payment_date
  params['pg_payment_date']
end

#payment_systemObject



70
71
72
# File 'lib/offsite_payments/integrations/platron.rb', line 70

def payment_system
  params['pg_payment_system']
end

#platron_payment_idObject



62
63
64
# File 'lib/offsite_payments/integrations/platron.rb', line 62

def platron_payment_id
  params['pg_payment_id']
end

#ps_amountObject



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

def ps_amount
  params['pg_ps_amount']
end

#ps_full_amountObject



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

def ps_full_amount
  params['pg_ps_full_amount']
end

#saltObject



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

def salt
  params['pg_salt']
end

#secretObject



126
127
128
# File 'lib/offsite_payments/integrations/platron.rb', line 126

def secret
  @options[:secret]
end

#signatureObject



106
107
108
# File 'lib/offsite_payments/integrations/platron.rb', line 106

def signature
  @signature
end

#success_response(path, secret) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/offsite_payments/integrations/platron.rb', line 138

def success_response(path,secret)
  salt = rand(36**15).to_s(36)
  xml = ""
  doc = Builder::XmlMarkup.new(:target => xml)
  sign = Platron.generate_signature({:pg_status => 'ok', :pg_salt => salt}, path, secret)
  doc.response do
    doc.pg_status 'ok'
    doc.pg_salt salt
    doc.pg_sig sign
  end
  xml
end

#user_phoneObject



74
75
76
# File 'lib/offsite_payments/integrations/platron.rb', line 74

def user_phone
  params['pg_user_phone']
end