PayPal REST API支付详情接口疑问:是否仅支持未完成支付?
/v1/payments/payment/{payment_id}: Clarifying "that has yet to complete" & Checking Payment Status Let me break this down clearly for you—first, that confusing phrase in the documentation, then how to actually use this interface (and others) to verify if a transaction is complete.
What "that has yet to complete" means
The key takeaway here is: this interface is designed to return details for payments that haven't reached their final, completed state yet.
Think of PayPal's payment flow as having distinct stages. A payment might be created (created state), approved by the user (approved state), but not yet "completed"—like when a merchant hasn't captured the funds, or the transaction is still pending. This endpoint is built for those in-progress payments. If the payment has fully finished (funds captured, transaction finalized), this endpoint won't give you the full picture of its completed status—and in some cases, might not return the data you expect.
How to check payment status with this endpoint
Even though it's focused on in-progress payments, you can still get critical state info from the response:
- Look for the top-level
statefield:created: Payment was created but no user action has been taken yetapproved: User has authorized the payment, but funds haven't been captured (so the transaction isn't fully complete yet)failed: The payment attempt failed
- If the payment has been captured (i.e., completed), the
transactions[].related_resourcesarray will include asaleobject. Thatsaleobject has its ownstatefield—look forcompletedhere to confirm funds have been successfully captured.
Example response snippet for an approved, captured payment:
{ "id": "PAY-123456789", "state": "approved", "transactions": [ { "related_resources": [ { "sale": { "id": "SALE-987654321", "state": "completed", "amount": { "total": "10.00", "currency": "USD" } } } ] } ] }
For fully completed transactions: Use the Sale endpoint
If you know the payment is done and want definitive status details, use the /v1/payments/sale/{sale_id} endpoint instead. You can grab the sale_id from the related_resources section of the payment response (like in the example above). This endpoint is purpose-built for completed transactions and will give you all finalized details, including settlement info, refunds, etc.
Quick recap
- "that has yet to complete" = this endpoint focuses on payments still in the workflow (not fully finalized)
- To check if a payment is complete via this endpoint: Verify the
saleobject exists and itsstateiscompleted - For finalized transactions, use the Sale endpoint for the most accurate, complete data
内容的提问来源于stack exchange,提问作者KayakinKoder

