From 84f53abdfe5ba365d687bce8b35aadc8bbfa2adf Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Mon, 5 Feb 2024 16:26:28 +1100 Subject: [PATCH] StripePaymentIntentsGateway decorator, remove `store` --- .../stripe_payment_intents_decorator.rb | 22 ------------------- lib/stripe/profile_storer.rb | 4 +++- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/lib/active_merchant/billing/gateways/stripe_payment_intents_decorator.rb b/lib/active_merchant/billing/gateways/stripe_payment_intents_decorator.rb index eb29ca560a..0ea1625b1a 100644 --- a/lib/active_merchant/billing/gateways/stripe_payment_intents_decorator.rb +++ b/lib/active_merchant/billing/gateways/stripe_payment_intents_decorator.rb @@ -37,28 +37,6 @@ ActiveMerchant::Billing::StripePaymentIntentsGateway.class_eval do super(money, charge_id, options) end - # Note: Not all payment methods are currently supported by the - # {Payment Methods API}[https://stripe.com/docs/payments/payment-methods] - # Current implementation will create a PaymentMethod object if the method is a token - # or credit card - # All other types will default to legacy Stripe store - def store(payment_method, options = {}) - params = {} - post = {} - - # If customer option is provided, create a payment method and attach to customer id - # Otherwise, create a customer, then attach - result = add_payment_method_token(params, payment_method, options) - return result if result.is_a?(ActiveMerchant::Billing::Response) - - customer_id = options[:customer] || customer(post, payment_method, options).params['id'] - options = format_idempotency_key(options, 'attach') - attach_parameters = { customer: customer_id } - attach_parameters[:validate] = options[:validate] unless options[:validate].nil? - - commit(:post, "payment_methods/#{params[:payment_method]}/attach", attach_parameters, options) - end - private def add_connected_account(post, options = {}) diff --git a/lib/stripe/profile_storer.rb b/lib/stripe/profile_storer.rb index 688bb4f9e8..ba3cc7b0aa 100644 --- a/lib/stripe/profile_storer.rb +++ b/lib/stripe/profile_storer.rb @@ -12,7 +12,9 @@ module Stripe end def create_customer_from_token - token = @payment.source.gateway_payment_profile_id + token = ActiveMerchant::Billing::StripeGateway::StripePaymentToken.new( + { 'id' => @payment.source.gateway_payment_profile_id } + ) response = @provider.store(token, options) if response.success?