Get Subscription Details

and_taurus
Contributor
Contributor

Hi,

i had set up a standard subscription with sdk. It works fine, but i want to get some subscription-details like the name or email of subscriber. Anyone know how i get this information in the onApprove() function after the user had subscribe for a plan?

 

I know the process with a standard order, its like:

 

// JS

paypal.Buttons({
    createOrder: function(data, actions) {
      return actions.order.create({
      intent: "CAPTURE",
      prefer: "return=representation",
      purchase_units: [{
      amount: {
      currency_code: "EUR",
      value: preis_ges
      }
}]
});
},
   onApprove: function(data, actions) {
   return actions.order.capture().then(function(details) {
   var id = details.payer.payer_id ;

   var name = details.payer.name.given_name+' '+details.payer.name.surname ;
});
}
}).render('#paypal-button-container');

 

But this wont work for a subscription ?!

Thanks, A

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

and_taurus
Contributor
Contributor

Hi, thanks for your reply.

After hours of searching for a working solution i've change my onApprove-function like following. This works for me:

onApprove: function(data,actions) {
      return actions.subscription.get(data.subscriptionID).then(function(details) {

           var mail = details.subscriber.email_address;

           var name = details.subscriber.name.given_name+" "+details.subscriber.name.surname;

     and so on...

});

}

 

All available values can you find here : https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get

View solution in original post

Login to Me Too
2 REPLIES 2

MTS_Chiranjeevi
Moderator
Moderator

Hi @and_taurus,

 

Thank you for contacting PayPal community.

 

Our sincere apologies for the inconvenience caused.

 

Yes, you can get the subscriber details by implementing "Show subscription details".

 

Thank you for understanding and patience.


Sincerely,

Chiranjeevi

PayPal, Inc.

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too
Solved

and_taurus
Contributor
Contributor

Hi, thanks for your reply.

After hours of searching for a working solution i've change my onApprove-function like following. This works for me:

onApprove: function(data,actions) {
      return actions.subscription.get(data.subscriptionID).then(function(details) {

           var mail = details.subscriber.email_address;

           var name = details.subscriber.name.given_name+" "+details.subscriber.name.surname;

     and so on...

});

}

 

All available values can you find here : https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get

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.