PayPal REST API - Coupon / Discount Code (Negative Numbers)

I do it creating another item, and giving a negative price.

  $item = new Item();
  $price = -11.20;
  ......
  $item->setName($name)
        ->setCurrency($currency)
        ->setQuantity($quantity)
        ->setSku($sku)
        ->setPrice($price);

For this example I have a Promo code of -11.20 euro:

promo code


What worked for me:

Add a discount field to the breakdown:

'discount' => [
    'currency_code' => $order->currency,
    'value' => $order->coupon_total,
]

See PayPal's docs: https://developer.paypal.com/docs/api/orders/v2/#definition-amount_breakdown

The discount will the show up as discount in the price breakdown.

Tags:

Paypal