Class: Spree::PaymentMethod::NpAtobarai
- Inherits:
-
Spree::PaymentMethod
- Object
- Spree::PaymentMethod
- Spree::PaymentMethod::NpAtobarai
- Defined in:
- app/models/spree/payment_method/np_atobarai.rb
Constant Summary collapse
- INVOICE_SENDING_OPTIONS =
[ :postal, :email ]
Class Method Summary collapse
- .destroy_np_atobarai_adjustments(order) ⇒ Object
- .invoice_sending_options ⇒ Object
- .np_atobarai_fee_label ⇒ Object
Instance Method Summary collapse
- #actions ⇒ Object
-
#can_capture?(payment) ⇒ Boolean
Indicates whether its possible to capture the payment.
-
#can_void?(payment) ⇒ Boolean
Indicates whether its possible to void the payment.
- #cancel ⇒ Object
- #capture ⇒ Object
- #create_np_atobarai_fee_adjustment!(order) ⇒ Object
- #custom_form_fields_partial_name ⇒ Object
- #np_atobarai_fee_adjustment_applicable?(order, payment) ⇒ Boolean
- #source_required? ⇒ Boolean
- #void ⇒ Object
Class Method Details
.destroy_np_atobarai_adjustments(order) ⇒ Object
61 62 63 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 61 def (order) order.adjustments.where(label: ).destroy_all end |
.invoice_sending_options ⇒ Object
69 70 71 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 69 def Spree::Payment.invoice_sendings.slice(*INVOICE_SENDING_OPTIONS) end |
.np_atobarai_fee_label ⇒ Object
65 66 67 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 65 def Spree.t('np_atobarai_fee_adjustment') end |
Instance Method Details
#actions ⇒ Object
8 9 10 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 8 def actions %w[capture void] end |
#can_capture?(payment) ⇒ Boolean
Indicates whether its possible to capture the payment
13 14 15 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 13 def can_capture?(payment) [ 'checkout', 'pending' ].include?(payment.state) end |
#can_void?(payment) ⇒ Boolean
Indicates whether its possible to void the payment.
18 19 20 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 18 def can_void?(payment) payment.state != 'void' end |
#cancel ⇒ Object
30 31 32 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 30 def cancel(*) ActiveMerchant::Billing::Response.new(true, "", {}, {}) end |
#capture ⇒ Object
26 27 28 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 26 def capture(*) ActiveMerchant::Billing::Response.new(true, "", {}, {}) end |
#create_np_atobarai_fee_adjustment!(order) ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 50 def (order) adjustment = order.adjustments.new adjustment.source = self adjustment.order = order adjustment.amount = adjustment.label = adjustment.save! adjustment end |
#custom_form_fields_partial_name ⇒ Object
22 23 24 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 22 def custom_form_fields_partial_name 'np_atobarai_form_fields' end |
#np_atobarai_fee_adjustment_applicable?(order, payment) ⇒ Boolean
42 43 44 45 46 47 48 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 42 def (order, payment) return false if .blank? || order.blank? || payment&.invoice_sending_email? return true if .blank? !(order.billing_address&.phone) end |
#source_required? ⇒ Boolean
38 39 40 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 38 def source_required? false end |
#void ⇒ Object
34 35 36 |
# File 'app/models/spree/payment_method/np_atobarai.rb', line 34 def void(*) ActiveMerchant::Billing::Response.new(true, "", {}, {}) end |