Class: LolitaPaypal::TransactionsController

Inherits:
ApplicationController show all
Includes:
ActiveMerchant::Billing::Integrations
Defined in:
app/controllers/lolita_paypal/transactions_controller.rb

Instance Method Summary collapse

Instance Method Details

#answerObject

process ipn request POST is sent from paypal and will create transaction GET is a redirect from paypal and will redirect back to return_path



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/lolita_paypal/transactions_controller.rb', line 20

def answer
  if request.post?
    if ipn_notify.acknowledge
      LolitaPaypal::Transaction.create_transaction(ipn_notify, payment_from_ipn, request)
    end
    render nothing: true
  else
    if payment_from_ipn
      redirect_to payment_from_ipn.paypal_return_path
    else
      render text: I18n.t('lolita_paypal.wrong_request'), status: 400
    end
  end
ensure
  LolitaPaypal.logger.info("[#{session_id}][#{payment_from_ipn && payment_from_ipn.id}][answer] #{params}")
end

#checkoutObject

renders form with encrypted data and redirects to Paypal web interface



10
11
12
13
14
15
# File 'app/controllers/lolita_paypal/transactions_controller.rb', line 10

def checkout
  @payment_request = LolitaPaypal::Request.new(@payment)
  render 'lolita_paypal/payment_form'
ensure
  LolitaPaypal.logger.info("[#{session_id}][#{@payment.id}][checkout]")
end