diff --git a/app/furniture/marketplace/split_job.rb b/app/furniture/marketplace/split_job.rb index 35b3ebc6b..2b2b61f65 100644 --- a/app/furniture/marketplace/split_job.rb +++ b/app/furniture/marketplace/split_job.rb @@ -16,7 +16,7 @@ def perform(order:) end transfer = Stripe::Transfer.create({ - amount: vendors_share.to_i, + amount: vendors_share.cents, currency: "usd", destination: vendor_stripe_account, transfer_group: order.id diff --git a/spec/furniture/marketplace/split_job_spec.rb b/spec/furniture/marketplace/split_job_spec.rb index 6379d4157..0e146dc2e 100644 --- a/spec/furniture/marketplace/split_job_spec.rb +++ b/spec/furniture/marketplace/split_job_spec.rb @@ -3,7 +3,26 @@ RSpec.describe Marketplace::SplitJob, type: :job do describe "#perform" do before do - allow(Stripe::Transfer).to receive(:create) + allow(Stripe::Transfer).to receive(:create).and_return( + double(Stripe::Transfer, id: "trf_1234") # rubocop:disable RSpec/VerifiedDoubles + ) + end + + let(:marketplace) { create(:marketplace, :with_products, :with_stripe_account, :with_stripe_utility) } + let(:order) { create(:marketplace_order, :with_products, marketplace:) } + + it "transfers the vendors share into their account" do + described_class.new.perform(order:) + + expect(Stripe::Transfer).to have_received(:create).with( + { + amount: order.vendors_share.cents, + currency: "usd", + destination: marketplace.vendor_stripe_account, + transfer_group: order.id + }, + {api_key: marketplace.stripe_api_key} + ) end context "when the order has already been split" do