You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何取消PayPal v2 API中状态为CREATED且超过10分钟的订单?

Fixing PayPal v2 Orders Cancellation (Instead of Using DELETE)

Hey there, I’ve run into this exact issue before—let me break down the correct way to cancel those stale CREATED orders for you.

First off, you’re right that the DELETE method isn’t supported for the v2 Orders API. PayPal designed this API to use PATCH requests to modify order statuses instead of deleting them entirely. Here’s how to make it work for your use case:

Step 1: Target the Right Orders

First, filter your orders to only those that:

  • Have a status of CREATED
  • Were created more than 10 minutes ago (you’ll need to track creation timestamps on your end since PayPal doesn’t expose a "time since creation" filter directly)

Step 2: Use the PATCH Endpoint

Call the PATCH /v2/checkout/orders/{order_id} endpoint with a JSON Patch payload that updates the order’s status to CANCELLED.

Example Request Payload:

[
  {
    "op": "replace",
    "path": "/status",
    "value": "CANCELLED"
  }
]

Step 3: Authentication & Headers

Just like other PayPal v2 API calls, you’ll need to include your valid OAuth 2.0 access token in the Authorization header (format: Bearer YOUR_ACCESS_TOKEN), and set Content-Type to application/json.

Important Notes:

  • This only works for orders in CREATED or APPROVED status. Once an order is COMPLETED, you can’t cancel it (you’d need to process a refund instead).
  • PayPal will automatically expire CREATED orders after a set period (usually 3 hours), but manually cancelling stale ones after 10 minutes is a good practice to keep your order list clean.

内容的提问来源于stack exchange,提问作者Erik Huzinecz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.01 01:37:27