I am using paypal.Buttons on a ecommerce site for the checkout and I have a problem with the data returned from PayPal on the "actions.order.capture()." function below: onApprove: function (data, actions) {
actions.order.capture().then(function (details) {
// This function shows a transaction success message to your buyer.
//console.log(details);
return fetch('/complete.aspx?id=' + data.orderID, {
method: 'POST', // or 'PUT'
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(details)
}).then(function (res) { etc... When using the sandbox mode I get a json string which contains the customers telephone number as shown below: {"create_time":"xxxxxxxxx","update_time":"xxxxxxxxx","id":"xxxxxxxxx","intent":"CAPTURE","status":"COMPLETED","payer":{"email_address":"xxxxxxxxx","payer_id":"xxxxxxxxx","address":{"address_line_1":"xxxxxxxxx,","admin_area_2":"xxxxxxxxx","admin_area_1":"xxxxxxxxx","postal_code":"xxxxxxxxx","country_code":"GB"},"name":{"given_name":"xxxxxxxxx","surname":"xxxxxxxxx"},"phone":{"phone_number":{"national_number":"12345678910"}}},"purchase_units":[{"reference_id":"default","amount":{"value":"10.00","currency_code":"GBP"},"payee":{"email_address":"xxxxxxxxx","merchant_id":"xxxxxxxxx"},"shipping":{"name":{"full_name":"xxxxxxxxx"},"address":{"address_line_1":"xxxxxxxxx,","admin_area_2":"xxxxxxxxx","admin_area_1":"xxxxxxxxx","postal_code":"xxxxxxxxx","country_code":"GB"}},"payments":{"captures":[{"status":"PENDING","id":"xxxxxxxxx","final_capture":true,"create_time":"xxxxxxxxx","update_time":"xxxxxxxxx","amount":{"value":"10.00","currency_code":"GBP"},"seller_protection":{"status":"ELIGIBLE","dispute_categories":["ITEM_NOT_RECEIVED","UNAUTHORIZED_TRANSACTION"]},"status_details":{"reason":"RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION"},"links":[{"href":"https://api.sandbox.paypal.com/v2/payments/captures/xxxxxxxxx","rel":"self","method":"GET","title":"GET"},{"href":"https://api.sandbox.paypal.com/v2/payments/captures/xxxxxxxxx/refund","rel":"refund","method":"POST","title":"POST"},{"href":"https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxxxx","rel":"up","method":"GET","title":"GET"}]}]}}],"links":[{"href":"https://api.sandbox.paypal.com/v2/checkout/orders/xxxxxxxxx","rel":"self","method":"GET","title":"GET"}]} When using the Live server to make a transaction this different json string is returned which has a different structure and does not have the telephone number:
... View more