title: How to send an itemised PayPal invoice to user and merchant?
body: <p>I am developing a website that contains a store. A user can pay with PayPal on this store and this work perfectly! The shopping cart is programmed using JavaScript and this has caused a few issues.</p>
  
  <p>I originally wanted to have a JS function that sent the user an email with their cart but I could find any code for that. I know that you can get an itemised receipt using PayPal but my system won't give me those details. I've read through the developer part of the PayPal website but I can't seem to figure it out!</p>
  
  <p>My PayPal script is below:</p>
  
  <pre class="lang-js prettyprint-override"><code>&lt;script&gt;
          paypal.Buttons({
              createOrder: function(data, actions) {
                  // This function sets up the details of the transaction, including the amount and line item details.
                  return actions.order.create({
                      purchase_units: [{
                          amount: {
                              value: countCartTotal()
                          }
                      }]
                  });
              },
              onApprove: function(data, actions) {
                  // This function captures the funds from the transaction.
                  return actions.order.capture().then(function(details) {
                      // This function shows a transaction success message to your buyer.
                      window.location.href = "orderConfirmed.php"
                      clearCart()
                  });
              }
          }).render('#paypal-button-container');
          //This function displays Smart Payment Buttons on your web page.
      &lt;/script&gt;
  </code></pre>
  
  <p>The shopping cart is coded in cart.js and I know I can use a function from this file in the PayPal script as the function 'countCartTotal()' is what tell PayPal the amount to charge the customers. In my cart. js, this is how I add items to the cart:</p>
  
  <pre class="lang-js prettyprint-override"><code>function insertItemToDOM(product) {
      cartDOM.insertAdjacentHTML('beforeend', `
      &lt;div class="cart__item"&gt;
        &lt;img class="cart__item__image" src="${product.image}" alt="${product.name}"&gt;
        &lt;h3 class="cart__item__name"&gt;${product.name}&lt;/h3&gt;
        &lt;h3 class="cart__item__price"&gt;${product.price}&lt;/h3&gt;
        &lt;button class="btn btn--primary btn--small${(product.quantity === 1 ? ' btn--danger' : '')}" data-action="DECREASE_ITEM"&gt;&amp;minus;&lt;/button&gt;
        &lt;h3 class="cart__item__quantity"&gt;${product.quantity}&lt;/h3&gt;
        &lt;button class="btn btn--primary btn--small" data-action="INCREASE_ITEM"&gt;&amp;plus;&lt;/button&gt;
        &lt;button class="btn btn--danger btn--small" data-action="REMOVE_ITEM"&gt;&amp;times;&lt;/button&gt;
      &lt;/div&gt;
    `);
  
      addCartFooter();
  }
  </code></pre>
  
  <p>I need to have the Paypal contain the '${product.name}' and the '${product.quantity}'</p>