jigna Bavaliya
jigna Bavaliya

Reputation: 51

How to show Product details in paypal express checkout

I have implemented express checkout like this

// Render the PayPal button

paypal.Button.render({

// Set your environment

env: 'sandbox', // sandbox | production

// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create

client: {
    sandbox:    'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
    production: 'Aco85QiB9jk8Q3GdsidqKVCXuPAAVbnqm0agscHCL2-K2Lu2L6MxDU2AwTZa-ALMn_N0z-s2MXKJBxqJ'
},

// Set to 'Pay Now'

commit: true,

// Wait for the PayPal button to be clicked

payment: function() {

    // Make a client-side call to the REST api to create the payment

    return paypal.rest.payment.create(this.props.env, this.props.client, {
        transactions: [
            {
                amount: { total: '<?php echo $cart->total(); ?>', currency: 'USD' }
            }
        ]
    });
},

// Wait for the payment to be authorized by the customer

onAuthorize: function(data, actions) {

    // Execute the payment

    return actions.payment.execute().then(function() {
        document.querySelector('#paypal-button-container').innerText = 'Payment Complete!';
        window.location.href = 'cartaction.php?action=place0rder';
    });
}

}, '#paypal-button-container');

where $cart->total() is total payable amount of all products. it works totally fine.

But i want to display all products name price and description as shown in following image.

When we click Amount it shows item details

But here in my case It just shows amount like below.

enter image description here

What should I add in the code to achieve this. Any help please?

Upvotes: 2

Views: 2325

Answers (1)

habdulkarim
habdulkarim

Reputation: 176

Just like the REST API integration, you can actually use the same parameter. Below is my sample code for that part:

transactions: [
	{
		amount: { total: '1.00', currency: 'USD' },
		item_list: {
			items: [
				{
				name: 'hat',
				description: 'Brown hat.',
				quantity: '1',
				price: '1.00',
				currency: 'USD'
				}
			]
		}
	}
]

Upvotes: 5

Related Questions