Class: WalletonePayment

Inherits:
Walletone::Middleware::Base
  • Object
show all
Defined in:
app/middleware/walletone_payment.rb

Instance Method Summary collapse

Instance Method Details

#perform(notify, env) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/middleware/walletone_payment.rb', line 4

def perform notify, env

  raise 'Wrong sign' unless notify.valid? ENV['WALLETONE_SECRET']

  if notify.accepted?
    Spree::WalletonePaymentProcessing.new(
      payment_method_id: notify['PAYMENT_METHOD_ID'],
      order_id: notify.WMI_PAYMENT_NO,
      payment_id: notify.WMI_ORDER_ID,
      payer_id: notify.WMI_TO_USER_ID,
      amount: notify.WMI_PAYMENT_AMOUNT.to_f
    ).process
  else
    # Payment is failed. Notify your client.
  end
  "Payment processed"
end