StripePaymentIntentsGateway decorator, remove store

This commit is contained in:
Gaetan Craig-Riou
2024-02-05 16:26:28 +11:00
parent 8a0c32eec0
commit 84f53abdfe
2 changed files with 3 additions and 23 deletions

View File

@@ -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 = {})

View File

@@ -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?