0
votes

Is it possible with the Smart Payment Button for Paypal recurring payments to pass additional parameters like an invoice id for example.

paypal.Buttons({

  createSubscription: function(data, actions) {

    return actions.subscription.create({

      'plan_id': 'P-2UF78835G6983425GLSM44AM'

    });

  },


  onApprove: function(data, actions) {

    alert('You have successfully created subscription ' + data.subscriptionID);

  }


}).render('#paypal-button-container');

This is the example code from https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription and it says:

  • Calls PayPal using actions.subscription.create() to create a subscription for your plan and includes the plan ID, subscriber details, shipping, and other details.

But I can't pass anything besides the plan_id.

2

2 Answers

1
votes

You can add the custom_id field as explained on this page

In that case, your code would look like

return actions.subscription.create({
   'custom_id': 'my-custom-code-for-integration',
   'plan_id': 'P-2UF78835G6983425GLSM44AM'
 });
0
votes

The underlying API is /v1/billing/subscriptions

Here is the reference: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create

It does not appear to have a field for an invoice_id -- so, the answer to your question is No, it is not possible.


You will get a unique PayPal subscription profile ID in the resulting response, e.g. "id": "I-BW452GLLEP1G" -- So, what you can do is store that profile ID in your own invoice record.