Module: Vpago::PaymentDecorator
- Defined in:
- app/models/vpago/payment_decorator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #can_redirect_to_app? ⇒ Boolean
-
#capture!(amount = nil) ⇒ Object
override.
- #check_payment? ⇒ Boolean
- #pre_auth_cancelled? ⇒ Boolean
- #pre_auth_completed? ⇒ Boolean
-
#pre_auth_status ⇒ Object
COMPLETED, CANCELLED.
-
#process! ⇒ Object
override.
-
#protect_from_connection_error ⇒ Object
override: to allow capture faraday connection error.
- #should_generate_payouts? ⇒ Boolean
- #true_money_payment? ⇒ Boolean
- #url_constructor ⇒ Object
- #user_informer ⇒ Object
- #vattanac_mini_app_payment? ⇒ Boolean
- #vattanac_payment? ⇒ Boolean
Class Method Details
.prepended(base) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/vpago/payment_decorator.rb', line 17 def self.prepended(base) base.has_many :payouts, class_name: 'Spree::Payout', inverse_of: :payment base.after_create -> { Vpago::PayoutsGenerator.new(self).call }, if: :should_generate_payouts? base.delegate :checkout_url, :web_checkout_url, :processing_url, :success_url, :process_payment_url, :success_deeplink_url, to: :url_constructor # Add state machine event for payment retry base.state_machine.event :reset_for_retry do transition from: i[failed], to: :checkout end end |
Instance Method Details
#can_redirect_to_app? ⇒ Boolean
102 103 104 |
# File 'app/models/vpago/payment_decorator.rb', line 102 def can_redirect_to_app? payment_method.can_redirect_to_app? end |
#capture!(amount = nil) ⇒ Object
override
43 44 45 46 47 |
# File 'app/models/vpago/payment_decorator.rb', line 43 def capture!(amount = nil) reset_for_retry! if failed? super end |
#check_payment? ⇒ Boolean
98 99 100 |
# File 'app/models/vpago/payment_decorator.rb', line 98 def check_payment? payment_method.type_check? end |
#pre_auth_cancelled? ⇒ Boolean
82 83 84 |
# File 'app/models/vpago/payment_decorator.rb', line 82 def pre_auth_cancelled? pre_auth_status == 'CANCELLED' end |
#pre_auth_completed? ⇒ Boolean
78 79 80 |
# File 'app/models/vpago/payment_decorator.rb', line 78 def pre_auth_completed? pre_auth_status == 'COMPLETED' end |
#pre_auth_status ⇒ Object
COMPLETED, CANCELLED
74 75 76 |
# File 'app/models/vpago/payment_decorator.rb', line 74 def pre_auth_status pre_auth_response['transaction_status'] end |
#process! ⇒ Object
override
36 37 38 39 40 |
# File 'app/models/vpago/payment_decorator.rb', line 36 def process! reset_for_retry! if failed? super end |
#protect_from_connection_error ⇒ Object
override: to allow capture faraday connection error. gateway_error method already write rails log for this.
51 52 53 54 55 56 57 58 59 |
# File 'app/models/vpago/payment_decorator.rb', line 51 def protect_from_connection_error yield rescue ActiveMerchant::ConnectionError => e failure! gateway_error(e) rescue Faraday::ConnectionFailed, Faraday::TimeoutError => e failure! gateway_error(ActiveMerchant::ConnectionError.new(e., e)) end |
#should_generate_payouts? ⇒ Boolean
69 70 71 |
# File 'app/models/vpago/payment_decorator.rb', line 69 def should_generate_payouts? payment_method.enable_payout? && payouts.empty? end |
#true_money_payment? ⇒ Boolean
86 87 88 |
# File 'app/models/vpago/payment_decorator.rb', line 86 def true_money_payment? payment_method.type_true_money? end |
#url_constructor ⇒ Object
65 66 67 |
# File 'app/models/vpago/payment_decorator.rb', line 65 def url_constructor @url_constructor ||= Vpago::PaymentUrlConstructor.new(self) end |
#user_informer ⇒ Object
61 62 63 |
# File 'app/models/vpago/payment_decorator.rb', line 61 def user_informer @user_informer ||= ::Vpago::UserInformers::Firebase.new(order) end |
#vattanac_mini_app_payment? ⇒ Boolean
94 95 96 |
# File 'app/models/vpago/payment_decorator.rb', line 94 def vattanac_mini_app_payment? payment_method.type_vattanac_mini_app? end |
#vattanac_payment? ⇒ Boolean
90 91 92 |
# File 'app/models/vpago/payment_decorator.rb', line 90 def vattanac_payment? payment_method.type_vattanac? end |