Class: OffsitePayments::Integrations::Citrus::Notification
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#empty!, #gross_cents, #iso_currency, #test?, #valid_sender?
Constructor Details
#initialize(post, options = {}) ⇒ Notification
Returns a new instance of Notification.
70
71
72
73
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 70
def initialize(post, options = {})
super(post, options)
@secret_key = options[:credential2]
end
|
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
179
180
181
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 179
def acknowledge(authcode = nil)
checksum_ok?
end
|
#amount ⇒ Object
121
122
123
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 121
def amount
Money.from_amount(BigDecimal(gross), currency)
end
|
#amount_ok?(order_amount) ⇒ Boolean
98
99
100
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 98
def amount_ok?(order_amount)
amount == Money.from_amount(order_amount, currency)
end
|
#authidcode ⇒ Object
133
134
135
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 133
def authidcode
params['authIdCode']
end
|
#checksum ⇒ Object
141
142
143
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 141
def checksum
params['signature']
end
|
#checksum_ok? ⇒ Boolean
183
184
185
186
187
188
189
190
191
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 183
def checksum_ok?
fields = [invoice, transaction_status, sprintf('%.2f', amount), transaction_id, issuerrefno, authidcode, customer_first_name, customer_last_name, pgrespcode, customer_address[:zip]].join
unless Citrus.checksum(@secret_key, fields ) == checksum
@message = 'checksum mismatch...'
return false
end
true
end
|
#complete? ⇒ Boolean
75
76
77
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 75
def complete?
status == "Completed" || status == 'Canceled'
end
|
#currency ⇒ Object
149
150
151
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 149
def currency
params['currency']
end
|
#customer_address ⇒ Object
169
170
171
172
173
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 169
def customer_address
{ :address1 => params['addressStreet1'], :address2 => params['addressStreet2'],
:city => params['addressCity'], :state => params['addressState'],
:country => params['addressCountry'], :zip => params['addressZip'] }
end
|
#customer_email ⇒ Object
153
154
155
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 153
def customer_email
params['email']
end
|
#customer_first_name ⇒ Object
161
162
163
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 161
def customer_first_name
params['firstName']
end
|
#customer_last_name ⇒ Object
165
166
167
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 165
def customer_last_name
params['lastName']
end
|
#customer_phone ⇒ Object
157
158
159
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 157
def customer_phone
params['mobileNo']
end
|
#gross ⇒ Object
117
118
119
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 117
def gross
params['amount']
end
|
#invoice ⇒ Object
106
107
108
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 106
def invoice
item_id
end
|
#invoice_ok?(order_id) ⇒ Boolean
94
95
96
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 94
def invoice_ok?( order_id )
order_id.to_s == invoice.to_s
end
|
#issuerrefno ⇒ Object
129
130
131
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 129
def issuerrefno
params['issuerRefNo']
end
|
#item_id ⇒ Object
102
103
104
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 102
def item_id
params['TxId']
end
|
#message ⇒ Object
175
176
177
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 175
def message
@message || params['TxMsg']
end
|
#paymentmode ⇒ Object
145
146
147
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 145
def paymentmode
params['paymentMode']
end
|
#pgrespcode ⇒ Object
137
138
139
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 137
def pgrespcode
params['pgRespCode']
end
|
#status ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 79
def status
@status ||= if checksum_ok?
if transaction_id.blank?
'Invalid'
else
case transaction_status.downcase
when 'success' then 'Completed'
when 'canceled' then 'Failed'
end
end
else
'Tampered'
end
end
|
#transaction_id ⇒ Object
125
126
127
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 125
def transaction_id
params['pgTxnNo']
end
|
#transaction_status ⇒ Object
Status of transaction return from the Citrus. List of possible values:
SUCCESS
CANCELED
113
114
115
|
# File 'lib/offsite_payments/integrations/citrus.rb', line 113
def transaction_status
params['TxStatus']
end
|