Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paypal Subscription Error : Billing Plan Override is not allowed due to insufficient permissions

I have an error when i create subscription plan. when i click button, the popup is closed immediately and show this error. How can i fix this bug?

Error:

{
      "name": "NOT_AUTHORIZED",
      "message": "Authorization failed due to insufficient permissions.",
      "debug_id": "f745284410b5f",
      "details": [
             {
                    "issue": "Unauthorised Access",
                    "description": "Billing Plan Override is not allowed due to insufficient permissions."
             }
       ],
      "links": [
             {
                   "href": "https://developer.paypal.com/docs/api/v1/billing/subscriptions#NOT_AUTHORIZED",
                   "rel": "information_link",
                   "method": "GET"
            }
     ]
}

My code: (use @paypal/react-paypal-js Library)

  • create sub function
const createSubscription = (data: any, actions: any) => {
    console.log('planId create', planId);
    return actions.subscription
      .create({
        plan_id: planId,
        custom_id: storeId,
        plan: {
          billing_cycles: [
            {
              pricing_scheme: {
                fixed_price: {
                  currency_code: 'USD',
                  value: price,
                },
              },
              sequence: 1,
              total_cycles: 1,
            },
          ],
          taxes: {
            percentage: '0',
            inclusive: true,
          },
        },
      })
  • my paypal button code:
<PayPalButtons
      forceReRender={[price, planId, JSON.stringify(dataPurchase)]}
      createSubscription={createSubscription}
      onApprove={onApprove}
      onError={(error) => {
        console.log('Error:', error);
      }}
      onCancel={(order) => {
        console.log('reject payment', order);
      }}
      style={{
        shape: 'pill',
        layout: 'vertical',
        label: 'subscribe',
      }}
    />

If in function actions.subscription.create({...}) not have plan param (not overwrite), everything is still running fine

I want to create billing plan with custom plan.

like image 979
QyDsd Avatar asked Oct 30 '25 07:10

QyDsd


1 Answers

Posting this again since my first answer was deleted (I also edited it) Anyway After contacting PayPal support we received the following news: PayPal blocked actions.subscription.create({...}) If the plan is overrided.. all this without prior communication.

The only solution is to move your integration to server side APIs

https://developer.paypal.com/docs/api/subscriptions/v1/

Instead of using actions.subscription.create({...}) create the sub backend and return the sub Id to the pp button

something like this: createPaypalSubscriptionBackend is just a call to the backend that use Paypal create subscription API and return the sub id

<PaypalSmartPaymentButton
              paypalClient={paypalClient}
              intent={intent}
              buttonProps={
                {
                  createSubscription: (data, actions) => {

                    return createPaypalSubscriptionBackend({
                      plan_id: paypal_plan_id,
                      plan: plan,
                      subscriber: {
                        ...
                      }
                    }).then(function (response) {
                      return response.id
                    }).catch(function (errors) {
                        return actions.reject()
                      }
                    })
                  },
                  onClick: (data, actions) => {
                   
                  },
                  onApprove: (data, actions) => {

                  },
                  onCancel: (data) => {
                    // Show a cancel page, or return to cart;
                  },
                  onError: (err) => {
                    // Show an error page here, when an error occurs
                    return err
                  }
                }
              }
            />
like image 59
Daniele Mancini Avatar answered Nov 02 '25 18:11

Daniele Mancini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!