class Reji::Payment
Public Class Methods
new(payment_intent)
click to toggle source
# File lib/reji/payment.rb, line 5 def initialize(payment_intent) @payment_intent = payment_intent end
Public Instance Methods
amount()
click to toggle source
Get the total amount that will be paid.
# File lib/reji/payment.rb, line 10 def amount Reji.format_amount(raw_amount, @payment_intent.currency) end
as_stripe_payment_intent()
click to toggle source
The Stripe PaymentIntent instance.
# File lib/reji/payment.rb, line 52 def as_stripe_payment_intent @payment_intent end
cancelled?()
click to toggle source
Determine if the payment was cancelled.
# File lib/reji/payment.rb, line 35 def cancelled? @payment_intent.status == 'canceled' end
client_secret()
click to toggle source
The Stripe PaymentIntent client secret.
# File lib/reji/payment.rb, line 20 def client_secret @payment_intent.client_secret end
method_missing(key)
click to toggle source
Dynamically get values from the Stripe PaymentIntent.
# File lib/reji/payment.rb, line 57 def method_missing(key) @payment_intent[key] end
raw_amount()
click to toggle source
Get the raw total amount that will be paid.
# File lib/reji/payment.rb, line 15 def raw_amount @payment_intent.amount end
requires_action()
click to toggle source
Determine if the payment needs an extra action like 3D Secure.
# File lib/reji/payment.rb, line 30 def requires_action @payment_intent.status == 'requires_action' end
requires_payment_method()
click to toggle source
Determine if the payment needs a valid payment method.
# File lib/reji/payment.rb, line 25 def requires_payment_method @payment_intent.status == 'requires_payment_method' end
respond_to_missing?(method_name, include_private = false)
click to toggle source
Calls superclass method
# File lib/reji/payment.rb, line 61 def respond_to_missing?(method_name, include_private = false) super end
succeeded?()
click to toggle source
Determine if the payment was successful.
# File lib/reji/payment.rb, line 40 def succeeded? @payment_intent.status == 'succeeded' end
validate()
click to toggle source
Validate if the payment intent was successful and throw an exception if not.
# File lib/reji/payment.rb, line 45 def validate raise Reji::PaymentFailureError.invalid_payment_method(self) if requires_payment_method raise Reji::PaymentActionRequiredError.incomplete(self) if requires_action end