2
            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.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44

1 Answers1

1

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.

Preston PHX
  • 27,642
  • 4
  • 24
  • 44
  • 1
    Thank you very much for your reply. I think creating plan description per user is bad. As a solution I will store the meta data with the mapping to the transaction. – Uthpala Gamage Apr 10 '20 at 05:20
  • You can pass a `custom_id` with the creation of the subscription button, see https://stackoverflow.com/a/66776897/1066234 --- I also ran into this problem. I need to add more data then just a `custom_id`. I actually want to change the "pay purpose" field that shows up when the customers pays (and is displayed in the reports every month). Now, it only says "Plan XYZ". But before with the old Paypal subscriptions I could modify this, to e.g. "Plan XYZ (misterab@c.com, 1234)" easily. This seems not to be possible anymore. – Avatar Mar 25 '21 at 14:26
  • So as I understand the `description` cannot be modified on the fly anymore, but is prefilled from paypal according to the subscription plan set up. – Avatar Mar 25 '21 at 14:29