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:
Matt-Yorkley
2021-06-09 22:35:02 +01:00
parent e5a85caef6
commit 65d9325287

View File

@@ -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