app/models/spree/gateway/braintree_vzero_base/utils.rb
def collect_line_items # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
          items =
            @order
            .line_items
            .reject { |li| li.price.zero? || li.quantity.zero? }
            .map do |li|
            {
              name: li.name.truncate(127, omission: ''),
              kind: 'debit',
              quantity: li.quantity.to_s,
              unit_amount: li.price.to_s,
              unit_of_measure: 'unit',
              product_code: li.sku,
              total_amount: (li.price * li.quantity).to_s,
              tax_amount: li.additional_tax_total.to_s
            }
          end.
            take(PAYPAL_MAX_LINEITEMS - 1)
          total = @order.adjustment_total.abs
          return items if total.zero?

          items.append({
                         name: 'discount',
                         kind: 'credit',
                         quantity: '1',
                         unit_amount: total.to_s,
                         total_amount: total.to_s
                       })
        end
# Because of strange PayPal behaviour with accepting discounts
# the only solution to add needed discount (if it exist) to
# create a virtual Line Item with discount amount and with 'credit'
# and name it as 'discount' to be reflected in PayPal email to customer
#
Because of strange PayPal behaviour with accepting discounts
the only solution to add needed discount (if it exist) to
create a virtual Line Item with discount amount and with 'credit'
and name it as 'discount' to be reflected in PayPal email to customer
Because of strange PayPal behaviour with accepting discounts the only solution to add needed discount ( if it exist ) to create a virtual Line Item with discount amount and with ' credit ' and name it as ' discount ' to be reflected in PayPal email to customer
def collect_line_items 
          items =
            @order
            .line_items
            .reject { |li| li.price.zero? || li.quantity.zero? }
            .map do |li|
            {
              name: li.name.truncate(127, omission: ''),
              kind: 'debit',
              quantity: li.quantity.to_s,
              unit_amount: li.price.to_s,
              unit_of_measure: 'unit',
              product_code: li.sku,
              total_amount: (li.price * li.quantity).to_s,
              tax_amount: li.additional_tax_total.to_s
            }
          end.
            take(PAYPAL_MAX_LINEITEMS - 1)
          total = @order.adjustment_total.abs
          return items if total.zero?
          items.append({
                         name: 'discount',
                         kind: 'credit',
                         quantity: '1',
                         unit_amount: total.to_s,
                         total_amount: total.to_s
                       })
        end
def collect_line_items items = @order . line_items . reject { | li | li . price . zero? || li . quantity . zero? } . map do | li | { name : li . name . truncate ( 127 , omission : '' ) , kind : 'debit' , quantity : li . quantity . to_s , unit_amount : li . price . to_s , unit_of_measure : 'unit' , product_code : li . sku , total_amount : ( li . price * li . quantity ) . to_s , tax_amount : li . additional_tax_total . to_s } end . take ( PAYPAL_MAX_LINEITEMS - 1 ) total = @order . adjustment_total . abs return items if total . zero? items . append ( { name : 'discount' , kind : 'credit' , quantity : '1' , unit_amount : total . to_s , total_amount : total . to_s } ) end
Because of strange PayPal behaviour with accepting discounts
the only solution to add needed discount (if it exist) to
create a virtual Line Item with discount amount and with 'credit'
and name it as 'discount' to be reflected in PayPal email to customer
Because of strange PayPal behaviour with accepting discounts the only solution to add needed discount ( if it exist ) to create a virtual Line Item with discount amount and with ' credit ' and name it as ' discount ' to be reflected in PayPal email to customer
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize