import type { CheckoutParams, CheckoutResult, RefundParams, RefundResult, WebhookEvent } from '../core/provider.interface.js'; import { AbstractPaymentProvider } from '../core/abstract-provider.js'; export interface PayPalConfig { clientId: string; secret: string; testMode?: boolean; returnUrl: string; cancelUrl: string; webhookId?: string; } export declare class PayPalProvider extends AbstractPaymentProvider { private config; readonly name = "paypal"; readonly supportedCurrencies: string[]; readonly supportedMethods: string[]; private baseUrl; private tokenCache; constructor(config: PayPalConfig); private getAccessToken; private api; protected doCheckout(params: CheckoutParams): Promise; /** * Capture a PayPal order after user approval. * Call this when PayPal redirects back to returnUrl with ?token=ORDER_ID */ captureOrder(orderId: string): Promise<{ status: string; data: Record; }>; /** * Get order details. */ getOrder(orderId: string): Promise>; createRefund(params: RefundParams): Promise; /** * VÉRIFIE RÉELLEMENT le webhook — auprès de PayPal. * * ── CE QUE CETTE FONCTION FAISAIT AVANT, ET CE QUE ÇA COÛTAIT ───────────── * Elle analysait le JSON et lui faisait confiance : « For now, trust the parsed event ». * L'adresse d'un webhook est publique par nature — on la déclare chez la banque. N'importe qui * pouvait donc y poster un `PAYMENT.CAPTURE.COMPLETED` portant un identifiant de commande, et * l'application le prenait pour un paiement : règlement écrit, recette au livre, **plat envoyé * en cuisine**. L'identifiant n'est pas secret — il figure dans l'URL que le client voit. Un * client pouvait donc commander, relever son propre identifiant, et se faire servir sans payer. * * ── POURQUOI PAYPAL NE SE VÉRIFIE PAS COMME LES AUTRES ─────────────────── * Stripe, Chargily, Paystack signent avec un HMAC qu'on recalcule localement. PayPal, non : il * envoie **cinq en-têtes** et un certificat, et c'est SON API qui tranche * (`POST /v1/notifications/verify-webhook-signature`). D'où le paramètre `headers`, et d'où * l'utilité de `PAYPAL_WEBHOOK_ID` — qui n'est pas un secret, mais l'identifiant SANS LEQUEL * PayPal ne peut pas savoir quelle configuration vérifier. * * ⚠️ **Sans `webhookId`, on LÈVE.** Accepter « faute de pouvoir vérifier » rétablirait * exactement le défaut qu'on corrige, avec la bonne conscience en plus. */ protected doVerifyWebhook(body: string, _signature: string, headers?: Headers | Record): Promise; /** * Verify webhook signature via PayPal API (production). */ verifyWebhookSignature(headers: Record, body: string): Promise; } /** * Create a PayPal provider from environment variables. */ export declare function createPayPalProvider(config?: Partial): PayPalProvider; //# sourceMappingURL=paypal.provider.d.ts.map