Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix: Built payment webhook URLs with a scheme (#15058)
Damian Legawiecdb0f23d5c7f3
diff --git a/spree/core/app/models/spree/payment_method.rb b/spree/core/app/models/spree/payment_method.rbindex 52675ee880..7ee74537e5 100644--- a/spree/core/app/models/spree/payment_method.rb+++ b/spree/core/app/models/spree/payment_method.rb@@ -197,7 +197,7 @@ module Spreedef webhook_urlreturn nil unless store- "#{store.url_or_custom_domain}/api/v3/webhooks/payments/#{prefixed_id}"+ "#{store.formatted_url_or_custom_domain}/api/v3/webhooks/payments/#{prefixed_id}"endclass WebhookSignatureError < StandardError; enddiff --git a/spree/core/spec/models/spree/payment_method_spec.rb b/spree/core/spec/models/spree/payment_method_spec.rbindex 4b0eb1e7fd..71ce72b0a8 100644--- a/spree/core/spec/models/spree/payment_method_spec.rb+++ b/spree/core/spec/models/spree/payment_method_spec.rb@@ -116,6 +116,19 @@ describe Spree::PaymentMethod, type: :model doendend+ describe '#webhook_url' do+ let(:payment_method) { create(:credit_card_payment_method) }++ it 'is an absolute url when the store url is a bare host' do+ store.update!(url: 'shop.example.com')++ url = payment_method.webhook_url++ expect(URI.parse(url).scheme).to be_present+ expect(url).to end_with("/api/v3/webhooks/payments/#{payment_method.prefixed_id}")+ end+ end+describe '#gateway_amount' doit 'hands a method that takes money amounts the amount with its currency' domethod = Spree::Gateway::Bogus.newdiff --git a/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rb b/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rbindex 9bf1437ea9..1092042b78 100644--- a/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rb+++ b/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rb@@ -93,7 +93,7 @@ module SpreeStripedef connect_webhook_urlreturn nil unless store- "#{store.url_or_custom_domain}/api/v3/webhooks/payouts/#{prefixed_id}"+ "#{store.formatted_url_or_custom_domain}/api/v3/webhooks/payouts/#{prefixed_id}"enddef create_connect_webhook_endpointdiff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rbindex 753e88e079..4815fbf7db 100644--- a/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rb+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rb@@ -405,5 +405,11 @@ RSpec.describe SpreeStripe::Gateway::Connect doexpect(gateway.connect_webhook_url).to end_with("/api/v3/webhooks/payouts/#{gateway.prefixed_id}")expect(gateway.connect_webhook_url).not_to eq(gateway.webhook_url)end++ it 'is an absolute url when the store url is a bare host' do+ gateway.store.update!(url: 'shop.example.com')++ expect(URI.parse(gateway.connect_webhook_url).scheme).to be_present+ endendenddiff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rbindex 83f61e1923..1ce2f5dda1 100644--- a/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb@@ -241,7 +241,13 @@ RSpec.describe SpreeStripe::Gateway dosubject { gateway.webhook_url }it 'returns the core payment webhook url' do- expect(subject).to eq("#{store.url_or_custom_domain}/api/v3/webhooks/payments/#{gateway.prefixed_id}")+ expect(subject).to eq("#{store.formatted_url_or_custom_domain}/api/v3/webhooks/payments/#{gateway.prefixed_id}")+ end++ it 'is an absolute url when the store url is a bare host' do+ store.update!(url: 'shop.example.com')++ expect(URI.parse(subject).scheme).to be_presentendend