Skip to main content
PayPal is implemented in two parts:
  1. Merchant onboarding — registering and connecting seller accounts as Partners
  2. Payment gateway — processing end-customer payments, creating orders, and managing webhooks
These services let the platform authenticate sellers and manage financial transactions.

Configuration

Two clients

Merchant onboarding

1. Create Partner Referral

  • Flow: User → Core Backend → Integration Services → PayPal API
  • Internal endpoint: POST /paypal/partner-referrals
  • PayPal endpoint: POST /v2/customer/partner-referrals
Response includes an onboarding_url to redirect the seller to.

2. Onboarding return (callback)

  • Flow: PayPal → User redirect → Core Backend
  • The Core Backend receives merchantId and trackingId in the URL and persists the merchantId.
This step does not call the Integration Service.

3. Verify merchant integration

  • Internal endpoint: GET /paypal/merchant-integrations/:merchantId
Checks whether the merchant is fully authorized to receive payments.
If payments_receivable === true and vetting_status !== 'DENIED', the Core Backend enables the PayPal gateway for that shop.

Payment & checkout

Create payment intent

  • Internal endpoint: POST /payment-gateway/create-intent
Scenario A — merchant account connected. Funds transfer directly or split:
Scenario B — merchant account not connected. Funds stay in the platform’s primary PayPal account:

Webhook handling & normalization

  • Flow: PayPal → Integration Services → Core Backend (/webhook/generic)
When the Integration Service receives a PayPal webhook, it validates the signature and sends a normalized payload to the Core Backend:

Status mapping

Flow diagrams

Merchant onboarding

Payment checkout

Security notes

1

Webhook verification

All webhooks are validated using paypal-transmission-sig and PAYPAL_WEBHOOK_ID. The signature includes transmissionId, timestamp, webhookId, and the CRC32 of the request body.
2

Token management

A new access token is obtained for each onboarding request (Client Credentials Flow). No sensitive tokens are logged.
3

HMAC comparison

crypto.timingSafeEqual (or safeCompareHmac) is used to compare signatures and prevent timing attacks.

Troubleshooting