Cancel a PaymentIntent
Cancels a PaymentIntent resource. A payment intent with a status of canceled
means your customer cannot proceed with paying the particular payment intent.
For example, if an order from your business should be cancelled, you should also call the cancel payment intent endpoint to ensure that your customer cannot pay the payment intent moving forward.
You can only cancel a payment intent with status awaiting_payment_method
.
Endpoint
POST /payment_intents/:id/cancel
Sample code
- curl
- Node
- PHP
- Python
- Ruby
curl --request POST --location 'https://api.payrexhq.com/payment_intents/<ID of a payment intent resource>/cancel' \
-u replace_with_secret_api_key: \
--data-urlencode 'amount=10000'
const client = require('payrex-node')('insert your PayRex Secret API key.');
const paymentIntent = await client.paymentIntents.cancel(
// Payment Intent to cancel.
'<ID of a payment intent resource>',
)
$client = new \Payrex\PayrexClient('insert your PayRex Secret API key.');
$paymentIntent = $client->paymentIntents->cancel('<payment intent id to cancel>');
from payrex import Client as PayrexClient
client = PayrexClient('insert your PayRex Secret API key.')
payment_intent = client.payment_intents.cancel(
# Payment Intent to cancel.
'<ID of a payment intent resource>',
)
client = Payrex::Client.new("insert your PayRex Secret API key.")
payment_intent = client.payment_intents.cancel(
# Payment Intent to cancel.
"<ID of a payment intent resource>",
)
Parameters
id REQUIRED
The id of the PaymentIntent to be cancelled.
Returns
Returns a PaymentIntent resource.