module Od::Payments::PaymentMethod

Public Class Methods

attach(payment_method_id, customer_id) click to toggle source
# File lib/od/payments/resources/payment_method.rb, line 48
def self.attach(payment_method_id, customer_id)
  Stripe::PaymentMethod.attach(
    payment_method_id,
    { customer: customer_id }
  )
rescue Stripe::CardError => e
  raise Od::Payments::CardError.new(e.error.message, {})
rescue Stripe::StripeError => e
  raise Od::Payments::OdPaymentsError, e.error.message
end
create(params) click to toggle source
# File lib/od/payments/resources/payment_method.rb, line 5
def self.create(params)
  case Od::Payments.adapter
  when :stripe
    Stripe::PaymentMethod.create params
  end
rescue Stripe::CardError => e
  raise Od::Payments::CardError.new(e.error.message, {})
rescue Stripe::StripeError => e
  raise Od::Payments::OdPaymentsError, e.error.message
end
delete(payment_method_id) click to toggle source
# File lib/od/payments/resources/payment_method.rb, line 28
def self.delete(payment_method_id)
  case Od::Payments.adapter
  when :stripe
    Stripe::PaymentMethod.detach(
      payment_method_id
    )
  end
rescue Stripe::StripeError => e
  raise Od::Payments::OdPaymentsError, e.error.message
end
list(customer_id) click to toggle source
# File lib/od/payments/resources/payment_method.rb, line 16
def self.list(customer_id)
  case Od::Payments.adapter
  when :stripe
    Stripe::PaymentMethod.list({
                                 customer: customer_id,
                                 type: 'card'
                               })
  end
rescue Stripe::StripeError => e
  raise Od::Payments::OdPaymentsError, e.error.message
end
show(payment_method_id) click to toggle source
# File lib/od/payments/resources/payment_method.rb, line 39
def self.show(payment_method_id)
  case Od::Payments.adapter
  when :stripe
    Stripe::PaymentIntent.retrieve payment_method_id
  end
rescue Stripe::StripeError => e
  raise Od::Payments::OdPaymentsError, e.error.message
end