Module: Effective::Providers::MonerisCheckout

Extended by:
ActiveSupport::Concern
Included in:
OrdersController
Defined in:
app/controllers/effective/providers/moneris_checkout.rb

Instance Method Summary collapse

Instance Method Details

#moneris_checkoutObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/effective/providers/moneris_checkout.rb', line 6

def moneris_checkout
  raise('moneris_checkout provider is not available') unless EffectiveOrders.moneris_checkout?

  @order = Order.find(params[:id])
  (EffectiveResources.authorize!(self, :update, @order) rescue false)

  payment = moneris_checkout_receipt_request(moneris_checkout_params[:ticket])
  purchased = (1..49).include?(payment['response_code'].to_i) # Must be > 0 and < 50 to be valid. Sometimes we get the string 'null'

  if purchased == false
    return order_declined(
      payment: payment,
      provider: 'moneris_checkout',
      declined_url: moneris_checkout_params[:declined_url]
    )
  end

  order_purchased(
    payment: payment,
    provider: 'moneris_checkout',
    card: payment['card_type'],
    purchased_url: moneris_checkout_params[:purchased_url]
  )
end