Class: Spree::Gateway::CustomPaymentSourceMethod

Inherits:
Spree::Gateway show all
Defined in:
app/models/spree/gateway/custom_payment_source_method.rb

Constant Summary

Constants inherited from Spree::Gateway

FROM_DOLLAR_TO_CENT_RATE

Constants included from DisplayOn

DisplayOn::DISPLAY

Instance Method Summary collapse

Methods inherited from Spree::Gateway

#disable_customer_profile, #exchange_multiplier, #gateway_dashboard_payment_url, #method_missing, #method_type, #options, #provider, #reusable_sources, #sources_by_order, #supports?

Methods inherited from PaymentMethod

#auto_capture?, #available_for_order?, #available_for_store?, #cancel, #default_name, find_with_destroyed, #method_type, #payment_icon_name, providers, #public_preferences, #reusable_sources, #source_required?, #store_credit?, #supports?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spree::Gateway

Instance Method Details

#create_profile(payment) ⇒ Object



19
20
21
22
23
24
25
26
# File 'app/models/spree/gateway/custom_payment_source_method.rb', line 19

def create_profile(payment)
  return if payment.source.gateway_customer.present?

  user = payment.source.user || payment.order.user
  return if user.blank?

  find_or_create_customer(user)
end

#find_or_create_customer(user) ⇒ Object

simulate a 3rd party payment gateway api to fetch/or create a customer



29
30
31
# File 'app/models/spree/gateway/custom_payment_source_method.rb', line 29

def find_or_create_customer(user)
  gateway_customers.find_or_create_by!(user: user, profile_id: "CUSTOMER-#{user.id}")
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'app/models/spree/gateway/custom_payment_source_method.rb', line 11

def payment_profiles_supported?
  true
end

#payment_source_classObject



7
8
9
# File 'app/models/spree/gateway/custom_payment_source_method.rb', line 7

def payment_source_class
  Spree::PaymentSource
end

#provider_classObject



3
4
5
# File 'app/models/spree/gateway/custom_payment_source_method.rb', line 3

def provider_class
  self.class
end

#show_in_admin?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/models/spree/gateway/custom_payment_source_method.rb', line 15

def show_in_admin?
  false
end