How to access javascript object?


I am tyring to add PayPal Express Checkout into my website, all is working fine, but I am not able to get the transaction ID using data[“id”] and it keeps on saying undefined.

How do I access the object ? If i just alert(data) it says object object. How do I see what objects are there in the data ?

Below is my code:

		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
		<div id="paypal-button"></div>
		<script src=""></script>
				// Configure environment
				env: 'sandbox',
				client: {
					sandbox: 'demo_sandbox_client_id',
					production: 'demo_production_client_id'
				// Customize button (optional)
				locale: 'en_US',
				style: {
					size: 'small',
					color: 'gold',
					shape: 'pill',
				// Set up a payment
				payment: function(data, actions) {
					return actions.payment.create({
						transactions: [{
							amount: {
								total: '0.01',
								currency: 'USD'
				// Execute the payment
				onAuthorize: function(data, actions) {
					return actions.payment.execute().then(function() {
						var resultDOM = JSON.stringify(data, null, 2);
						var payID = data['id'];

						// Show a confirmation message to the buyer
						window.alert('Thank you for your purchase and ID is: ' + payID);
			}, '#paypal-button');
		<script src=""></script>
		<script src="js/bootstrap.min.js"></script>

Please help.



This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.