class SolidusPaypalBraintree::TransactionsController
Constants
- PERMITTED_BRAINTREE_TRANSACTION_PARAMS
Public Instance Methods
create()
click to toggle source
# File lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb, line 19 def create transaction = SolidusPaypalBraintree::Transaction.new transaction_params import = SolidusPaypalBraintree::TransactionImport.new(current_order, transaction) restart_checkout = params[:options] && params[:options][:restart_checkout] == "true" respond_to do |format| if import.valid? import.import!(import_state, restart_checkout: restart_checkout) format.html { redirect_to redirect_url(import) } format.json { render json: { redirectUrl: redirect_url(import) } } else status = 422 format.html { import_error(import) } format.json { render json: { errors: import.errors, status: status }, status: status } end end end
Private Instance Methods
import_error(import)
click to toggle source
# File lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb, line 44 def import_error(import) raise InvalidImportError, "Import invalid: #{import.errors.full_messages.join(', ')}" end
import_state()
click to toggle source
# File lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb, line 40 def import_state params[:state] || 'confirm' end
payment_method()
click to toggle source
# File lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb, line 63 def payment_method SolidusPaypalBraintree::Gateway.find(params[:payment_method_id]) end
redirect_url(import)
click to toggle source
# File lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb, line 49 def redirect_url(import) if import.order.complete? spree.order_url(import.order) else spree.checkout_state_url(import.order.state) end end
transaction_params()
click to toggle source
# File lib/controllers/frontend/solidus_paypal_braintree/transactions_controller.rb, line 57 def transaction_params params.require(:transaction) .permit(PERMITTED_BRAINTREE_TRANSACTION_PARAMS) .merge({ payment_method: payment_method }) end