Payments API

Capture a payment

POST

If you have successfully authorized a payment, you can now fully capture, or partially capture funds from the authorized payment, depending on whether your selected payment processor supports it. The payment will be updated to SETTLED or SETTLING, depending on the payment method type.

The payload sent in this capture request is completely optional. If you don’t send a payload with the capture request, the full amount that was authorized will be sent for capture. Below are the available payload attributes, which give you more granular control when capturing funds, if you require it.

Path parameters

idstringRequired
ID of the payment to capture.

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.
amount
integerOptional

The amount you would like to capture, in minor units. The currency used on authorization is assumed.

If no amount is specified it defaults to the full amount.

final
booleanOptional

Indicates whether the capture request is the final capture request.

After a final capture, no subsequent captures are allowed.

order
objectOptional
More information associated with the order.
metadata
map from strings to anyOptional

Additional payment metadata. This only takes effect if the payment was created via the New Workflows (read more here). A dictionary of key-value pairs where the values can only be strings or integers. Keys which already exist in the payment metadata will be overwritten.

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
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

Errors

POST
$curl -X POST https://api.sandbox.primer.io/payments/string/capture \
> -H "X-API-KEY: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "order": {
> "retailerCountryCode": "AW"
> }
>}'
Response
1{
2 "id": "kHdEw9EG",
3 "date": "2021-02-21T15:36:16.367687",
4 "dateUpdated": "2021-02-21T15:36:17.133701",
5 "status": "SETTLED",
6 "cardTokenType": "CARD_PAN",
7 "orderId": "order-abc",
8 "currencyCode": "EUR",
9 "amount": 42,
10 "order": {
11 "lineItems": [
12 {
13 "amount": 1,
14 "productType": "PHYSICAL",
15 "productData": {}
16 }
17 ],
18 "countryCode": "AW",
19 "retailerCountryCode": "AW",
20 "fees": [
21 {
22 "amount": 1
23 }
24 ],
25 "shipping": {}
26 },
27 "customerId": "customer-123",
28 "customer": {
29 "billingAddress": {
30 "countryCode": "AW"
31 },
32 "shippingAddress": {
33 "countryCode": "AW"
34 }
35 },
36 "metadata": {
37 "productId": 123,
38 "merchantId": "a13bsd62s"
39 },
40 "paymentMethod": {
41 "descriptor": "Purchase: Socks",
42 "paymentType": "SUBSCRIPTION",
43 "paymentMethodToken": "heNwnqaeRiqvY1UcslfQc3wxNjEzOTIxNjc4",
44 "isVaulted": true,
45 "analyticsId": "VtkMDAxZW5isH0HsbbNxZ3lo",
46 "paymentMethodType": "PAYMENT_CARD",
47 "paymentMethodData": {
48 "first6Digits": "411111",
49 "last4Digits": "1111",
50 "expirationMonth": "12",
51 "expirationYear": "2030",
52 "cardholderName": "John Biggins",
53 "network": "Visa",
54 "isNetworkTokenized": false,
55 "binData": {
56 "network": "VISA",
57 "issuerCountryCode": "AW",
58 "issuerCurrencyCode": "AED",
59 "regionalRestriction": "UNKNOWN",
60 "accountNumberType": "UNKNOWN",
61 "accountFundingType": "UNKNOWN",
62 "prepaidReloadableIndicator": "NOT_APPLICABLE",
63 "productUsageType": "UNKNOWN",
64 "productCode": "VISA",
65 "productName": "VISA"
66 }
67 },
68 "threeDSecureAuthentication": {
69 "responseCode": "NOT_PERFORMED",
70 "reasonCode": "GATEWAY_UNAVAILABLE"
71 },
72 "authorizationType": "FINAL"
73 },
74 "processor": {
75 "name": "STRIPE",
76 "processorMerchantId": "acct_stripe_1234",
77 "amountCaptured": 42,
78 "amountRefunded": 0
79 },
80 "requiredAction": {
81 "name": "3DS_AUTHENTICATION",
82 "description": "string"
83 },
84 "statusReason": {
85 "type": "APPLICATION_ERROR",
86 "declineType": "SOFT_DECLINE",
87 "code": "ERROR"
88 },
89 "transactions": [
90 {
91 "date": "string",
92 "amount": 1,
93 "currencyCode": "AED",
94 "processorMerchantId": "acct_stripe_1234",
95 "transactionType": "SALE",
96 "processorTransactionId": "54c4eb5b3ef8a",
97 "processorName": "STRIPE",
98 "processorStatus": "SETTLED",
99 "processorStatusReason": {
100 "type": "APPLICATION_ERROR",
101 "declineType": "SOFT_DECLINE",
102 "code": "ERROR"
103 },
104 "cardTokenType": "CARD_PAN"
105 }
106 ],
107 "riskData": {
108 "fraudChecks": {
109 "source": "FRAUD_PROVIDER",
110 "preAuthorizationResult": "THREE_DS",
111 "postAuthorizationResult": "ACCEPT"
112 },
113 "cvvCheck": {
114 "source": "PROCESSOR",
115 "result": "MATCHED"
116 },
117 "avsCheck": {
118 "source": "PROCESSOR",
119 "result": {
120 "streetAddress": "NOT_MATCHED",
121 "postalCode": "NOT_VERIFIED"
122 }
123 }
124 }
125}