Use this file to discover all available pages before exploring further.
Refund captured payments to customers after an initial transaction. Common scenarios include:
Customer returns a product or requests a refund from a service
Customer cancels an order after payment
Customer requests a partial refund
This integration uses the Payments API v2 to process full or partial refunds with the capture ID from the original payment. Add refund endpoints to your existing PayPal integration with comprehensive error handling and negative testing capabilities.
# Test full refund (replace with actual capture ID)curl -X POST http://localhost:3000/api/captures/3C679366HH908993F/refund \ -H "Content-Type: application/json"# Expected success response:# {"id":"WH4YN4SYEDZJA","status":"COMPLETED","amount":"100.00"}# Test partial refund with notecurl -X POST http://localhost:3000/api/captures/3C679366HH908993F/refund \ -H "Content-Type: application/json" \ -d '{"amount": "25.00", "note": "Partial refund for damaged item"}'# Test refund status checkcurl http://localhost:3000/api/refunds/WH4YN4SYEDZJA# Expected response:# {"id":"WH4YN4SYEDZJA","status":"COMPLETED","amount":"25.00"}
Use the following best practices to ensure refunds are processed safely, accurately, and in compliance with operational and regulatory requirements.
Store capture IDs: Always save capture IDs from successful payments in your database for future refunds.
Use idempotency keys: Use idempotency keys when processing refunds to avoid duplicate refunds in case of network issues.
Validate refund amounts: Check the refund amount doesn’t exceed original payment or remaining refundable balance.
Log all refunds: Keep an audit trail of who initiated refunds, when, and why. This is critical for compliance.
Provide refund notes: Include clear explanation in the note_to_payer field for customer clarity.
Handle partial refunds: Track cumulative refunded amounts to prevent over-refunding.
Process refunds within 180 days: Process refunds within 180 days of the original capture date. Your customer’s bank may have shorter windows. After extended periods, manual intervention through PayPal support may be required.
Implement approval workflows: Processed refunds cannot be cancelled. Build approval workflows for refunds over a certain threshold.
Have backup manual refund process: Have a manual refund process as backup. Log failed attempts and escalate to PayPal support with the error details.
Find capture IDs: The capture ID is returned as capture.result.id when you capture a payment. Store this value in your database immediately. You’ll need it for any future refunds on that transaction.
Refund processing time: In sandbox mode, refunds complete instantly. In production, customers see refunds in their account within 3-5 business days, though timing varies by payment method.
Webhook notifications: Set up webhooks to receive PAYMENT.CAPTURE.REFUNDED events for real-time status updates. Always verify webhook signatures for security.
No refunds to different payment methods: Refunds always go back to the customer’s original payment method.
No currency conversion: Always refund in the same currency as the original payment. PayPal handles any exchange rate adjustments automatically.