Search code examples
paypalpaypal-sandboxazure-api-managementpaypal-rest-sdkpaypal-subscriptions

How to Integrate Azure API Management With Paypal


I've been integrating Azure API Management with Paypal. Here is the current flow

  1. User goes to APIM portal and Signs In
  2. Azure B2C flow is executed
  3. On Auth Success the Delegation endpoint is executed to evaluate the APIM operation (SignIn, Subscribe, etc)
  4. When the operation is Subscribe, redirect to the corresponding Paypal subscription link
  5. Paypal flow is executed
  6. Paypal return to the delegation endpoint configured in Paypals returnurl

So far so good, the issue I'm having is that the ony thing I have access to from paypal is the referer, which is like this https://www.sandbox.paypal.com/webapps/billing/subscriptions?ba_token=[BA_TOKEN]&country.x=US&locale.x=en_US&mode=member&token=[TOKEN]

I'm lost on how I could use those tokens to identify which product the user subscribed to.


Solution

  • In step 4, store the subscription link or its ID before redirecting the user, as a pending checkout/order.

    When they return, note any additional parameters in the return URL.

    This should give you enough information to match the return event with the original subscription redirection and user.


    For the best experience, change your flow to use no redirection at all.

    See the modern "in-context" JS buttons solution here, which keeps your site loaded in the background: https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription

    (If you don't know what that means, click the PayPal button in this demo and note the window that opens; that's essentially the experience: https://developer.paypal.com/demo/checkout/#/pattern/client )