Skip to content

Commit

Permalink
Split the transfer in dollars
Browse files Browse the repository at this point in the history
  • Loading branch information
zspencer committed Oct 24, 2024
1 parent 0b22f77 commit b366abe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/furniture/marketplace/split_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 20 additions & 1 deletion spec/furniture/marketplace/split_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b366abe

Please sign in to comment.