Sha256: 0cfdc44e22c42d535604a4c2e377202c8eca050ed16eeff617997caa2ebf34c3
Contents?: true
Size: 1011 Bytes
Versions: 33
Compression:
Stored size: 1011 Bytes
Contents
module Pay class Payment attr_reader :intent delegate :id, :amount, :client_secret, :status, :confirm, to: :intent def self.from_id(id) intent = id.start_with?("seti_") ? ::Stripe::SetupIntent.retrieve(id) : ::Stripe::PaymentIntent.retrieve(id) new(intent) end def initialize(intent) @intent = intent end def requires_payment_method? status == "requires_payment_method" end def requires_action? status == "requires_action" end def canceled? status == "canceled" end def cancelled? canceled? end def succeeded? status == "succeeded" end def payment_intent? intent.is_a?(::Stripe::PaymentIntent) end def setup_intent? intent.is_a?(::Stripe::SetupIntent) end def validate if requires_payment_method? raise Pay::InvalidPaymentMethod.new(self) elsif requires_action? raise Pay::ActionRequired.new(self) end end end end
Version data entries
33 entries across 33 versions & 1 rubygems