Class: MercadoPago::ProcessNotification
- Inherits:
-
Object
- Object
- MercadoPago::ProcessNotification
- Defined in:
- app/services/mercado_pago/process_notification.rb
Constant Summary collapse
- STATES =
Equivalent payment states MP state => Spree state
approved => complete pending => pend in_process => pend rejected => failed refunded => void cancelled => void in_mediation => pend charged_back => void
{ complete: %w(approved), failure: %w(rejected), void: %w(refunded cancelled charged_back) }
Instance Attribute Summary collapse
-
#notification ⇒ Object
readonly
Returns the value of attribute notification.
Instance Method Summary collapse
-
#initialize(notification) ⇒ ProcessNotification
constructor
A new instance of ProcessNotification.
- #process! ⇒ Object
Constructor Details
#initialize(notification) ⇒ ProcessNotification
Returns a new instance of ProcessNotification.
32 33 34 |
# File 'app/services/mercado_pago/process_notification.rb', line 32 def initialize(notification) @notification = notification end |
Instance Attribute Details
#notification ⇒ Object (readonly)
Returns the value of attribute notification.
30 31 32 |
# File 'app/services/mercado_pago/process_notification.rb', line 30 def notification @notification end |
Instance Method Details
#process! ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/mercado_pago/process_notification.rb', line 36 def process! client = ::Spree::PaymentMethod::MercadoPago.provider op_info = client.get_operation_info(notification.operation_id)["collection"] if payment = Spree::Payment.where(identifier: op_info["external_reference"]).first if STATES[:complete].include?(op_info["status"]) payment.complete elsif STATES[:failure].include?(op_info["status"]) payment.failure elsif STATES[:void].include?(op_info["status"]) payment.void end # When Spree issue #5246 is fixed we can remove this line payment.order.updater.update end end |