Module: Vpago::PaymentMethodDecorator
- Defined in:
- app/models/vpago/payment_method_decorator.rb
Constant Summary collapse
- TYPE_PAYWAY =
'Spree::Gateway::Payway'.freeze
- TYPE_PAYWAY_V2 =
'Spree::Gateway::PaywayV2'.freeze
- TYPE_WINGSDK =
'Spree::Gateway::WingSdk'.freeze
- TYPE_ACLEDA =
'Spree::Gateway::Acleda'.freeze
- TYPE_ACLEDA_V2 =
'Spree::Gateway::AcledaV2'.freeze
- TYPE_ACLEDA_MOBILE =
'Spree::Gateway::AcledaMobile'.freeze
- TYPE_TRUE_MONEY =
'Spree::Gateway::TrueMoney'.freeze
- TYPE_VATTANAC =
'Spree::Gateway::Vattanac'.freeze
- TYPE_VATTANAC_MINI_APP =
'Spree::Gateway::VattanacMiniApp'.freeze
- TYPE_CASH_ON =
'Spree::PaymentMethod::CashOn'.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #can_redirect_to_app? ⇒ Boolean
- #default_payout_profile ⇒ Object
- #enable_payout? ⇒ Boolean
- #enable_pre_auth? ⇒ Boolean
-
#payment_icon_path ⇒ String
The image asset path, e.g.
- #payment_request_updater ⇒ Object
-
#purchase(_amount, _source, _gateway_options = {}) ⇒ Object
TODO: we have already implement purchase for payway_v2.
-
#support_check_transaction_api? ⇒ Boolean
The payment method must implement
check_transaction(payment). - #support_payout? ⇒ Boolean
- #support_pre_auth? ⇒ Boolean
- #type_acleda? ⇒ Boolean
- #type_acleda_mobile? ⇒ Boolean
- #type_acleda_v2? ⇒ Boolean
- #type_cash_on? ⇒ Boolean
- #type_check? ⇒ Boolean
- #type_payway? ⇒ Boolean
- #type_payway_v2? ⇒ Boolean
- #type_true_money? ⇒ Boolean
- #type_vattanac_mini_app? ⇒ Boolean
- #type_wingsdk? ⇒ Boolean
- #vapgo_checkout_service ⇒ Object
- #vpago_payment? ⇒ Boolean
Class Method Details
.prepended(base) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/vpago/payment_method_decorator.rb', line 14 def self.prepended(base) base.preference :icon_name, :string, default: 'cheque' base.preference :app_scheme, :string base.belongs_to :vendor, class_name: 'Spree::Vendor', optional: true, inverse_of: :payment_methods def base.vpago_payments [ Spree::PaymentMethod::TYPE_PAYWAY_V2, Spree::PaymentMethod::TYPE_PAYWAY, Spree::PaymentMethod::TYPE_WINGSDK, Spree::PaymentMethod::TYPE_ACLEDA, Spree::PaymentMethod::TYPE_ACLEDA_V2, Spree::PaymentMethod::TYPE_ACLEDA_MOBILE, Spree::PaymentMethod::TYPE_VATTANAC, Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP, Spree::PaymentMethod::TYPE_TRUE_MONEY, Spree::PaymentMethod::TYPE_CASH_ON ] end end |
Instance Method Details
#can_redirect_to_app? ⇒ Boolean
126 127 128 |
# File 'app/models/vpago/payment_method_decorator.rb', line 126 def can_redirect_to_app? preferred_app_scheme.present? end |
#default_payout_profile ⇒ Object
52 53 54 |
# File 'app/models/vpago/payment_method_decorator.rb', line 52 def default_payout_profile nil end |
#enable_payout? ⇒ Boolean
35 |
# File 'app/models/vpago/payment_method_decorator.rb', line 35 def enable_payout? = support_payout? |
#enable_pre_auth? ⇒ Boolean
36 |
# File 'app/models/vpago/payment_method_decorator.rb', line 36 def enable_pre_auth? = support_pre_auth? && self[:enable_pre_auth] |
#payment_icon_path ⇒ String
Returns the image asset path, e.g. "payment_logos/payway-abapay-khqr.png".
131 132 133 |
# File 'app/models/vpago/payment_method_decorator.rb', line 131 def payment_icon_path "payment_logos/#{preferred_icon_name.tr('_', ' ').parameterize}.png" end |
#payment_request_updater ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/models/vpago/payment_method_decorator.rb', line 72 def payment_request_updater if type_payway? ::Vpago::Payway::PaymentRequestUpdater elsif type_payway_v2? ::Vpago::PaywayV2::PaymentRequestUpdater elsif type_wingsdk? ::Vpago::WingSdk::PaymentRequestUpdater elsif type_acleda? ::Vpago::Acleda::PaymentRequestUpdater elsif type_acleda_mobile? ::Vpago::AcledaMobile::PaymentRequestUpdater end end |
#purchase(_amount, _source, _gateway_options = {}) ⇒ Object
TODO: we have already implement purchase for payway_v2. make sure to implement this on other payment method as well.
48 49 50 |
# File 'app/models/vpago/payment_method_decorator.rb', line 48 def purchase(_amount, _source, = {}) ActiveMerchant::Billing::Response.new(true, 'Payway Gateway: Success') end |
#support_check_transaction_api? ⇒ Boolean
The payment method must implement check_transaction(payment).
The returned object should respond to .success?, and optionally .failed? and .pending?.
42 43 44 |
# File 'app/models/vpago/payment_method_decorator.rb', line 42 def support_check_transaction_api? respond_to?(:check_transaction) end |
#support_payout? ⇒ Boolean
37 |
# File 'app/models/vpago/payment_method_decorator.rb', line 37 def support_payout? = false |
#support_pre_auth? ⇒ Boolean
38 |
# File 'app/models/vpago/payment_method_decorator.rb', line 38 def support_pre_auth? = false |
#type_acleda? ⇒ Boolean
90 91 92 |
# File 'app/models/vpago/payment_method_decorator.rb', line 90 def type_acleda? type == Spree::PaymentMethod::TYPE_ACLEDA end |
#type_acleda_mobile? ⇒ Boolean
86 87 88 |
# File 'app/models/vpago/payment_method_decorator.rb', line 86 def type_acleda_mobile? type == Spree::PaymentMethod::TYPE_ACLEDA_MOBILE end |
#type_acleda_v2? ⇒ Boolean
94 95 96 |
# File 'app/models/vpago/payment_method_decorator.rb', line 94 def type_acleda_v2? type == Spree::PaymentMethod::TYPE_ACLEDA_V2 end |
#type_cash_on? ⇒ Boolean
118 119 120 |
# File 'app/models/vpago/payment_method_decorator.rb', line 118 def type_cash_on? type == Spree::PaymentMethod::TYPE_CASH_ON end |
#type_check? ⇒ Boolean
122 123 124 |
# File 'app/models/vpago/payment_method_decorator.rb', line 122 def type_check? type == 'Spree::PaymentMethod::Check' end |
#type_payway? ⇒ Boolean
98 99 100 |
# File 'app/models/vpago/payment_method_decorator.rb', line 98 def type_payway? type == Spree::PaymentMethod::TYPE_PAYWAY end |
#type_payway_v2? ⇒ Boolean
102 103 104 |
# File 'app/models/vpago/payment_method_decorator.rb', line 102 def type_payway_v2? type == Spree::PaymentMethod::TYPE_PAYWAY_V2 end |
#type_true_money? ⇒ Boolean
114 115 116 |
# File 'app/models/vpago/payment_method_decorator.rb', line 114 def type_true_money? type == Spree::PaymentMethod::TYPE_TRUE_MONEY end |
#type_vattanac_mini_app? ⇒ Boolean
110 111 112 |
# File 'app/models/vpago/payment_method_decorator.rb', line 110 def type_vattanac_mini_app? type == Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP end |
#type_wingsdk? ⇒ Boolean
106 107 108 |
# File 'app/models/vpago/payment_method_decorator.rb', line 106 def type_wingsdk? type == Spree::PaymentMethod::TYPE_WINGSDK end |
#vapgo_checkout_service ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/vpago/payment_method_decorator.rb', line 60 def vapgo_checkout_service if type_payway? ::Vpago::Payway::Checkout elsif type_payway_v2? ::Vpago::PaywayV2::Checkout elsif type_wingsdk? ::Vpago::WingSdk::Checkout elsif type_acleda? ::Vpago::Acleda::Checkout end end |
#vpago_payment? ⇒ Boolean
56 57 58 |
# File 'app/models/vpago/payment_method_decorator.rb', line 56 def vpago_payment? self.class.vpago_payments.include?(type) end |