PayFacto API - v2.0 - POST /charges

PayFacto API - v2.0 - POST /charges

PayFacto API - v2.0 - POST /charges

Creates a new charge for a credit card, terminal, payment token, or cash source. Set capture=false to create a pre-authorization that must be captured separately.

1

Prerequisites

πŸ”‘

Authentication β€” HTTP Basic Auth

All v2.0 endpoints use HTTP Basic Authentication. Set Authorization: Basic base64(username:password). Contact PayFacto for credentials.

πŸ“‹

Content-Type

All request bodies require Content-Type: application/json.

πŸ”„

Idempotency

Include Idempotency-Key header (max 64 chars) on POST requests. 200 = duplicate; 201 = newly created.

πŸ’΅

Amounts

All monetary amounts are positive integers in cents. $12.99 = 1299.

2

Request

POST  https://uat.ca.api.payfacto.cloud/payments/v1/charges
ℹ️

Authenticate with HTTP Basic Auth. Include Content-Type: application/json and optionally Idempotency-Key.

Request body fields

FieldConstraintDescription
amountinteger Β· requiredAmount in cents. Must be >= 1. $12.99 = 1299.
invoiceNumberstring Β· requiredMerchant invoice reference. Max 25 chars.
paymentMethodobject Β· requiredPayment method. Required: type (CARD, TERMINAL, PAYMENT_TOKEN, CASH). Include matching sub-object.
captureboolean Β· optionalCapture immediately. Default: true. Set false for pre-authorization.
billingDetailobject Β· optionalCustomer billing address, email, first/last name, phone.
shippingDetailobject Β· optionalShipping recipient details and tracking number.
statementDescriptorstring Β· optionalDescriptor on customer statement. Max 23 chars.
metadataobject Β· optionalFree-form key-value pairs stored with the charge.

paymentMethod.type values

typeSub-objectWhat to include
CARDpaymentMethod.cardInclude number, expiry.month, expiry.year. Optional: cvv. Supports 3DS via card.authentication.
TERMINALpaymentMethod.terminalRequired: terminalId (UUID). Optional: clerkId, cashback, tip, accountType.
PAYMENT_TOKENpaymentMethod.paymentTokenRequired: storedCredential.type and storedCredential.tokenId.
CASHpaymentMethod.cashRequired: terminalId. Optional: tip, clerkId.
3

Request β€” Code Example

⚠️

Use UAT credentials during testing.

JSON β€” Card charge request
{
"amount": 1299,
"invoiceNumber": "1234567",
"capture": true,
"paymentMethod": {
"type": "CARD",
"card": {
"number": "4111111111111111",
"cvv": "123",
"expiry": { "month": "05", "year": "2039" }
}
},
"billingDetail": {
"firstName": "John", "lastName": "Smith",
"address": { "line1": "56 Sparks Street", "city": "Ottawa", "postalCode": "K5A 1S4", "country": "CA" }
}
}
4

Response

Response fields (charge object)

FieldTypeDescription
idstring (UUID)Unique charge identifier. Store for all subsequent operations.
amountintegerAmount in cents (e.g. 1299 = $12.99).
amountCapturedintegerTotal captured amount in cents.
amountRefundedintegerTotal refunded amount in cents.
billingDetailobjectCustomer billing info (address, email, name, phone).
capturebooleanWhether the charge was captured immediately.
capturedbooleanWhether an uncaptured charge has since been captured.
invoiceNumberstringMerchant invoice reference (max 25 chars).
metadataobjectKey-value pairs for custom data.
originalTransactionTimestring (ISO 8601)UTC timestamp of original transaction. Only on post-charge operations.
paymentMethodobjectPayment method details (type, card/terminal/token data).
refundedbooleanWhether the charge has been fully refunded.
releaseDetailobjectRelease details if the charge was released.
resultobjectAuth result: authCode, batch, declineCode, isoResponseCode, issuerMessage.
shippingDetailobjectShipping recipient information.
statementDescriptorstringMerchant descriptor on customer statement (max 23 chars).
statusstringTransaction status: AUTHORIZED, CAPTURED, DECLINED, FAILED, RELEASED, SUCCEEDED, VOIDED.
transactionTimestring (ISO 8601)UTC timestamp when this object was created.
voidDetailobjectVoid details if voided.
errorobjectError object on failure. Contains code, type, details, message.

status values

statusDescription
AUTHORIZEDPre-authorization hold placed. Not yet captured.
CAPTUREDFunds captured successfully.
DECLINEDTransaction declined by the issuer.
FAILEDTransaction failed at the processing level.
RELEASEDUncaptured pre-authorization released.
SUCCEEDEDFull transaction completed successfully.
VOIDEDTransaction voided before settlement.

result.declineCode values

declineCodeMeaning
DO_NOT_HONORGeneric decline. Ask cardholder to use another card.
INSUFFICIENT_FUNDSBalance too low.
EXPIRED_CARDCard has expired.
INVALID_CVVCVV does not match.
INVALID_NUMBERCard number is invalid.
PICKUP_CARDCard flagged β€” do not accept.
CALL_ISSUERRefer to card issuer.
PIN_TRY_EXCEEDEDToo many incorrect PIN attempts.
CARD_VELOCITY_EXCEEDEDTransaction frequency limit exceeded.
BATCH_EXPIREDBatch expired; re-submit.
INSERT_CARDContactless declined; insert chip.
ISSUER_TIMEOUTIssuer timed out; retry.
DO_NOT_RETRYHard decline β€” do not retry.
5

Response β€” Code Examples

JSON β€” 201 Succeeded
{
"id": "a1822999-099d-4fb1-a354-77be553a5b22",
"amount": 1299,
"amountCaptured": 1299,
"captured": true,
"invoiceNumber": "1234567",
"paymentMethod": { "type": "CARD", "card": { "brand": "VISA", "lastFour": "1111" } },
"result": { "authCode": "012345" },
"status": "SUCCEEDED",
"transactionTime": "2024-05-15T14:30:01Z"
}
JSON β€” 402 Declined
{
"id": "b2933000-1aae-5gc2-b465-88cf664b6c33",
"amount": 1299,
"result": { "declineCode": "DO_NOT_HONOR" },
"status": "DECLINED",
"error": { "code": "ISSUER_DECLINED", "type": "CARD_ERROR", "message": "The card could not be charged." }
}
6

Error / HTTP Status Codes

HTTP StatusMeaningRecommended Action
200OK β€” Previously created (same idempotency key)Check status field in response body
201Created β€” New resource createdStore the id for future operations
400Bad Request β€” Invalid payloadCheck error.details and error.invalidFields
402Payment Required β€” Issuer declinedCheck result.declineCode β€” do not retry automatically
404Not FoundVerify the ID in the request path
422Unprocessable β€” Invalid stateCheck error.message
500Internal Server ErrorRetry with backoff; contact PayFacto Support if persistent