Skip to main contentBlack Friday40% off

PayPal Payments

Take every payment through PayPal alongside or instead of Stripe — listings, claims, the store and subscriptions. Create the app, wire the webhook, set the env vars, test in the sandbox and go live.

Stripe does not accept merchants in every country. If yours is one of them — or your businesses simply prefer it — a buyer can pay with PayPal instead of a card. The money lands in your own PayPal account, and what they bought is granted from a verified webhook event, by the same rules Stripe's is.

PayPal covers everything the directory sells

Paid listings, listing claims, the store — both "Buy now" and the cart — sponsor blocks, promotion placements and lead subscriptions. There is nothing left that only Stripe can take, and nothing extra to configure for any of it: the same three variables, and the same webhook events.

What PayPal handles

FlowWhere the buyer startsPrice comes from
Premium listing/submit, picking the Premium planprice on the premium plan in config/plans.config.ts
Standard → Premium upgradeDashboard, or the listing's own pageThe same plan price
Sponsor block/promotepricePerMonth in config/advertising.config.ts
Promotion placements/promotepricePerMonth per placement, summed
Lead subscriptionThe owner's leads inboxprice in config/quotes.config.ts
Listing claimThe claim form on a listingprice in config/claims.config.ts
Store orderA product page's "Buy now", or the cartThe product and variant rows, re-read from the database

The first two, claims and store orders are one-time; sponsors, placements and lead subscriptions are monthly. See Payments for the Stripe side of each.

Step 1 — Create a PayPal app

  1. Sign in at developer.paypal.com → Apps & Credentials
  2. Pick Sandbox while you test, Live when you ship
  3. Create an app, then copy its Client ID and Secret

The secret is server-only

PAYPAL_CLIENT_SECRET never belongs in Git or in a NEXT_PUBLIC_ variable. .env.local is already .gitignored. Sandbox and live credentials are separate sets — they are not interchangeable.

Step 2 — Create the webhook

Without a webhook, a buyer can pay and the listing is never granted. In the app's settings, under Webhooks, add one pointing at:

https://your-domain.com/api/webhooks/paypal

Subscribe it to these five, which cover paid listings:

EventWhy it matters
CHECKOUT.ORDER.APPROVEDThe buyer approved and then closed the tab. This captures the money anyway.
PAYMENT.CAPTURE.COMPLETEDThe money arrived. This is what grants the listing.
PAYMENT.CAPTURE.DENIEDLogged, so a buyer's "but I paid" can be checked.
PAYMENT.CAPTURE.REFUNDEDDrops the listing back to the free plan, and takes back the dofollow link the payment granted (not one won as a weekly winner or given by an admin).
PAYMENT.CAPTURE.REVERSEDThe same, for a chargeback.

If the directory also sells sponsor blocks, promotion placements or lead subscriptions, add these seven:

EventWhy it matters
BILLING.SUBSCRIPTION.ACTIVATEDThe subscription is live. This is what switches the sponsor block, placement or lead subscription on.
BILLING.SUBSCRIPTION.UPDATEDStatus or billing period changed.
BILLING.SUBSCRIPTION.SUSPENDEDPaused — after repeated failed charges, among others.
BILLING.SUBSCRIPTION.CANCELLEDEnded by the subscriber or by you.
BILLING.SUBSCRIPTION.EXPIREDRan to its end.
BILLING.SUBSCRIPTION.PAYMENT.FAILEDMarks it past due.
PAYMENT.SALE.COMPLETEDA renewal went through; keeps the billing period current.
Without these, a subscriber pays and gets nothing

BILLING.SUBSCRIPTION.ACTIVATED is what turns the placement on. Leave the subscription events off and PayPal still takes the monthly payment — the sponsor block or promotion simply never appears, and nobody finds out until the buyer asks where their ad is.

Tick the child event, not the Checkout group

In PayPal's event picker, Checkout order approved sits inside a collapsible Checkout group. Ticking that group's own checkbox does not select it — PayPal selects Checkout order completed instead, a different event this app does not handle. The group shows as ticked either way, so nothing looks wrong.

What quietly breaks is the safety net. CHECKOUT.ORDER.APPROVED is what captures an order when the buyer approved the payment on paypal.com and never came back to your site. Without it, that order just expires uncaptured: the buyer believes they paid, and nothing was taken.

Expand the Checkout group and tick Checkout order approved on its own. The same caution applies to every group here: tick the child events, never the group heading.

The mistake, as it actually looks — the group is ticked, and the wrong child event with it.

Then copy the webhook ID PayPal shows beside it. That is what verifies every incoming event, and it differs between your sandbox and live apps.

Check the events actually saved

Back on the Webhooks list, read the Events Tracked column on your webhook's row. For a listings-only directory it must name exactly these five, and the first word of the list is the one to check:

Checkout order approved, Payment capture completed, Payment capture denied,
Payment capture refunded, Payment capture reversed

If it starts with Checkout order completed, you hit the trap above — edit the webhook, clear that event, and tick Checkout order approved.

Selling subscriptions as well, the same column should also carry the seven BILLING.SUBSCRIPTION.* and PAYMENT.SALE.COMPLETED entries — twelve in all.

Wrong: the list starts with Checkout order completed.

Right: Checkout order approved first, and the five listing events in all. Add the subscription events on top if you sell them.

Step 3 — Set the environment variables

PAYPAL_CLIENT_ID=...
PAYPAL_CLIENT_SECRET=...
PAYPAL_WEBHOOK_ID=...
# optional: sandbox | live — overrides testMode in config/payments.config.ts
PAYPAL_ENV=sandbox
All three, or none

The app refuses to start in production with a client id and no webhook id. PayPal events can only be verified against a webhook id, a listing is only ever granted from a verified event, so a half-configured install would take money and grant nothing. Set all three together, or leave all three unset.

With them unset, nothing changes: the paid-listing flow is the Stripe checkout it was.

Step 4 — Choose the default provider

config/payments.config.ts is yours and survives every upgrade:

config/payments.config.ts
export const paymentsConfig = definePayments({
  provider: 'paypal',   // 'stripe' | 'paypal' | 'none'
  testMode: true,       // sends PayPal to its sandbox API
});

provider is only the default. Whatever else you have configured by environment stays available, and the buyer picks:

Stripe keysPayPal keysWhat the buyer sees
setunsetCard only — exactly as before PayPal existed
unsetsetPayPal only
setsetA choice, with provider preselected

There is nothing to configure for the choice itself. The payment step asks the server which providers are live and renders nothing extra when there is only one.

Step 5 — Make the two prices agree

The providers read the price from different places, and nothing reconciles them:

  • Stripe charges whatever its Price says — set in the Stripe dashboard, reached through STRIPE_PRICE_ID_PREMIUM and the STRIPE_PRICE_ID_PROMO_* variables.
  • PayPal charges what your config says, because a PayPal order and plan each carry their own amount: price on the premium plan in config/plans.config.ts for a listing, pricePerMonth in config/advertising.config.ts for sponsors and placements, and price in config/quotes.config.ts for lead subscriptions — each in the currency from the same file.
Check this before you take real money

Where a Stripe Price and the matching config value disagree, buyers pay different amounts depending on which button they press. Make each pair equal, and change them together.

The bundle discount is the same trap in a second form. Stripe takes 30% off through STRIPE_COUPON_ID_PROMO_ALL_THREE; PayPal has no coupons, so the all-three plan's price already has allThreeDiscountPercent taken off it. Nothing links the two.

How a payment runs

buyer clicks pay
  → the payment route creates a PayPal order, saved on the listing
  → buyer approves on paypal.com
  → back on your site: the order is captured, the listing granted, buyer redirected
  → PAYMENT.CAPTURE.COMPLETED webhook
      grants the listing — the authority, and a no-op if the return already did

Both paths end in the same fulfilment function Stripe uses, so a listing is granted by the same rules whichever provider took the money. It is idempotent — the capture id is stored under a unique constraint, so a replayed webhook changes nothing.

If the buyer approves and then closes the tab, nothing captures on the way back. CHECKOUT.ORDER.APPROVED captures it server-side instead.

No migration. PayPal reuses the columns Stripe already writes, and payments.payment_method now records which provider took the money.

A claim fee runs exactly like a listing payment: an order, the buyer approves, the return trip captures it, and the listing is handed to its new owner by the same function the Stripe webhook calls.

A refund marks the claim refunded and stops there — the listing stays with its new owner. That is deliberate, and the same on Stripe: a refund is as often a goodwill gesture as a reversal, so taking a listing back is a decision for you, not for the webhook.

How a store order runs

"Buy now" and the cart checkout both offer PayPal once it is configured, with the choice sitting above the pay button.

The cart travels inside the order. Stripe keeps it in the checkout session's metadata; PayPal has nowhere to put it — its custom_id holds 127 characters — so each line rides in its own order item with <productId>:<variantId> in the sku, and the webhook reads the cart back from there. Prices are re-read from the database whichever provider took the money, and nothing is stored before the buyer pays.

What PayPal is told about shipping depends on the cart:

The cartWhat PayPal is asked for
Print-on-demand, address already on the shipping formThat address, with the Printful rate as the order's shipping line
Physical goods, no address yetAsk the buyer for one
Digital onlyNo address at all
Shipping countries are enforced before the money moves

Stripe applies shippingCountries on its own checkout page. PayPal cannot — but approving is not paying, so the app reads the approved order and refuses to capture one shipping outside the list. The buyer is not charged, lands on the cancel page with "We can't ship there", and keeps their cart. The webhook's safety-net capture runs the same check, so there is no way around it.

Fulfilment is the code the Stripe webhook runs: the order and its items are recorded, stock goes down, print-on-demand lines go to Printful, and the buyer gets the confirmation email. A refund marks the order refunded; stock is not put back and the Printful order is not cancelled, because the goods may already be printed or on their way.

Decimal points in JPY, HUF and TWD

PayPal refuses them. Amounts are formatted per currency, so a ¥1500 item is sent as 1500, not 1500.00. Nothing to configure — worth knowing if you are reconciling by hand.

How a subscription runs

PayPal will not take a price straight into a checkout the way Stripe does. A subscription points at one Plan, and a plan belongs to a Product — catalogue objects that have to exist before anyone can pay. The app creates them for you and reuses them:

  • One product per installation, named DirectoryLaunch subscriptions.
  • One plan per price and period, named after what it bills. A restarted server finds the plan it made last week instead of adding a second one. Plans accumulate in Products & Plans in the PayPal dashboard — that is expected, not a leak.

A promotion with several placements is one plan, not several subscriptions. Its price is the sum of the placements chosen, which keeps one row, one subscription and one lifecycle — the shape the Stripe flow already has.

No migration. The subscription id lives in the existing stripe_subscription_id column on partners, promotions and lead_subscriptions. The name is historical; which provider issued an id is read off the id itself — Stripe's are sub_…, PayPal's are I-….

Testing in the sandbox

  1. Set PAYPAL_ENV=sandbox with your sandbox app's credentials
  2. In the developer dashboard, Testing Tools → Sandbox accounts, copy a personal account's email and password — that account is your test buyer

The Personal account is your test buyer.

  1. Submit a Premium listing, pay as that buyer, and check the listing comes back premium
Webhooks cannot reach localhost

PayPal has to post to a public HTTPS URL. Either expose your dev port with a tunnel (ngrok http 3000) and point the sandbox webhook at https://<id>.ngrok.app/api/webhooks/paypal, or test on a preview deployment. Without a reachable webhook the return trip still captures and still grants the listing — but you will not have tested the path that matters in production.

The boilerplate's next.config.ts already allows the usual tunnel hosts to pull dev resources. Without that, a page served through a tunnel renders blank.

Testing Tools → Webhooks simulator replays a single event — the quickest way to exercise the refund branch, which is otherwise tedious to produce.

Going live

  1. Swap in the live app's client id and secret
  2. Create the webhook again on the live app — its ID is different
  3. Set PAYPAL_ENV=live, or drop the variable and leave testMode: false
  4. Redeploy, then buy one real listing and refund it

Sandbox and live share no data: sandbox payments never appear in the live dashboard, and a live webhook id does not verify sandbox events.

Revenue in the admin dashboard

Card revenue is read from the Stripe API. PayPal revenue is read from your own payments rows, because PayPal's equivalent (Transaction Search) is reporting-grade — delayed by hours and absent from the sandbox. Both are summed into the same chart, and the footnote under it names the sources it actually used.

Troubleshooting

What you seeUsually
Refuses to start, asking for PAYPAL_WEBHOOK_IDA client id with no webhook id. Set all three.
"signature verification failed" in the logsWrong PAYPAL_WEBHOOK_ID, or a sandbox webhook id against live events (or the reverse).
Buyer paid, listing still pendingThe webhook never arrived. The dashboard asks PayPal directly on the next load and heals it; check the webhook's delivery log in the developer dashboard.
"PayPal is not configured on this site"Only some of the three variables are set, or the deployment was not redeployed after adding them.
Buyer approved on paypal.com, never returned, and nothing was ever capturedThe webhook is not subscribed to CHECKOUT.ORDER.APPROVED — check the Events Tracked column, see Step 2.
Capture fails with INSTRUMENT_DECLINEDThe buyer's funding source was refused. They have to start a new order; nothing was taken.
Buyers charged different amountsA Stripe Price and the matching config value disagree — see Step 5.
Subscriber was charged, the sponsor block or placement never appearedThe webhook is missing BILLING.SUBSCRIPTION.ACTIVATED. Add the seven subscription events and check the Events Tracked column.
Plans piling up in PayPal → Products & PlansExpected. One plan per price and period, reused; a new price makes a new plan.
Buyer approved a store order and landed on the cancel page saying "We can't ship there"Their address is outside shippingCountries. Nothing was captured and nothing was charged.

See also