cancel
Showing results for 
Search instead for 
Did you mean: 

Get buyer information via javascript function

Options
Go to solution
ajarrow
Contributor
Posted on

In my checkout flow, I am redirecting to a confirmation page where I would like to show the buyer name and address. Is there any way to get that information and insert it via javascript? I just need to know how to get the info in my PayPal checkout function in javascript. Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Solved

Get buyer information via javascript function

Options
Go to solution
ajarrow
Contributor

Actually, I got most of this figured out by studying the docs. As for the buyer address, I got that (and the full name as well) by going into this:

details.purchase_units[0].shipping

Then, as I am using vanilla Javascript, I created this:

var buyerInfo = [details.purchase_units[0].shipping.name.full_name, details.purchase_units[0].shipping.address.address_line_1, details.purchase_units[0].shipping.address.admin_area_2, details.purchase_units[0].shipping.address.admin_area_1, details.purchase_units[0].shipping.address.postal_code, details.id];

And then I added it to sessionStorage and went from there. This way I was able to get the full name with one line and it was the only place I could find an address. Thanks so much for your help!

View solution in original post

3 REPLIES 3

Get buyer information via javascript function

Options
Go to solution
JackieDaytona
Contributor

Buyer name gets returned in onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {

The buyer first name and last name are in the details function

So using JQuery to get them 

        $('#transmsg').html('<b>' + 'AUTHORIZED...' + '</b>');
        $('#transmsg').append('<br>'+'Transaction completed by: ' + details.payer.name.given_name +' '+ details.payer.name.surname + '<br>' + "Order Id: "          + details.id + '<br>' + 'Status: PAID & APPROVED' + '<br>'+ 'Thank You For Your Order'+ '<br>');

Now the address is a bit tricky as you to get that from an IPN call.  Personally, IPN were a PAIN in the **bleep** so I deccided NOT to use them/it.

But if you REALLY need the address go for it. 

 

 

Solved

Get buyer information via javascript function

Options
Go to solution
ajarrow
Contributor

Actually, I got most of this figured out by studying the docs. As for the buyer address, I got that (and the full name as well) by going into this:

details.purchase_units[0].shipping

Then, as I am using vanilla Javascript, I created this:

var buyerInfo = [details.purchase_units[0].shipping.name.full_name, details.purchase_units[0].shipping.address.address_line_1, details.purchase_units[0].shipping.address.admin_area_2, details.purchase_units[0].shipping.address.admin_area_1, details.purchase_units[0].shipping.address.postal_code, details.id];

And then I added it to sessionStorage and went from there. This way I was able to get the full name with one line and it was the only place I could find an address. Thanks so much for your help!

Get buyer information via javascript function

Options
Go to solution
JackieDaytona
Contributor
Ah thanx for that address bit. Did not know it got returned like that. Might need it in the future ..:) JD

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.