Get buyer information via javascript

ajarrow
Contributor
Contributor

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

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

ajarrow
Contributor
Contributor

I finally got this figured out by studying the docs and some help from a. 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.

View solution in original post

Login to Me Too
1 REPLY 1
Solved

ajarrow
Contributor
Contributor

I finally got this figured out by studying the docs and some help from a. 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.

Login to Me Too

Haven't Found your Answer?

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