paypalpaypal-subscriptions

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


            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.


Solution

  • 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 or override the plan_id's details with an additional plan object when creating the subscription for approval.