skip to Main Content

I am implementing subscriptions to a premium service on a website using Paypal as the payment service. I have successfully created a Catalog Product and Billing Plan through the API, and I am able to get to the payment page on Paypal, but it’s not clear how I’m supposed to persist a user identifier through the purchase process.

I assumed it would be something along the lines of passing a user id somewhere, but there’s nothing in the Paypal documentation about this. I need to be able to let the user make a purchase and have the Paypal webhook send the confirmation to an endpoint on my site, and that’s where I’d expect to get their user id to toggle the subscription on their account on my end.

Is there something I’m missing? There has to be a way to do this cause I’d imagine it’s a pretty common use case. If anyone has information or has done this before, I’d love to hear. Thanks.

2

Answers


  1. I am able to get to the payment page on PayPal,

    You are vague about what you are doing here. There are multiple ways (and some ways have multiple versions) of accepting subscriptions via PayPal, so it is important that you provide full details about the method you are using.

    The time to associate a created subscription ID with a user ID is when it is approved, in the onApprove function if you are using a Smart Payment Button: https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription

    Login or Signup to reply.
  2. The only truly secure way I’ve found when using javascript SDK, is to securely generate a unique custom_id on your server side associated with the user.

    Then when you create the buttons, the ‘createSubscription’ function takes custom_id as a parameter.

    Then use a webhook to receive events from your subscription and the custom_id will be present in the body of all BILLING.SUBSCRIPTION events under resource.custom_id.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search