Skip to content

Instantly share code, notes, and snippets.

@stuartchaney
Created August 10, 2023 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartchaney/099cdd31f09f9cc280f4deccad22392c to your computer and use it in GitHub Desktop.
Save stuartchaney/099cdd31f09f9cc280f4deccad22392c to your computer and use it in GitHub Desktop.
Service object to determine test transactions for a Shop
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