diff --git a/app/services/paypal_items_builder.rb b/app/services/paypal_items_builder.rb index 771e21dac8..dadfb04283 100644 --- a/app/services/paypal_items_builder.rb +++ b/app/services/paypal_items_builder.rb @@ -8,11 +8,7 @@ class PaypalItemsBuilder def call items = order.line_items.map(&method(:line_item_data)) - shipping_and_tax_adjustments = order.all_adjustments.shipping + order.all_adjustments.tax - - order.all_adjustments.eligible.each do |adjustment| - next if shipping_and_tax_adjustments.include?(adjustment) - + relevant_adjustments.each do |adjustment| items << adjustment_data(adjustment) end @@ -30,6 +26,11 @@ class PaypalItemsBuilder attr_reader :order + def relevant_adjustments + # Tax total and shipping costs are added separately, so they're not included here. + order.all_adjustments.eligible - order.all_adjustments.tax - order.all_adjustments.shipping + end + def line_item_data(item) { Name: item.product.name,