Skip to content

Commit

Permalink
Do not set @client_secret and @pk_key if order has no valid payments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexboldak committed May 29, 2022
1 parent 9f51547 commit 6fc98ae
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ def self.prepended(base)

def process_payments_and_set_keys
@order.tap do |order|
@client_secret = nil
@pk_key = nil

order.process_payments!
order.reload.payments.valid.where.not(intent_client_key: nil).last.tap do |payment|
@client_secret = payment.intent_client_key
@pk_key = payment.payment_method.preferred_publishable_key
last_valid_payment = order.reload.payments.valid.where.not(intent_client_key: nil).last

if last_valid_payment
@client_secret = last_valid_payment.intent_client_key
@pk_key = last_valid_payment.payment_method.preferred_publishable_key
end

end
end
end
Expand Down

0 comments on commit 6fc98ae

Please sign in to comment.