Add details to PayPal Checkout Purchase (Like Title)

I currently have a digital store on my site which is powered by PayPal. I am attempting to add a title to my purchase so the client knows what was purchased when looking at a transaction history. I’ve tried to find out how on the PayPal Checkout documentation but I don’t quite understand what is written nor how to implement it.

function paypal_render(price, tier) {
    paypal.Buttons({
        style : {
            color: 'blue',

        },
        createOrder: function (data, actions) {
            return actions.order.create({
                purchase_units : [{
                    amount: {
                        currency_code: 'USD',
                        value: ''+price
                    },
                }],
                application_context: {
                    shipping_preference: "NO_SHIPPING",
                },
                item: {
                    title: "PEANUTS LAB - TIER " + tier + "DONATION",
                }
            });
        },
        onApprove: function (data, actions) {
            return actions.order.capture().then(function (details) {
                console.log(details)
            })
        }
    }).render('#paypal');
}

Here is what the Sandbox order looks like with the current script: enter image description here

Any help is appreciated.

Answer

You linked to the definition of an item object, but what you need to provide is an array of item objects with the key items, as detailed for the purchase_unit object.

The root API schema for a v2/checkout/orders create is documented here

Here is a complete example with one item and including the required amount breakdown.

{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "amount": {
        "currency_code": "USD",
        "value": "500",
        "breakdown": {
          "item_total": {
            "currency_code": "USD",
            "value": "500"
          }
        }
      },
      "items": [
        {
          "name": "Name of Item #1 (can be viewed in the upper-right dropdown during payment approval)",
          "description": "Optional description; item details will also be in the completed paypal.com transaction view",
          "unit_amount": {
            "currency_code": "USD",
            "value": "500"
          },
          "quantity": "1"
        }
      ]
    }
  ]
}

Any fields that don’t correspond to the API schema will be ignored, as in your question’s example