PayPal Subscriptions and Smart Payment Buttons -- adding a description/metadata

Viewed 562
            createSubscription: function(data, actions) {

              console.log($('#donation-details').val());
              return actions.subscription.create({

                'plan_id': window.VUE_DONATION_MODULE.getPlanId(),
                // I want to add meta data about the subscription
                'description': $('#donation-details').val(),
                'application_context':{brand_name:$('#donation-details').val()}
              });

            },


            onApprove: function(data, actions) {


              $('#step-7').removeClass('active').fadeOut();
              $('#step-9').addClass('active').fadeIn();

            }

I am using PayPal Smart Buttons to make a subscription, and want to add metadata. For a one-time payments I used the 'description' field to enter this metadata. Please help me find a way to record metadata for subscriptions; I want it to display it under transaction details after loging into PayPal, in both merchant account and customer account.

1 Answers

Plans have a description field you can use at original plan creation time: https://developer.paypal.com/docs/api/subscriptions/v1/#plans-create-request-body

If you need per-user metadata to be part of the plan description, you must create a new plan per user.

If you just need to associate additional metadata with a user's subscription, you must do this in your own database. Associate the subscription ID object with the user the moment it is created by your site/application, and so all additional metadata can be stored by your site/application, and be looked up by either the user or the subscription ID.

Related