12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'app/controllers/effective/providers/moneris.rb', line 12
def moneris_postback
raise('moneris provider is not available') unless EffectiveOrders.moneris?
@order ||= Effective::Order.find(params[:response_order_id])
(EffectiveResources.authorize!(self, :update, @order) rescue false)
purchased_url = params.delete(:rvar_purchased_url)
declined_url = params.delete(:rvar_declined_url)
if @order.purchased? return order_purchased(payment: params, provider: 'moneris', card: params[:card], purchased_url: purchased_url)
end
if params[:result].to_s != '1' || params[:transactionKey].blank?
return order_declined(payment: params, provider: 'moneris', card: params[:card], declined_url: declined_url)
end
payment = params.merge(verify_moneris_transaction(params[:transactionKey]))
valid = (1..49).include?(payment[:response_code].to_i)
if valid == false
return order_declined(payment: payment, provider: 'moneris', card: params[:card], declined_url: declined_url)
end
order_purchased(payment: payment, provider: 'moneris', card: params[:card], purchased_url: purchased_url)
end
|