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
Improve `PaymentSource` model to work with gateways using payment profiles, eg. Stripe
Damian Legawiec8a74281755dc
diff --git a/core/app/models/spree/payment_source.rb b/core/app/models/spree/payment_source.rbindex 58b747c4d2..57cb81b9bb 100644--- a/core/app/models/spree/payment_source.rb+++ b/core/app/models/spree/payment_source.rb@@ -3,7 +3,7 @@ module Spreeinclude Spree::Metadatabelongs_to :payment_method, class_name: 'Spree::PaymentMethod'- belongs_to :user, class_name: 'Spree::User', optional: true+ belongs_to :user, class_name: Spree.user_class.to_s, optional: truevalidates_uniqueness_of :gateway_payment_profile_id, scope: :typeenddiff --git a/core/db/migrate/20241218183905_add_gateway_customer_profile_id_to_spree_payment_sources.rb b/core/db/migrate/20241218183905_add_gateway_customer_profile_id_to_spree_payment_sources.rbnew file mode 100644index 0000000000..cd37011d3e--- /dev/null+++ b/core/db/migrate/20241218183905_add_gateway_customer_profile_id_to_spree_payment_sources.rb@@ -0,0 +1,5 @@+class AddGatewayCustomerProfileIdToSpreePaymentSources < ActiveRecord::Migration[6.1]+ def change+ add_column :spree_payment_sources, :gateway_customer_profile_id, :string+ end+enddiff --git a/core/spec/services/spree/wallet/create_payment_source_spec.rb b/core/spec/services/spree/wallet/create_payment_source_spec.rbindex baa09a5c5a..cfb057f646 100644--- a/core/spec/services/spree/wallet/create_payment_source_spec.rb+++ b/core/spec/services/spree/wallet/create_payment_source_spec.rb@@ -12,6 +12,7 @@ module Spreelet(:params) do{gateway_payment_profile_id: '12345',+ gateway_customer_profile_id: '67890',cc_type: 'visa',last_digits: '1111',name: 'John',