diff --git a/app/services/spree_stripe/create_source.rb b/app/services/spree_stripe/create_source.rb index f445a23..22a10d5 100644 --- a/app/services/spree_stripe/create_source.rb +++ b/app/services/spree_stripe/create_source.rb @@ -37,7 +37,7 @@ def call when 'customer_balance', 'us_bank_account' SpreeStripe::PaymentSources::BankTransfer.create!(source_params) else - raise "[STRIPE] Unknown payment method #{stripe_payment_method_details.type}" + Spree::PaymentSource.create!(source_params) end end diff --git a/spec/services/spree_stripe/create_source_spec.rb b/spec/services/spree_stripe/create_source_spec.rb index b0129d5..ce9e4ad 100644 --- a/spec/services/spree_stripe/create_source_spec.rb +++ b/spec/services/spree_stripe/create_source_spec.rb @@ -227,5 +227,25 @@ expect(subject).to be_a(SpreeStripe::PaymentSources::Link) end end + + context 'if source is cashapp' do + let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'cashapp') } + + it 'creates a generic PaymentSource' do + expect(subject).to be_a(Spree::PaymentSource) + expect(subject.gateway_payment_profile_id).to eq source_id + expect(subject.payment_method).to eq gateway + end + end + + context 'if source is an unknown type' do + let(:payment_method_details) { Stripe::StripeObject.construct_from(type: 'some_future_method') } + + it 'creates a generic PaymentSource' do + expect(subject).to be_a(Spree::PaymentSource) + expect(subject.gateway_payment_profile_id).to eq source_id + expect(subject.payment_method).to eq gateway + end + end end end