Skip to content

Commit

Permalink
Fix issue with Paddle Billing Charges when there's no payment details (
Browse files Browse the repository at this point in the history
…#872)

* Only grab/set payment method details if there is a payment on a paddle transaction

* standardrb fix
  • Loading branch information
deanpcmad authored Oct 18, 2023
1 parent 0c4bb20 commit 3561698
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/pay/paddle/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,21 @@ def self.sync(charge_id, object: nil, try: 0, retries: 1)
subscription: pay_customer.subscriptions.find_by(processor_id: object.subscription_id)
}

case object.payment.method_details.type.downcase
when "card"
attrs[:payment_method_type] = "card"
attrs[:brand] = details.card.type
attrs[:exp_month] = details.card.expiry_month
attrs[:exp_year] = details.card.expiry_year
attrs[:last4] = details.card.last4
when "paypal"
attrs[:payment_method_type] = "paypal"
end
if object.payment
case object.payment.method_details.type.downcase
when "card"
attrs[:payment_method_type] = "card"
attrs[:brand] = details.card.type
attrs[:exp_month] = details.card.expiry_month
attrs[:exp_year] = details.card.expiry_year
attrs[:last4] = details.card.last4
when "paypal"
attrs[:payment_method_type] = "paypal"
end

# Update customer's payment method
Pay::Paddle::PaymentMethod.sync(pay_customer: pay_customer, attributes: object.payments.first)
# Update customer's payment method
Pay::Paddle::PaymentMethod.sync(pay_customer: pay_customer, attributes: object.payments.first)
end

# Update or create the charge
if (pay_charge = pay_customer.charges.find_by(processor_id: object.id))
Expand Down

0 comments on commit 3561698

Please sign in to comment.