Module: Samurai::Rails::Helpers

Defined in:
lib/samurai/rails/helpers.rb

Instance Method Summary collapse

Instance Method Details

#load_and_verify_payment_method(params) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/samurai/rails/helpers.rb', line 16

def load_and_verify_payment_method(params)
  if params[:payment_method_token].blank?
    @payment_method = Samurai::PaymentMethod.new :is_sensitive_data_valid=>false
  else
    @payment_method = Samurai::PaymentMethod.find params[:payment_method_token]
    @payment_method = nil if @payment_method && !@payment_method.is_sensitive_data_valid?
  end
  @payment_method
end

#payment_method_paramsObject



26
27
28
29
30
# File 'lib/samurai/rails/helpers.rb', line 26

def payment_method_params
  { :payment_method_token => params[:payment_method_token] }.tap do |_params|
    _params[:reference_id] = @transaction.reference_id if @transaction
  end
end

#setup_for_transparent_redirect(params) ⇒ Object



11
12
13
14
# File 'lib/samurai/rails/helpers.rb', line 11

def setup_for_transparent_redirect(params)
  @transaction = Samurai::Transaction.find params[:reference_id] unless params[:reference_id].blank?
  @payment_method = Samurai::PaymentMethod.for_transparent_redirect(params)
end