Add Others data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
<script> paypal.Buttons({ // Sets up the transaction when a payment button is clicked createOrder: (data, actions) => { return actions.order.create({ "purchase_units": [{ "custom_id": "<?php echo $event_id; ?>", "description": "<?php echo $event_title; ?>", "amount": { "currency_code": "<?php echo $event_currency_code; ?>", "value": <?php echo $event_price; ?>, "breakdown": { "item_total": { "currency_code": "<?php echo $event_currency_code; ?>", "value": <?php echo $event_price; ?> } } }, "items": [ { "name": "<?php echo $event_title; ?>", "description": "<?php echo $event_title; ?>", "unit_amount": { "currency_code": "<?php echo $event_currency_code; ?>", "value": <?php echo $event_price; ?> }, "quantity": "1", "category": "DIGITAL_GOODS" }, ] }] }); }, // Finalize the transaction after payer approval onApprove: (data, actions) => { return actions.order.capture().then(function(orderData) { setProcessing(true); var postData = {paypal_order_check: 1, order_id: orderData.id}; fetch('/paypal-checkout-validate', { method: 'POST', headers: {'Accept': 'application/json'}, body: encodeFormData(postData) }) .then((response) => response.json()) .then((result) => { if(result.status == 1){ window.location.href = "/success?checkout_ref_id="+result.ref_id; }else{ const messageContainer = document.querySelector("#paymentResponse"); messageContainer.classList.remove("hidden"); messageContainer.textContent = result.msg; setTimeout(function () { messageContainer.classList.add("hidden"); messageText.textContent = ""; }, 5000); } setProcessing(false); }) .catch(error => console.log(error)); }); } }).render('#paypal-button-container'); const encodeFormData = (data) => { var form_data = new FormData(); for ( var key in data ) { form_data.append(key, data[key]); } return form_data; } // Show a loader on payment form processing const setProcessing = (isProcessing) => { if (isProcessing) { document.querySelector(".overlay").classList.remove("hidden"); } else { document.querySelector(".overlay").classList.add("hidden"); } } </script> can i add more data in purchase_units
![](/skins/images/0FF1A2F377A75DEEE7D9B96ED67745BD/responsive_peak/images/icon_anonymous_message.png)
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- How long is OrderID valid? in REST APIs
- Issue with Payflow Pro: "Failed to connect to host" Error on Server Deployment in Payflow
- Securing Return and Error URLs for Payflow Pro Transparent Redirect Implementation in Payflow
- How to pass "amount" using @paypal/react-paypal-js in REST APIs
- UNPROCESSABLE_ENTITY","details":[{"issue":"TRANSACTION_REFUSED in REST APIs