Created
August 10, 2023 15:07
-
-
Save stuartchaney/099cdd31f09f9cc280f4deccad22392c to your computer and use it in GitHub Desktop.
Service object to determine test transactions for a Shop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DetermineTestTransaction < ApplicationService | |
attr_reader :shop | |
def initialize(shop) | |
@shop = shop | |
end | |
def perform | |
is_test_environment? || test_eligible_shop? | |
end | |
private | |
def is_test_environment? | |
%w[development staging test].include?(Rails.env) | |
end | |
def test_eligible_shop? | |
shop.test_charges_enabled || | |
%w[YOUREMAIL].any? { |test_email| shop.email.include?(test_email) } || | |
%w[partner_test staff shopify_alumni plus_partner_sandbox open_learning].include?(shop.plan_name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment