Skip to content

Commit

Permalink
Adding self.sync to fake processor for a consistent API (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizkowalski authored Dec 20, 2024
1 parent cfec031 commit 7a8f373
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ This is a major change to add Stripe tax support, Stripe metered billing, new co

### Method Additions and Changes

In an effort to keep a consistant naming convention, the email parameters of `subscription` and `charge` have been updated to have `pay_` prepended to them (`pay_subscription` and `pay_charge` respectively). If you are directly using any of the built in emails or created custom Pay views, you will want to be sure to update your parameter names to the updated names.
In an effort to keep a consistent naming convention, the email parameters of `subscription` and `charge` have been updated to have `pay_` prepended to them (`pay_subscription` and `pay_charge` respectively). If you are directly using any of the built in emails or created custom Pay views, you will want to be sure to update your parameter names to the updated names.

You'll need to replace all references to:
```ruby
Expand All @@ -120,7 +120,7 @@ params[:subscription] with params[:pay_subscription]

The `send_emails` configuration variable has been removed from Pay and replaced by the new configuration system which is discussed below. `Pay.send_emails` is primarily used internally, but if you have been using it in your application code you will need to update those areas to use the new method calls from the email configuration settings. For example, to check if the receipt email should be sent you can now call `Pay.send_email?(:receipt)`. If your email configuration option uses a lambda, you can pass any additional arguments to `send_email?` like so `Pay.send_email?(:receipt, pay_charge)` for use in the lambda.

The `update_email!` method has been replaced with `update_customer!`. When dealing with a `Stripe::Billable` or `Braintree::Billable` object, a hash of additional attributes can be passed in that will be merged into the default atrributes.
The `update_email!` method has been replaced with `update_customer!`. When dealing with a `Stripe::Billable` or `Braintree::Billable` object, a hash of additional attributes can be passed in that will be merged into the default attributes.

The `Stripe::Subscription#cancel_now!` method now accepts a hash of options such as `cancel_now!(prorate: true, invoice_now: true)` which will be handled automatically by Stripe.

Expand Down
6 changes: 5 additions & 1 deletion app/models/pay/fake_processor/subscription.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module Pay
module FakeProcessor
class Subscription < Pay::Subscription
def self.sync(processor_id, **options)
# Bypass sync operation for FakeProcessor
end

def api_record(**options)
self
end

# With trial, sets end to trial end (mimicing Stripe)
# With trial, sets end to trial end (mimicking Stripe)
# Without trial, sets can ends_at to end of month
def cancel(**options)
return if canceled?
Expand Down
6 changes: 6 additions & 0 deletions test/pay/fake_processor/subscription_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@ class Pay::FakeProcessor::Subscription::Test < ActiveSupport::TestCase
assert @subscription.canceled?
refute @subscription.resumable?
end

test "fake processor sync!" do
assert_nothing_raised do
@subscription.sync!
end
end
end

0 comments on commit 7a8f373

Please sign in to comment.