Class: Gemgento::Payment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gemgento::Payment
- Defined in:
- app/models/gemgento/payment.rb
Overview
Constant Summary collapse
- REDIRECTING_PAYMENT_METHODS =
{ paypal_standard: %w[confirm_after], paypal_express: %w[payment_after confirm_before] }
Instance Attribute Summary collapse
-
#cc_cid ⇒ Object
Returns the value of attribute cc_cid.
-
#cc_number ⇒ Object
Returns the value of attribute cc_number.
-
#payment_id ⇒ Object
Returns the value of attribute payment_id.
-
#save_card ⇒ Object
Returns the value of attribute save_card.
Instance Method Summary collapse
- #is_new_credit_card_payment? ⇒ Boolean
- #is_redirecting_payment_method?(step = nil) ⇒ Boolean
-
#set_cc_last4 ⇒ void
Set cc_last4 to the last 4 numbers of cc_number.
Instance Attribute Details
#cc_cid ⇒ Object
Returns the value of attribute cc_cid.
7 8 9 |
# File 'app/models/gemgento/payment.rb', line 7 def cc_cid @cc_cid end |
#cc_number ⇒ Object
Returns the value of attribute cc_number.
7 8 9 |
# File 'app/models/gemgento/payment.rb', line 7 def cc_number @cc_number end |
#payment_id ⇒ Object
Returns the value of attribute payment_id.
7 8 9 |
# File 'app/models/gemgento/payment.rb', line 7 def payment_id @payment_id end |
#save_card ⇒ Object
Returns the value of attribute save_card.
7 8 9 |
# File 'app/models/gemgento/payment.rb', line 7 def save_card @save_card end |
Instance Method Details
#is_new_credit_card_payment? ⇒ Boolean
42 43 44 45 46 47 |
# File 'app/models/gemgento/payment.rb', line 42 def is_new_credit_card_payment? payable_type == 'Gemgento::Quote' && payable.converted_at.nil? && !is_redirecting_payment_method? && method != 'free' && payment_id.nil? end |
#is_redirecting_payment_method?(step = nil) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/gemgento/payment.rb', line 18 def is_redirecting_payment_method?(step = nil) if REDIRECTING_PAYMENT_METHODS.has_key?(self.method.to_sym) if step.blank? return true else return REDIRECTING_PAYMENT_METHODS[self.method.to_sym].include? step end else return false end end |
#set_cc_last4 ⇒ void
This method returns an undefined value.
Set cc_last4 to the last 4 numbers of cc_number.
33 34 35 36 37 38 39 40 |
# File 'app/models/gemgento/payment.rb', line 33 def set_cc_last4 if self.cc_number.present? self.cc_last4 = cc_number[-4..-1] elsif saved_cc = Gemgento::SavedCreditCard.find_by(user: self.payable.user, token: self.payment_id) self.cc_last4 = saved_cc.cc_number.to_s[-4..-1] end end |