Quantcast
Channel: Active questions tagged paypal - Stack Overflow
Viewing all articles
Browse latest Browse all 512

How can I use Paypal Smart buttons to check out using paypal merchant id (partner id)

$
0
0

I'm working with the PayPal Partner Referral API to onboard merchants for different products. However, I’m encountering an error when trying to request multiple products together in a single

<script        src="https://www.paypal.com/sdk/js?client-id=<?php echo PAYPAL_SANDBOX ? PAYPAL_SANDBOX_CLIENT_ID : PAYPAL_PROD_CLIENT_ID; ?>&disable-funding=credit&currency=<?php echo CURRENCY; ?>&merchant-id=<?=$paypal_merchant_id;?>"></script><script>    document        .getElementById("checkoutForm")        .addEventListener("submit", function(event) {            event.preventDefault();            var form = document.getElementById("checkoutForm");            var totalamount = $('#totalamount').val();            var trans_charges = $('#trans_charges').val();            console.log("Total Amount", totalamount, "Trans charges", trans_charges, "loggedin", loggedin);            // render button            paypal.Buttons({                createOrder: function(data, actions) {                    // Create an order on the client side with the cart details                    return actions.order.create({                        purchase_units: [{                            amount: {                                currency_code: 'USD',                                value: totalamount // Replace with the actual cart total                            },                            payee: {                                email_address: '<?=$paypal_partner_merchant_id;?>' // an email                            },                            payment_instruction: {                                disbursement_mode: 'INSTANT',                                platform_fees: [{                                    amount: {                                        currency_code: 'USD',                                        value: '<?=$site_settin["trans_charges"];?>' // Platform fee                                    },                                    payee: {                                        merchant_id: '<?=$paypal_merchant_id;?>' // an alpha-numeric key from paypal                                    }                                }]                            }                        }]                    });                },                onApprove: function(data, actions) {                    console.log("Data", data);                    // Capture the funds from the transaction                    return actions.order.capture().then(function(details) {                        console.log("Details", details);                    });                },                onError: function(err) {                    console.error('PayPal Button Error:', err);                }            }).render('#checkoutForm');        });</script>

this opens up a paypal popup goes through the complete process

paypal process

and when I complete the payment it gives me error;console errors .can any one help me thanks


Viewing all articles
Browse latest Browse all 512

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>