Class: Spree::Alipayinfo
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::Alipayinfo
- Defined in:
- app/models/spree/alipayinfo.rb
Constant Summary collapse
- NECESSARY =
%w(Mode PaymentID DateCreated MerchantRefNo Amount TransactionID ResponseCode ResponseMessage).freeze
Instance Method Summary collapse
- #actions ⇒ Object
-
#can_mark_as_captured?(payment) ⇒ Boolean
Indicates whether it’s possible to capture the payment.
-
#can_void?(payment) ⇒ Boolean
Indicates whether it’s possible to void the payment.
- #mark_as_captured(payment) ⇒ Object
- #void(payment) ⇒ Object
Instance Method Details
#actions ⇒ Object
9 10 11 |
# File 'app/models/spree/alipayinfo.rb', line 9 def actions %w(mark_as_captured void) end |
#can_mark_as_captured?(payment) ⇒ Boolean
Indicates whether it’s possible to capture the payment
14 15 16 |
# File 'app/models/spree/alipayinfo.rb', line 14 def can_mark_as_captured?(payment) ['checkout', 'pending'].include?(payment.state) end |
#can_void?(payment) ⇒ Boolean
Indicates whether it’s possible to void the payment.
19 20 21 |
# File 'app/models/spree/alipayinfo.rb', line 19 def can_void?(payment) payment.state != 'void' end |
#mark_as_captured(payment) ⇒ Object
23 24 25 26 27 |
# File 'app/models/spree/alipayinfo.rb', line 23 def mark_as_captured(payment) payment.update_attribute(:state, 'pending') if payment.state == 'checkout' payment.complete true end |
#void(payment) ⇒ Object
29 30 31 32 33 |
# File 'app/models/spree/alipayinfo.rb', line 29 def void(payment) payment.update_attribute(:state, 'pending') if payment.state == 'checkout' payment.void true end |