What was going on
With react-paypal-js in sandbox, clicking the PayPal button created the subscription fine, but then the SDK's internal cartid API call failed with a 500: `Api: /smart/api/billagmt/subscriptions/I-XXX/cartid returned status code: 500` and a body of `{"ack": "error", "message": "Unhandled api error"}`. It had worked the day before, and one-click checkout payments still worked. Dozens of people hit it at the same time on 2024-07-26.

What fixed it
This one wasnt a code problem at all. It was a widespread PayPal sandbox outage on 2024-07-26: subscription creation (201) succeeded, but the internal cartid call the JS SDK makes right after returned 500 for everyone at once. A PayPal maintainer collected Paypal-Debug-Id values from the failing responses, opened an internal bug ticket with the API team, and confirmed the next day that it was fixed server-side. Reporters confirmed it worked again.

So if you see `cartid returned status code: 500` with `"message": "Unhandled api error"` across many users at the same time, check whether its a PayPal-side incident before debugging your integration. Grab the `Paypal-Debug-Id` response header (and the `meta.calc` value in the error body) so support can find your calls.