Skip to content

Commit

Permalink
Added docs for cancel_authorization endpoint. (#7079)
Browse files Browse the repository at this point in the history
Co-authored-by: Naman Malhotra <[email protected]>
  • Loading branch information
zmaglica and naman03malhotra authored Sep 28, 2023
1 parent af41db7 commit 2eb4de5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog/add-documentation-for-cancel-authorization-endpoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: add

Added docs for cancel_authorization endpoint
54 changes: 54 additions & 0 deletions docs/rest-api/source/includes/wp-api-v3/order.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,60 @@ curl -X POST https://example.com/wp-json/wc/v3/payments/orders/42/capture_author
}
}
```
## Cancel an authorization

_@since v5.7.0_

Cancel the authorization of an existing uncaptured payment intent.

### POST params

- payment_intent_id: string

### Error codes

- `wcpay_missing_order` - Order not found
- `wcpay_refunded_order_uncapturable` - Payment cannot be canceled
- `wcpay_payment_uncapturable` - The payment cannot be canceled if intent status is not one of 'processing', 'requires_capture', or 'succeeded'
- `wcpay_intent_order_mismatch` - Payment cannot be canceled because the order id does not match with payment intent id
- `wcpay_cancel_error` - Unknown error

### HTTP request

<div class="api-endpoint">
<div class="endpoint-data">
<i class="label label-get">POST</i>
<h6>/wp-json/wc/v3/payments/orders/&lt;order_id&gt;/cancel_authorization</h6>
</div>
</div>

```shell
curl -X POST https://example.com/wp-json/wc/v3/payments/orders/42/cancel_authorization \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"payment_intent_id": "pi_ZZZZZZZZZZZZZZZZAAAAAAAA"
}'
```

> JSON response example:
```json
{
"status": "canceled",
"id": "pi_ZZZZZZZZZZZZZZZZAAAAAAAA"
}
```

```json
{
"code": "wcpay_missing_order",
"message": "Order not found",
"data": {
"status": 409
}
}
```

## Create customer

Expand Down

0 comments on commit 2eb4de5

Please sign in to comment.