Payments API

Authorize a payment

POST

Manually authorize a payment using a provided processor. This is useful if you want to authorize a payment without a workflow action. The processor merchant ID must be provided which can be found on the Integrations page. The processor name is optional but it must be provided if your account has multiple processors configured which share the same merchant IDs.

Path parameters

idstringRequired
ID of the payment to authorize.

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.
processor
objectRequired
The payment processor to use for this payment.

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/authorize \
> -H "X-API-KEY: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "processor": {
> "processorMerchantId": "acct_myprocessor_1234"
> }
>}'
Response
1{
2 "id": "kHdEw9EG",
3 "date": "2021-02-21T15:36:16.367687",
4 "dateUpdated": "2021-02-21T15:36:17.133701",
5 "status": "AUTHORIZED",
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": "MYPROCESSOR",
76 "processorMerchantId": "acct_myprocessor_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_myprocessor_1234",
95 "transactionType": "SALE",
96 "processorTransactionId": "54c4eb5b3ef8a",
97 "processorName": "MYPROCESSOR",
98 "processorStatus": "AUTHORIZED",
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}