Search code examples
javascriptpaypalpaypal-subscriptions

PayPal Subscription Data


Good day how can I change the data on my alert that instead of notifying the subscription ID it will show the subscribers name.

<div id="paypal-button-container"></div>
<script src="https://www.paypal.com/sdk/js?client-id=api&vault=true" data-sdk-integration-source="button-factory"></script>
<script>
  paypal.Buttons({
      style: {
          shape: 'rect',
          color: 'gold',
          layout: 'vertical',
          label: 'subscribe'
      },
      createSubscription: function(data, actions) {
        return actions.subscription.create({
          'plan_id': 'plan_id'
        });
      },
      onApprove: function(data, actions) {
        alert(data.subscriptionID);
      }
  }).render('#paypal-button-container');
</script>

I tried using data.subscriber.name.given_name bases on this like in the Paypal checkout


Solution

  • Put console.log(data); in your code next to the alert, and after making a test payment look around in your Web Developer tools, expanding everything in the object to find the path to the data you want.