Class: Payments::CheckoutsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/payments/checkouts_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

caches_page_with_cache_marker, #raise_not_found!

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/payments/checkouts_controller.rb', line 7

def show
  @client_token = Braintree::ClientToken.generate(
    merchant_account_id: @payment.
  )

  set_payment_to_session(@payment)

  respond_with @payment, layout: .blank? ? 'application' : 'cabinet'
end

#updateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/payments/checkouts_controller.rb', line 17

def update
  @checkout = TranslationCms::Api::Payments::Checkout.create(
    payment_method_nonce: params['payment_method_nonce'],
    payment_transaction_id: @payment.id,
    device_data: params['device_data']
  )

  url = if @checkout.success
          payments_integrations_success_url(provider: :credit_card, order_id: @checkout.order_number)
        else
          payments_integrations_fail_url(provider: :credit_card, token: @payment.public_token)
  end

  redirect_to url
end