Skip to content

Commit

Permalink
Merge branch 'main' into non-http-webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov committed Jun 12, 2023
2 parents b7e1629 + b0ad8f9 commit 42c3dec
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 50 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: Remove Gemfile.lock
run: rm Gemfile.lock
- name: Set up Ruby ${{ matrix.version }}
uses: ruby/setup-ruby@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.3
3.2.2
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
Unreleased
----------

* Adds support for toggling test charges within `EnsureBilling` by adding `test` field to `BillingConfiguration` and pulling in environment variable [#1688](https://github.com/Shopify/shopify_app/pull/1688)
* Fix registration of event_bridge and pub_sub webhooks [#1635](https://github.com/Shopify/shopify_app/pull/1635)

21.5.0 (May 18, 2023)
----------
* Support Unified Admin [#1658](https://github.com/Shopify/shopify_app/pull/1658)
* Set `access_scopes` column to string by default [#1636](https://github.com/Shopify/shopify_app/pull/1636)
* Fixes a bug with `EnsureBilling` causing infinite redirect in embedded apps [#1578](https://github.com/Shopify/shopify_app/pull/1578)
* Modifies SessionStorage#with_shopify_session to call a block with a supplied session instance [#1488](https://github.com/Shopify/shopify_app/pull/1488)
* Refactors `ShopifyApp::WebhhooksManager#recreate_webhooks!` to have a uniform webhook inventory that doesn't clash with the API library. Updates webhook generator to use supplied session. [#1686](https://github.com/Shopify/shopify_app/pull/1686)
* Fix registration of event_bridge and pub_sub webhooks [#1635](https://github.com/Shopify/shopify_app/pull/1635)
* No longer use session repository from API library[#1689](https://github.com/Shopify/shopify_app/pull/1689)

21.4.1 (Feb 21, 2023)
----------
Expand Down
7 changes: 0 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ gemspec
gem "rails-controller-testing", group: :test
gem "rails", "< 7" # temporary: https://github.com/Shopify/shopify_app/pull/1561

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.1")
# Default gems removed from stdlib in Ruby 3.1.0
gem "net-imap", require: false
gem "net-pop", require: false
gem "net-smtp", require: false
end

group :rubocop do
gem "rubocop-shopify", require: false
end
58 changes: 30 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
PATH
remote: .
specs:
shopify_app (21.4.1)
shopify_app (21.5.0)
activeresource
addressable (~> 2.7)
browser_sniffer (~> 2.0)
jwt (>= 2.2.3)
rails (> 5.2.1)
redirect_safely (~> 1.0)
shopify_api (~> 12.4)
shopify_api (~> 13.0)
sprockets-rails (>= 2.0.0)

GEM
Expand Down Expand Up @@ -81,7 +81,7 @@ GEM
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.1)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
binding_of_caller (1.0.0)
Expand All @@ -104,14 +104,14 @@ GEM
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.12.0)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
json (2.6.3)
jwt (2.7.0)
language_server-protocol (3.17.0.3)
loofah (2.19.1)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
nokogiri (>= 1.12.0)
mail (2.8.1)
mini_mime (>= 0.1.1)
net-imap
Expand All @@ -133,17 +133,17 @@ GEM
timeout
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.14.2-arm64-darwin)
nio4r (2.5.9)
nokogiri (1.15.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.2-x86_64-darwin)
nokogiri (1.15.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.14.2-x86_64-linux)
nokogiri (1.15.0-x86_64-linux)
racc (~> 1.4)
oj (3.14.2)
oj (3.14.3)
openssl (3.1.0)
parallel (1.22.1)
parser (3.2.1.1)
parallel (1.23.0)
parser (3.2.2.1)
ast (~> 2.4.1)
prettier_print (1.2.1)
pry (0.14.2)
Expand All @@ -156,7 +156,7 @@ GEM
pry (~> 0.13)
public_suffix (5.0.1)
racc (1.6.2)
rack (2.2.6.4)
rack (2.2.7)
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.7.3)
Expand Down Expand Up @@ -194,30 +194,30 @@ GEM
rb-readline (0.5.5)
redirect_safely (1.0.0)
activemodel
regexp_parser (2.7.0)
regexp_parser (2.8.0)
rexml (3.2.5)
rubocop (1.48.1)
rubocop (1.51.0)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.26.0, < 2.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.0)
rubocop-ast (1.28.1)
parser (>= 3.2.1.0)
rubocop-shopify (2.12.0)
rubocop (~> 1.44)
ruby-lsp (0.4.2)
rubocop-shopify (2.13.0)
rubocop (~> 1.50)
ruby-lsp (0.5.1)
language_server-protocol (~> 3.17.0)
sorbet-runtime
syntax_tree (>= 6.0.2, < 7)
syntax_tree (>= 6.1.1, < 7)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
securerandom (0.2.2)
shopify_api (12.4.0)
shopify_api (13.0.0)
activesupport
concurrent-ruby
hash_diff
Expand All @@ -228,20 +228,20 @@ GEM
securerandom
sorbet-runtime
zeitwerk (~> 2.5, < 2.6.5)
sorbet-runtime (0.5.10736)
sorbet-runtime (0.5.10835)
sprockets (4.2.0)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sqlite3 (1.6.2-arm64-darwin)
sqlite3 (1.6.2-x86_64-darwin)
sqlite3 (1.6.2-x86_64-linux)
sqlite3 (1.6.3-arm64-darwin)
sqlite3 (1.6.3-x86_64-darwin)
sqlite3 (1.6.3-x86_64-linux)
syntax_tree (6.1.1)
prettier_print (>= 1.2.0)
thor (1.2.1)
thor (1.2.2)
timeout (0.3.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand All @@ -257,7 +257,9 @@ GEM

PLATFORMS
arm64-darwin-21
arm64-darwin-22
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-21
x86_64-linux

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ShopifyApp.configure do |config|
# amount: 5,
# interval: ShopifyApp::BillingConfiguration::INTERVAL_EVERY_30_DAYS,
# currency_code: "USD", # Only supports USD for now
# test: ENV.fetch('SHOPIFY_TEST_CHARGES', !Rails.env.production?)
# )

if defined? Rails::Server
Expand Down
4 changes: 3 additions & 1 deletion lib/shopify_app/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ class BillingConfiguration
attr_reader :amount
attr_reader :currency_code
attr_reader :interval
attr_reader :test

def initialize(charge_name:, amount:, interval:, currency_code: "USD")
def initialize(charge_name:, amount:, interval:, currency_code: "USD", test: !Rails.env.production?)
@charge_name = charge_name
@amount = amount
@currency_code = currency_code
@interval = interval
@test = test
end
end

Expand Down
12 changes: 6 additions & 6 deletions lib/shopify_app/controller_concerns/ensure_billing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def request_recurring_payment(session:, return_url:)
},
},
returnUrl: return_url,
test: !Rails.env.production?,
test: ShopifyApp.configuration.billing.test,
},
)

Expand All @@ -154,7 +154,7 @@ def request_one_time_payment(session:, return_url:)
currencyCode: ShopifyApp.configuration.billing.currency_code,
},
returnUrl: return_url,
test: !Rails.env.production?,
test: ShopifyApp.configuration.billing.test,
},
)

Expand All @@ -176,7 +176,7 @@ def run_query(session:, query:, variables: nil)
response
end

RECURRING_PURCHASES_QUERY = <<~'QUERY'
RECURRING_PURCHASES_QUERY = <<~QUERY
query appSubscription {
currentAppInstallation {
activeSubscriptions {
Expand All @@ -186,7 +186,7 @@ def run_query(session:, query:, variables: nil)
}
QUERY

ONE_TIME_PURCHASES_QUERY = <<~'QUERY'
ONE_TIME_PURCHASES_QUERY = <<~QUERY
query appPurchases($endCursor: String) {
currentAppInstallation {
oneTimePurchases(first: 250, sortKey: CREATED_AT, after: $endCursor) {
Expand All @@ -203,7 +203,7 @@ def run_query(session:, query:, variables: nil)
}
QUERY

RECURRING_PURCHASE_MUTATION = <<~'QUERY'
RECURRING_PURCHASE_MUTATION = <<~QUERY
mutation createPaymentMutation(
$name: String!
$lineItems: [AppSubscriptionLineItemInput!]!
Expand All @@ -224,7 +224,7 @@ def run_query(session:, query:, variables: nil)
}
QUERY

ONE_TIME_PURCHASE_MUTATION = <<~'QUERY'
ONE_TIME_PURCHASE_MUTATION = <<~QUERY
mutation createPaymentMutation(
$name: String!
$price: MoneyInput!
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_app/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ShopifyApp
VERSION = "21.4.1"
VERSION = "21.5.0"
end
2 changes: 1 addition & 1 deletion shopify_app.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("jwt", ">= 2.2.3")
s.add_runtime_dependency("rails", "> 5.2.1")
s.add_runtime_dependency("redirect_safely", "~> 1.0")
s.add_runtime_dependency("shopify_api", "~> 12.4")
s.add_runtime_dependency("shopify_api", "~> 13.0")
s.add_runtime_dependency("sprockets-rails", ">= 2.0.0")

s.add_development_dependency("byebug")
Expand Down
19 changes: 19 additions & 0 deletions test/controllers/concerns/ensure_billing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ def index
ShopifyAppConfigurer.setup_context
end

test "billing configuration with test charges default" do
ShopifyApp.configuration.billing = ShopifyApp::BillingConfiguration.new(
charge_name: TEST_CHARGE_NAME,
amount: 5,
interval: ShopifyApp::BillingConfiguration::INTERVAL_ONE_TIME,
)
assert(ShopifyApp.configuration.billing.test)
end

test "billing configuration with real" do
ShopifyApp.configuration.billing = ShopifyApp::BillingConfiguration.new(
charge_name: TEST_CHARGE_NAME,
amount: 5,
interval: ShopifyApp::BillingConfiguration::INTERVAL_ONE_TIME,
test: false,
)
assert_not(ShopifyApp.configuration.billing.test)
end

test "requires single payment if none exists and non recurring" do
ShopifyApp.configuration.billing = ShopifyApp::BillingConfiguration.new(
charge_name: TEST_CHARGE_NAME,
Expand Down
1 change: 0 additions & 1 deletion test/test_helpers/fake_session_storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module TestHelpers
class FakeSessionStorage
extend T::Sig
include ShopifyAPI::Auth::SessionStorage

sig { returns(T::Hash[String, ShopifyAPI::Auth::Session]) }
attr_reader :sessions
Expand Down
1 change: 0 additions & 1 deletion test/utils/rails_generator_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def with_session(test_class, is_embedded: false, is_private: false, &block)
scope: ShopifyApp.configuration.scope,
is_private: is_private,
is_embedded: is_embedded,
session_storage: TestHelpers::FakeSessionStorage.new,
user_agent_prefix: nil,
)
ShopifyAPI::Context.activate_session(ShopifyAPI::Auth::Session.new(shop: "my-shop"))
Expand Down

0 comments on commit 42c3dec

Please sign in to comment.