Transaction with PP button does not show product description

Temp20230911d
Contributor
Contributor

Apologies if I'm posting this in the wrong category! I've created some PP smart buttons and when the transaction shows up in the PP account the amount is correct but it doesn't show any product description and I can not tell what item was purchased. I'm not an expert coder so I suspect my code is the issue. Any help would be greatly appreciated. My code from one of my items (client id removed):

 

<div id="paypal-button-container" margin: auto>
<script src="https://www.paypal.com/sdk/js?client-id=[CLIENTID HIDDEN] &components=messages,buttons">
</script>
<div id="paypal-button-container"></div>
<script>
  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: '900.00'
          }
        }]
      });
    },
    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.
        alert('Thank you for your puchase' + details.payer.name.given_name);
window.location.href = 'https://mywebsite.com/confirmation.html';
      });
    }
  }).render('#paypal-button-container');
  //This function displays Smart Payment Buttons on your web page.
</script>
<div
  data-pp-message
  data-pp-amount="900.00">
</div>
 
Login to Me Too
1 REPLY 1

MTS_Chiranjeevi
Moderator
Moderator

Good day @Temp20230911d,

 

Thank you for posting to the PayPal community.

 

Yes, while performing the "Create Order" API call, merchant(i.e you) should pass the "items" value under "purchase_unitsthat the customer purchased which contains the name, quantity, description etc.

 

https://developer.paypal.com/docs/api/orders/v2/#orders_create

https://developer.paypal.com/docs/api/orders/v2/#orders_create!path=purchase_units/items&t=request 

 

Please use the "Show order details" API to get the particular order details.

 

https://developer.paypal.com/docs/api/orders/v2/#orders_get 

 

Sincerely,

Chiranjeevi

PayPal/Braintree MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.