Skip to content

Commit

Permalink
Merge pull request #821 from cjilbert504/paddle-update-payment-method
Browse files Browse the repository at this point in the history
Paddle update payment method
  • Loading branch information
cjilbert504 committed Jun 2, 2023
2 parents 6ed09fd + cba1aa6 commit 2162534
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pay/paddle/billable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ def subscribe(name: Pay.default_product_name, plan: Pay.default_plan_name, **opt
# pass
end

def add_payment_method(token, default: true)
Pay::Paddle::PaymentMethod.sync(self)
# Paddle does not use payment method tokens. The method signature has it here
# to have a uniform API with the other payment processors.
def add_payment_method(token = nil, default: true)
Pay::Paddle::PaymentMethod.sync(pay_customer: pay_customer)
end

def trial_end_date(subscription)
Expand Down
12 changes: 12 additions & 0 deletions test/pay/paddle/billable_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,16 @@ class Pay::Paddle::Billable::Test < ActiveSupport::TestCase
assert_equal "06", @pay_customer.default_payment_method.exp_month
assert_equal "2022", @pay_customer.default_payment_method.exp_year
end

test "paddle can add payment method" do
PaddlePay::Subscription::User.stub(:list, []) do
assert @pay_customer.add_payment_method
end
end

test "paddle can update payment method" do
PaddlePay::Subscription::User.stub(:list, []) do
assert @pay_customer.update_payment_method(nil)
end
end
end

0 comments on commit 2162534

Please sign in to comment.