Payments API

Cancel a payment

POST

Provided the payment has not reached SETTLED status, Primer will send a “void” request to the payment processor, thereby cancelling the payment and releasing the hold on customer funds. Upon success, the payment will transition to CANCELLED. The payload is optional.

Path parameters

idstringRequired
ID of payment to cancel.

Headers

X-Idempotency-KeystringOptional
Optional key to make the request idempotent. Enables a safe retry of a request without risking the user being charged or refunded multiple times. The idempotency key must be generated by the client and needs to be unique for every new request.

Request

This endpoint expects an object.
reason
stringOptional
You can optionally specify a reason for the cancellation. This is for your own records.

Response

This endpoint returns an object
id
stringOptional

The unique payment ID.

You can use this ID to retrieve the payment details, or perform downstream operations.

date
datetimeOptional
The date and time at which the payment was created in UTC format.
dateUpdated
datetimeOptional
The date and time of the last payment update in UTC format.
status
enumOptional

See the payment status table for more information.

cardTokenType
enumOptional

The type of card token used for the payment.

Only applies for card payments.

Allowed values: CARD_PANNETWORK_TOKENPROCESSOR_TOKEN
orderId
stringOptional
Your reference for the payment.
currencyCode
enumOptional

The 3-letter currency code in ISO 4217 format. e.g. use USD for US dollars.

amount
integerOptional
The amount you charged the customer, in minor units.
order
objectOptional
More information associated with the order.
customerId
stringOptional
The unique identifier for your customer.
customer
objectOptional
More information associated with the customer.
metadata
map from strings to anyOptional
Additional data to be used throughout the payment lifecycle.
paymentMethod
objectOptional
The payment method options provided in the request, as well as the token used to process the payment.
processor
objectOptional
More information associated with the payment processor, including the processor name.
requiredAction
objectOptional
Required action to perform in order to resume the payment workflow. This can be requiring a 3DS check from the customer for instance.
statusReason
objectOptional

Check this field for more information regarding the payment’s status. This is especially useful when the status is DECLINED or FAILED.

transactions
list of objectsOptional

A list summarizing the transactions that occurred while processing the payment.

Note: a refund is a separate transaction and so will appear in this transactions list if a refund was performed.

riskData
objectOptional
Risk data associated with this payment.

Errors