BYO PayPal International Checkout & Automated USD Export E-Invoicing
Technical reference for configuring BYO PayPal checkout for international buyers (country !== 'VN'), passing daily VCB FX exchange rates, and issuing 0% export VAT e-invoices.
Last updated: 2026-11-24
1. Scope & Country Isolation (country !== 'VN')
BYO PayPal checkout and USD pricing apply strictly to international customers where verified country !== 'VN'. Domestic Vietnamese routes, policies, and buyers remain strictly VND and SePay.
2. Configuring Your BYO PayPal Merchant Profile
Save your own PayPal REST Client ID, Client Secret, and Webhook ID inside your project's Credential Vault. Funds settle directly into your PayPal Business account.
await habifyServer.payment.upsertMerchantProfile({
provider: "paypal",
client_id: process.env.PAYPAL_CLIENT_ID!,
client_secret: process.env.PAYPAL_CLIENT_SECRET!,
webhook_id: process.env.PAYPAL_WEBHOOK_ID!,
mode: "live",
supported_currencies: ["USD"]
});3. Automated USD E-Invoicing & 0% Export VAT Conditions
When issuing an e-invoice for a captured PayPal USD transaction, your backend MUST supply the daily VCB buying transfer exchange_rate (invoice-service fails closed with 422 EXCHANGE_RATE_REQUIRED if missing or <= 0). Apply 0% export VAT only when all three criteria hold simultaneously: (1) electronic ToS accepted (tos_accepted === true), (2) non-cash payment via PayPal, and (3) buyer.country !== 'VN' (record buyer name, email, address, and country; tax ID not required). If any condition is absent, apply 10% VAT. Never reverse or adjust the issued invoice later when withdrawing USD from PayPal to a domestic bank account.
await habifyServer.invoice.issue({
request_id: `inv_pp_${captureId}`,
currency: "USD",
exchange_rate: vcbBuyingRateVnd, // required (> 0), fail-closed 422 if omitted
payment_method: "paypal",
tax_rate: "0", // when tos_accepted && paypal && buyer.country !== "VN"
buyer: {
buyer_type: "individual",
name: paypalBuyer.name,
email: paypalBuyer.email,
address: paypalBuyer.address,
country: paypalBuyer.countryCode
},
items: [{ name: "Annual SaaS Subscription", quantity: 1, unit_amount_minor: 2900 }]
});