cancel
Showing results for 
Search instead for 
Did you mean: 

Can I get country and email address onApprove?

Options
EdmundIJones
New Community Member
Posted on

 

I have a really basic implementation which sets up a subscription (i.e. recurring payments).

User clicks the button, logs into PayPal/enters card details and the onApprove function is fired when done.
In the onApprove function, is it possible to obtain the users Country in some way and or ideally an email address. I can get the SubscriptionID but it would be nice to get a little more information. What am I missing? I would like to do it entirely within the scope of the JavaScript code below.

Your help would be apprechiated.

 

paypal.Buttons({
                                                style: {
                                                    shape: 'rect',
                                                    color: 'blue',
                                                    layout: 'vertical',
                                                    label: 'subscribe'
                                                },
                                                createSubscription: function (data, actions) {
                                                    return actions.subscription.create({
                                                        /* Creates the subscription */
                                                        plan_id: 'P-6NA34298SB590924DMLUNVRQ'
                                                    });
                                                },
                                                onApprove: function (data, actions) {
                                                    var CountryCode;
                                                    var Email;
                                                    var PayerID;
                                                    var Firstname;
                                                    var Lastname;
                                                    var SubscriptionID;


                                                    //Firstname = data.payer.name.given_name;
                                                    //Lastname = data.payer.name.surname;
                                                    //Email = data.payer.email_address;
                                                    //PayerID = data.payer.payer_id;
                                                    //CountryCode = data.payer.address.country_code;
                                                    SubscriptionID = data.subscriptionID


                                                    //Got Payment, show download links

                                                    var url;
                                                    url = "OrderComplete.aspx" + "?PayerID=" + PayerID + "&Email=" + Email + "&CountryCode=" + CountryCode + "&Firstname=" + Firstname + "&Lastname=" + Lastname + "&SubscriptionID=" + SubscriptionID;
                                                    document.location.href = url;
                                                }
                                            }).render('#paypal-button-container-P-6NA34298SB590924DMLUNVRQ'); // Renders the PayPal button

I  

Haven't Found your Answer?

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