Quick start Testing with PayPal sandbox

Testing with PayPal sandbox

Test purchases, subscriptions, refunds, webhooks, trials and licenses end to end with PayPal sandbox accounts and test cards.

Sandbox is a full copy of your app that runs against PayPal’s sandbox, where no real money moves. Checkout, webhooks, receipts, the customer portal, license keys and outbound webhooks all behave as in Live. Test every flow here before you go live. New to it? How the PayPal sandbox works.

This page assumes the SDK is installed with your pk_test_… key (Quick start) and Sandbox PayPal is connected (Connect PayPal).

How Sandbox works

WhereWhat to look for
DashboardSet the Sandbox / Live toggle in the top bar to Sandbox. An amber Test mode ribbon shows on every page. Orders, customers, installs, discounts and webhook endpoints are separate per environment.
ExtensionThe pk_test_… key from Developers → Integrate. Every install, checkout and purchase made with it lands in Sandbox.
Hosted pagesCheckout, portal and restore pages show a sandbox banner.
ActionPayPal pageOfficial guide
Find or create sandbox buyer accountsSandbox accountsSandbox accounts guide
Generate test cardsCard testing
Learn how the sandbox worksPayPal sandbox

Get a sandbox buyer

  1. Open sandbox accounts. Go to PayPal sandbox accounts. PayPal created a Business account (the seller your sandbox app belongs to) and a Personal account (your buyer). See the PayPal guide: sandbox accounts.

  2. Copy the buyer login. On the Personal account, open the … menu → View/Edit account and copy its email and password.

  3. (Optional) Add buyers. Click Create account, choose Personal and a country, to test other countries or currencies.

To see the seller side, log in to sandbox.paypal.com with the sandbox Business account. You can also issue a refund there to test refund syncing.

Test cards: for the Debit or Credit Card button, generate a card with PayPal’s card testing tool (Credit card generator). It gives a sandbox card number, expiry and CVV for the brand and country you pick. Never use a real card in Sandbox, or a sandbox card in Live.

Test a one-time purchase

  1. Open checkout. In your extension, call bill.openCheckout() (for example from your Upgrade button) and pick a one-time price, or pass its price ID.

  2. Enter your email. Use one you can read. Try a discount code here if you created one.

  3. Pay. Click the PayPal button and log in as the sandbox Personal account, or use the card button with a generated card. Approve the payment.

  4. Check the extension. The success page shows the order number, plus the license key if the product issues one. bill.onChange fires and bill.hasAccess(user, 'pro') returns true.

  5. Check the dashboard. Customers → Orders shows the order as paid, with PayPal fee and net amount. The customer page shows the entitlement and license. The receipt email arrives in your inbox.

Test a subscription

  1. Add a daily price. Add a subscription price with interval day for fast renewal testing: PayPal sandbox bills it again the next day.

  2. Subscribe. Open checkout for that price and approve it as the sandbox Personal account.

  3. Check access. Access is granted as soon as PayPal activates the subscription. user.subscription holds status, currentPeriodEnd and, with a free trial, trialEndsAt.

  4. Check the dashboard. Customers → Subscriptions shows the subscription and next billing date. Open it to see PayPal’s transaction list.

  5. Wait for a renewal (optional). The next day brings a renewal order, a receipt email and a subscription.renewed outbound event.

  6. Cancel. Call bill.openPortal(), sign in with the email code and click Cancel subscription. Access continues until the end of the paid period, then ends.

Simulate PayPal webhook events

In Sandbox, Settings → PayPal has a Send test event button. Pick a PayPal event type, for example PAYMENT.CAPTURE.COMPLETED, BILLING.SUBSCRIPTION.CANCELLED or BILLING.SUBSCRIPTION.PAYMENT.FAILED, and PayPal sends a simulated event to your registered webhook. It shows up in Developers → PayPal events within a few seconds.

Simulated events carry PayPal’s sample data; their resource IDs match none of your orders or subscriptions. They confirm that the webhook is registered, reachable and passes signature verification. To change a real test order or subscription, do the action itself: buy, refund or cancel. Test events are not available in Live.

The PayPal events log

Developers → PayPal events lists every event PayPal sent for the current environment, newest first:

StatusMeaning
receivedStored, processing in progress.
processedApplied to your orders, subscriptions or disputes.
ignoredValid, but nothing needed to change, for example a duplicate or an untracked resource.
failedProcessing raised an error. The message is shown on the event.
rejectedSignature verification failed. The event was never processed.

Open an event to see PayPal’s full payload. Replay processes a stored event again. Processing is idempotent, so replaying a processed event never grants access or creates an order twice. Use it after fixing the cause of a failed event.

Test tools in the dashboard

TaskHow
Reset a trialInstall-based trials start once per install. Open Customers → Installs, find your install (show its ID with bill.getInstallId()) and click Reset trial. The next bill.startTrial() succeeds instead of failing with 409 trial_unavailable.
Grant accessOpen the install in Customers → Installs and click Grant access with a reason. bill.refresh() or the next background refresh picks it up. Revoke access removes it. To grant a product to a customer, add an entitlement on the customer in Customers → Customers.

Manual grants are recorded in Developers → Audit log, in Sandbox and Live alike.

Test restore and license keys

Restore on a new device: buy once with an email you can read. Load the extension in another Chrome profile, or remove and re-add the unpacked extension, to get a new install without access. Call bill.openRestore(), enter the purchase email and type the code you receive. The new install gets access.

License keys: turn on Issue license keys for the product, buy it, and copy the key from the success page or email. In a second profile, call bill.activateLicense(key). Activate on more installs than the device limit to see 409 seat_limit_reached with details.seatLimit and details.seatsUsed, then free a seat with bill.deactivateLicense() or from the customer portal.

More in License keys and Restore purchases.

Test your webhook endpoint

If your server consumes ExtensionBill events, add a sandbox endpoint in Developers → Webhooks. It must be reachable over public HTTPS; while developing, a tunnel to your local server works.

Click Send test on the endpoint to deliver a signed test event, then check the response in its deliveries list. Real purchases, refunds and cancellations send the actual events (order.paid, order.refunded, subscription.canceled and so on). Use your sk_test_… key for Server API calls, and see Webhooks for signature verification.

Scenario checklist

Work through these before you go live:

  • One-time purchase with the sandbox PayPal account: order paid, access granted, receipt received.
  • One-time purchase with a generated card via the card button.
  • Discount code applied at checkout; the order shows the discount.
  • Subscription signup, with and without a free trial; user.subscription populated.
  • Renewal on a daily price: renewal order and receipt the next day.
  • Cancel from the portal: access continues until the period ends.
  • Cancel from the dashboard, including cancel immediately: access ends right away.
  • Full refund from Customers → Orders: order refunded, entitlement and license revoked, refund email sent.
  • Partial refund: order partially_refunded, access kept.
  • Refund issued in PayPal from the sandbox Business account: the order updates within seconds.
  • Failed payment: send a BILLING.SUBSCRIPTION.PAYMENT.FAILED test event and confirm it reaches Developers → PayPal events verified. Real failed payments are covered in Subscription lifecycle.
  • Install trial: bill.startTrial() works once; Reset trial lets you test again.
  • Restore on a second profile with the email code.
  • License activation, device limit reached, deactivation.
  • Uninstall: remove the extension; the install is marked uninstalled and the feedback page opens.
  • Outbound webhook endpoint receives and verifies events.

When everything passes, continue with the Going live checklist.