Files
openfoodnetwork/lib/stripe/credit_card_remover.rb
2020-12-12 21:39:21 -05:00

18 lines
467 B
Ruby

# frozen_string_literal: true
require 'stripe/credit_card_clone_destroyer'
module Stripe
class CreditCardRemover
def initialize(credit_card)
@credit_card = credit_card
end
def call
Stripe::CreditCardCloneDestroyer.new.destroy_clones(@credit_card)
stripe_customer = Stripe::Customer.retrieve(@credit_card.gateway_customer_profile_id, {})
stripe_customer.delete if stripe_customer && !stripe_customer.deleted?
end
end
end