mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add #stripe_status helper method to Payment
This method could definitely be used elsewhere, but is currently most useful in debugging; at any time in the console you can bring up a payment object and call #stripe_status on it, and it'll make a live call to Stripe and tell you exactly what state the payment is in on the Stripe side.
This commit is contained in:
@@ -153,6 +153,17 @@ module Spree
|
||||
I18n.t('payment_method_fee')
|
||||
end
|
||||
|
||||
# Returns the current payment status from a live call to the Stripe API.
|
||||
# Returns nil if the payment is not a Stripe payment or does not have a payment intent.
|
||||
# If the payment requires authorization the status will be "requires_action".
|
||||
# If the payment has been captured the status will be "succeeded".
|
||||
# https://stripe.com/docs/api/payment_intents/object#payment_intent_object-status
|
||||
def stripe_status
|
||||
return if response_code.blank?
|
||||
|
||||
Stripe::PaymentIntentValidator.new.call(self).status
|
||||
end
|
||||
|
||||
def clear_authorization_url
|
||||
update_attribute(:cvv_response_message, nil)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user