Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/models/spree/payment_method/stripe_credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def create_profile(payment)
}.merge! address_for(payment)

source = update_source!(payment.source)
if source.number.blank? && source.gateway_payment_profile_id.present?
if reuse_existing_source?(source)
if v3_intents?
creditcard = ActiveMerchant::Billing::StripeGateway::StripePaymentToken.new('id' => source.gateway_payment_profile_id)
else
Expand All @@ -124,7 +124,7 @@ def create_profile(payment)

response = gateway.store(creditcard, options)
if response.success?
if v3_intents?
if v3_intents? && reuse_existing_source?(source)
payment.source.update!(
cc_type: payment.source.cc_type,
gateway_customer_profile_id: response.params['customer'],
Expand Down Expand Up @@ -212,6 +212,10 @@ def perform_refund(payment)

refund
end

def reuse_existing_source?(source)
source.number.blank? && source.gateway_payment_profile_id.present?
end
end
end
end