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_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
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_payout? ⇒ Boolean
- #support_pre_auth? ⇒ Boolean
- #type_acleda? ⇒ Boolean
- #type_acleda_mobile? ⇒ 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/vpago/payment_method_decorator.rb', line 12 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_MOBILE, Spree::PaymentMethod::TYPE_VATTANAC, Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP, Spree::PaymentMethod::TYPE_TRUE_MONEY ] end end |
Instance Method Details
#can_redirect_to_app? ⇒ Boolean
108 109 110 |
# File 'app/models/vpago/payment_method_decorator.rb', line 108 def can_redirect_to_app? preferred_app_scheme.present? end |
#default_payout_profile ⇒ Object
42 43 44 |
# File 'app/models/vpago/payment_method_decorator.rb', line 42 def default_payout_profile nil end |
#enable_payout? ⇒ Boolean
31 |
# File 'app/models/vpago/payment_method_decorator.rb', line 31 def enable_payout? = support_payout? |
#enable_pre_auth? ⇒ Boolean
32 |
# File 'app/models/vpago/payment_method_decorator.rb', line 32 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”.
113 114 115 |
# File 'app/models/vpago/payment_method_decorator.rb', line 113 def payment_icon_path "payment_logos/#{preferred_icon_name.tr('_', ' ').parameterize}.png" end |
#payment_request_updater ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/models/vpago/payment_method_decorator.rb', line 62 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.
38 39 40 |
# File 'app/models/vpago/payment_method_decorator.rb', line 38 def purchase(_amount, _source, = {}) ActiveMerchant::Billing::Response.new(true, 'Payway Gateway: Success') end |
#support_payout? ⇒ Boolean
33 |
# File 'app/models/vpago/payment_method_decorator.rb', line 33 def support_payout? = false |
#support_pre_auth? ⇒ Boolean
34 |
# File 'app/models/vpago/payment_method_decorator.rb', line 34 def support_pre_auth? = false |
#type_acleda? ⇒ Boolean
80 81 82 |
# File 'app/models/vpago/payment_method_decorator.rb', line 80 def type_acleda? type == Spree::PaymentMethod::TYPE_ACLEDA end |
#type_acleda_mobile? ⇒ Boolean
76 77 78 |
# File 'app/models/vpago/payment_method_decorator.rb', line 76 def type_acleda_mobile? type == Spree::PaymentMethod::TYPE_ACLEDA_MOBILE end |
#type_check? ⇒ Boolean
104 105 106 |
# File 'app/models/vpago/payment_method_decorator.rb', line 104 def type_check? type == 'Spree::PaymentMethod::Check' end |
#type_payway? ⇒ Boolean
84 85 86 |
# File 'app/models/vpago/payment_method_decorator.rb', line 84 def type_payway? type == Spree::PaymentMethod::TYPE_PAYWAY end |
#type_payway_v2? ⇒ Boolean
88 89 90 |
# File 'app/models/vpago/payment_method_decorator.rb', line 88 def type_payway_v2? type == Spree::PaymentMethod::TYPE_PAYWAY_V2 end |
#type_true_money? ⇒ Boolean
100 101 102 |
# File 'app/models/vpago/payment_method_decorator.rb', line 100 def type_true_money? type == Spree::PaymentMethod::TYPE_TRUE_MONEY end |
#type_vattanac_mini_app? ⇒ Boolean
96 97 98 |
# File 'app/models/vpago/payment_method_decorator.rb', line 96 def type_vattanac_mini_app? type == Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP end |
#type_wingsdk? ⇒ Boolean
92 93 94 |
# File 'app/models/vpago/payment_method_decorator.rb', line 92 def type_wingsdk? type == Spree::PaymentMethod::TYPE_WINGSDK end |
#vapgo_checkout_service ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/models/vpago/payment_method_decorator.rb', line 50 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
46 47 48 |
# File 'app/models/vpago/payment_method_decorator.rb', line 46 def vpago_payment? self.class.vpago_payments.include?(type) end |