PayFacto API - v1.0 - POST /v1/iapPurchaseCorrection

PayFacto API - v1.0 - POST /v1/iapPurchaseCorrection

PayFacto API - v1.0 - POST /v1/iapPurchaseCorrection

Reverses a previously approved IAP (Interac Automated Payment) Purchase in full. Must be performed on the same business day as the original IAP Purchase, before batch close. The OriginalAuthorizationNumber, OriginalTransactionNumber, OriginalInvoiceNumber, and OriginalAmount from the original IAP Purchase response are all required.

1

Prerequisites

πŸ”‘

API Key

Generate your API key from the Payments Manager: Administrator Client β†’ API Key β†’ Add New Key. Pass it as auth-api-key in every request.

πŸͺ

Company & Merchant Numbers

Your CompanyNumber (5-digit) and MerchantNumber (8-digit) are issued by PayFacto during onboarding. Both must match the company and merchant numbers of the original IAP Purchase.

🌐

Environment Base URL

Test: https://test.api.payfacto.cloud/v1   |   Production: Provided by the PayFacto Integration team upon certification.

πŸ“¦

Request Format β€” Base64-Encoded Payload

Requests use HTTP POST with an application/x-www-form-urlencoded body. Assemble all parameters as a cleartext query string, Base64-encode it, then send: auth-api-key={key}&payload={base64}. For terminal transactions (InputType=N), send CardNumber as 40 space characters and ExpirationDate as 4 space characters.

🏦

IAP β€” Interac Automated Payment

IAP (Interac Automated Payment) endpoints handle Interac debit transactions processed through integrated systems. This endpoint is exclusively for correcting IAP Purchase transactions. It cannot be used to reverse an IAP Pre-Authorization/Completion β€” use Void (/v1/void) for those.

⏰

Same-Day Correction β€” Before Batch Close

This correction must be performed on the same business day as the original IAP Purchase, before batch close. The correction amount must match the original IAP Purchase amount exactly. To reverse an IAP Purchase after batch close, use an IAP Refund (/v1/iapRefund) instead.

↩️

Original IAP Purchase Required

The OriginalAuthorizationNumber, OriginalTransactionNumber, OriginalInvoiceNumber, and OriginalAmount must all be taken from the response of the original /v1/iapPurchase. The correction amount submitted in Amount must be identical to OriginalAmount.

2

Request

POST https://test.api.payfacto.cloud/v1/iapPurchaseCorrection
ℹ️

All parameters are passed inside the Base64-encoded payload form field. Raw body format: auth-api-key=<key>&payload=<base64>. For terminal transactions (InputType=N), send CardNumber as 40 space characters and ExpirationDate as 4 space characters.

Required fields

FieldTypeDescription
CompanyNumberNumeric(5)Identifies the merchant on PayFacto's network. Must match the company number of the original IAP Purchase. Example: 12345
MerchantNumberNumeric(8)Identifies the merchant to PayFacto's network. Must match the merchant number of the original IAP Purchase. Example: 53400000
CustomerNumberAlphanumeric(8)Merchant-assigned customer identifier. Associates a client record with the transaction. Example: CLIENT12
AmountNumeric(11)The correction amount, including the decimal portion, left (0) padded. Must be identical to the OriginalAmount of the IAP Purchase being reversed. Example: 00000010000 = $100.00
InvoiceNumberAlphanumeric(12)Merchant-generated invoice number for this IAP Purchase Correction. May be unique or reused per merchant needs. Example: COR000000001
InputTypeAlphanumeric(1)How the transaction is initiated. N = terminal/pinpad (Semi-Integrated), I = Internet/E-Commerce, M = MOTO, U = Unattended.
CardTypeAlphanumeric(1)Card brand. For InputType=N send a blank space. For I/M: A = Amex, M = Mastercard, V = Visa, I = Diners, O = Discover. Blank for unknown.
CardNumberAlphanumeric(40)Cardholder's card number, left-justified and space-padded to 40 characters. For InputType=N, send 40 space characters β€” the terminal reads the card directly.
ExpirationDateNumeric(4)Card expiration date in MMYY format. For InputType=N, send 4 space characters. Example: 1226
MerchantTerminalNumberNumeric(5)Identifies the terminal on PayFacto's network. For E-Commerce transactions, send 5 blank spaces. Example: 12345
LanguageCodeAlphanumeric(1)Language for PayFacto responses and terminal display. F = French, E = English.
CurrencyCodeAlphanumeric(3)Currency of the transaction (indicative only). CAD = Canadian dollars, USD = US dollars (requires a US merchant number).
OperatorIDAlphanumeric(8)Identifies the cashier, agent, or system that initiated the transaction. Example: USER0001
OriginalInvoiceNumberAlphanumeric(12)The merchant's invoice number from the original IAP Purchase request and response. Must match the invoice number recorded on the original IAP Purchase exactly. Example: PUR000000001
OriginalAuthorizationNumberAlphanumeric(8)The authorization number returned in the response of the original IAP Purchase. Example: APPROV01
OriginalTransactionNumberNumeric(12)The transaction number returned in the response of the original IAP Purchase. Example: 000111222333
OriginalAmountNumeric(11)The amount of the original IAP Purchase, including the decimal portion, left (0) padded. The correction Amount must match this value exactly. Example: 00000010000 = $100.00

Optional fields

FieldTypeDescription
taxAmountNumeric(11)Total tax amount included in Amount, left (0) padded. Example: 00000000374 = $3.74
TrxOptionAlpha(50)Adds transaction-level options. Accepted values: isCredentialOnFile, isRecurring, isInstallment (mutually exclusive).
UserEchoDataAlphanumeric(256)Custom data printed on the terminal receipt (Semi-Integrated only). Pipe-delimited line segments. Contact PayFacto integration before use.
3

Request β€” Code Example

⚠️

The example below uses the test endpoint and a sandbox API key, and shows a terminal (InputType=N) IAP Purchase Correction. Replace credentials and base URL before going live. The correction must be submitted on the same business day as the original IAP Purchase, before batch close.

cURL
# IAP Purchase Correction -- POST /v1/iapPurchaseCorrection
# Step 1: Build the cleartext payload (InputType=N, terminal reads card directly)

PAYLOAD="CompanyNumber=12345&MerchantNumber=53400000&CustomerNumber=CLIENT12&Amount=00000010000&InvoiceNumber=COR000000001&InputType=N&CardType= &CardNumber= &ExpirationDate= &MerchantTerminalNumber=12345&LanguageCode=E&CurrencyCode=CAD&OperatorID=USER0001&OriginalInvoiceNumber=PUR000000001&OriginalAuthorizationNumber=APPROV01&OriginalTransactionNumber=000111222333&OriginalAmount=00000010000"

# Step 2: Base64-encode the payload
ENCODED=$(echo -n "$PAYLOAD" | base64)

# Step 3: Submit the request
curl -X POST "https://test.api.payfacto.cloud/v1/iapPurchaseCorrection" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "auth-api-key=YOUR_TEST_API_KEY&payload=$ENCODED"
4

Response

Always returned

FieldTypeDescription
returnCodeAlphanumeric(4)Identifies the exact status of the transaction result. 00 = correction applied successfully. All other values indicate a failure. Refer to Section 6 for endpoint-specific codes.
authorizationNumberAlphanumeric(8)Authorization code for the correction transaction. Mandatory to display on all customer receipts. Example: CORR0001
transactionNumberNumeric(12)Unique PayFacto gateway transaction identifier for this IAP Purchase Correction. Example: 000111222444
amountNumeric(11)Echo of the requested correction amount.
accountTypeAlphanumeric(1)Account type used for the transaction. C = Chequing, S = Savings.
bankTerminalNumberAlphanumeric(8)Terminal identifier at the banking acquirer that processed the transaction.
batchNumberNumeric(4)Batch number used when the transaction was processed. Can be used when generating client receipts. Example: 0001
cardNumberAlphanumeric(40)Echo of the request CardNumber (masked).
cardTypeAlphanumeric(1)Card brand determined by the network. D = Debit (Interac) is expected for IAP transactions.
companyNumberNumeric(5)Echo of the request CompanyNumber.
expirationDateNumeric(4)Echo of the request ExpirationDate, in MMYY format.
invoiceNumberAlphanumeric(12)Echo of the request InvoiceNumber.
languageCodeAlphanumeric(1)Echo of the request LanguageCode.
merchantNumberNumeric(8)Echo of the request MerchantNumber.
operatorIdAlphanumeric(8)Echo of the request OperatorID.
receiptDispAlphanumeric(32)PayFacto-generated receipt message. Can be used to produce a receipt. Example: APPROVED-THANK-YOU
referenceNumberAlphanumeric(10)Reference number obtained following successful processing of the correction.
sequenceNumberAlphanumeric(12)Sequence number generated by the banking acquirer.
serverNumberAlphanumeric(4)Identifies the PayFacto Network server that processed the transaction.
terminalDispAlphanumeric(24)Transaction message displayed on the terminal or payment page. Example: APPROVED
terminalNumberNumeric(5)Identifies the terminal in the PayFacto Network used to process the transaction.
timeStampAlphanumeric(17)Date and time the transaction was processed on the payment server. Format: YYYYMMDD-HHMMSSCC. Example: 20240515-15300100
trxCodeAlphanumeric(2)Transaction type code. For an IAP Purchase Correction this is always 00.
trxDateNumeric(8)Transaction date at the banking acquirer. Format: MMDDYYYY. May differ from timeStamp.
trxMethodAlphanumeric(3)Summarizes how the transaction was processed. First character: D = swiped, T = manual entry. Third character: 1 = authorized. Example: D@1
trxTimeNumeric(6)Transaction time at the banking acquirer. Format: HHMMSS. May differ from timeStamp.
trxTypeAlphanumeric(1)Type of card used. For IAP transactions this will be D = Debit.

Conditionally returned

FieldTypeDescription
customerNumberAlphanumeric(8)Only returned when provided in the request. Echo of the request CustomerNumber.
cvmResultsAlphanumeric(6)Only returned for chip (EMV) transactions. Cardholder Verification Method result. Print a signature line on the receipt if the first 2 digits are 03, 05, 43, 45, 1E, or 5E.
demoModeAlphanumeric(4)Only returned when the terminal is in demo mode. Value will be true.
emvAIDAlphanumeric(32)Only returned for chip (EMV) transactions. EMV Application Identifier. Example: AID: A000000277
emvLabelAlphanumeric(16)Only returned for chip (EMV) transactions. Human-readable application label. Example: Interac
emvTCAlphanumeric(40)Only returned for chip (EMV) transactions. EMV Transaction Cryptogram. Example: TC: A2E51243D4C7E551
emvTSIAlphanumeric(4)Only returned for chip (EMV) transactions. EMV Transaction Status Information.
emvTVRAlphanumeric(10)Only returned for chip (EMV) transactions. EMV Terminal Verification Result.
errorDescriptionAlphanumeric(50)Only returned when the transaction is not approved. Human-readable description of the failure reason.
surchargeAmountNumeric(11)Only returned when a surcharge was applied. Left (0) padded.
taxAmountNumeric(11)Only returned when taxAmount was included in the request. Echo of the submitted tax amount.
terminalInvoiceNumberNumeric(12)Only returned for terminal transactions. Terminal-assigned invoice number.
tipAmountNumeric(11)Only returned when a tip was added at the terminal. Left (0) padded.
tokenAlphanumeric(35)Only returned when tokenization is enabled. Token linked to the cardholder for future token-based transactions.
5

Response β€” Code Example

JSON β€” 200 Approved
{
"returnCode": "00",
"authorizationNumber": "CORR0001",
"transactionNumber": "000111222444",
"referenceNumber": "0000000002",
"amount": "00000010000",
"accountType": "C",
"cardNumber": "457300XXXXXX0001 ",
"cardType": "D",
"trxType": "D",
"trxCode": "00",
"trxDate": "05152024",
"trxTime": "153001",
"trxMethod": "D@1",
"timeStamp": "20240515-15300100",
"batchNumber": "0001",
"sequenceNumber": "000011112223",
"serverNumber": "0001",
"terminalNumber": "12345",
"bankTerminalNumber": "00000001",
"companyNumber": "12345",
"merchantNumber": "53400000",
"invoiceNumber": "COR000000001",
"expirationDate": " ",
"languageCode": "E",
"operatorId": "USER0001",
"receiptDisp": "APPROVED-THANK-YOU ",
"terminalDisp": "APPROVED "
}
JSON β€” Declined / Error
{
"returnCode": "9066",
"errorDescription": "INVALID ORIGINAL TRANSACTION STATUS",
"terminalDisp": "DECLINED ",
"receiptDisp": "DECLINED ",
"transactionNumber": "000111222445",
"timeStamp": "20240515-15300200"
}
6

Error / Return Codes

The following codes are most relevant to this endpoint. For the complete catalogue see the Return Code Index.

Return CodeMeaningWhen it occursRecommended Action
00Transaction approvedThe IAP Purchase has been fully reversed and the Interac debit charge removed from the batch.Display the authorizationNumber on the customer receipt. No follow-up operation is required.
05Transaction declinedThe IAP Purchase Correction was declined by the issuing bank.Retry the transaction. If the problem persists, contact PayFacto customer service.
9004"Null" value: company numberCompanyNumber is null or blank in the payload.Check your application. The field must correspond to the specification in the documentation.
9005 / 9006Invalid / rejected: company numberCompanyNumber does not match the required 5-digit length or is not configured in the payment solution.Make sure the application uses the correct company number provided by PayFacto. If it does, contact PayFacto customer service.
9007"Null" value: merchant numberMerchantNumber is null or blank in the payload.Check your application. The field must correspond to the specification in the documentation.
9008 / 9009Invalid / rejected: merchant numberMerchantNumber does not match the required 8-digit length or is not configured in the payment solution.Make sure the application uses the merchant number provided by PayFacto. If it does, contact PayFacto customer service.
9013 / 9014 / 9015Null / invalid / rejected: amountAmount is null, does not match the required 11-digit length, or does not follow the specification.Confirm the amount is left (0) padded to 11 digits and matches the original IAP Purchase amount exactly. If the problem persists, contact PayFacto customer service.
9016 / 9017 / 9018Null / invalid / rejected: invoice numberInvoiceNumber is null, exceeds 12 characters, or does not follow the specification.Check your application. The field must correspond to the specification in the documentation.
9019 / 9020 / 9021Null / invalid / rejected: input typeInputType is null, not a single character, not in the list of accepted values, or not associated with the merchant.Check your application. The field must correspond to the specification in the documentation.
9022 / 9023 / 9024Null / invalid / rejected: card typeCardType is null, not a single character, or not in the list of accepted values.Check your application. For terminal transactions send a blank space.
9025 / 9026 / 9027Null / invalid / rejected: card numberCardNumber is null, exceeds 40 characters, or does not follow the specification.For terminal transactions send 40 space characters.
9028 / 9029 / 9030Null / invalid / rejected: expiration dateExpirationDate is null, not 4 characters, or does not follow the specification.For terminal transactions send 4 space characters.
9031"Null" value: POS terminal numberMerchantTerminalNumber is null or blank when a terminal transaction is being attempted.Check your application. For terminal transactions provide a valid terminal number; for E-Commerce send 5 blank spaces.
9032 / 9033Invalid / rejected: POS terminal numberMerchantTerminalNumber does not follow the specification, or the merchant is not configured as a POS terminal merchant.Check your application. The field must correspond to the specification in the documentation. If the problem persists, contact PayFacto customer service.
9056 / 9057 / 9058Null / invalid / rejected: original invoice numberOriginalInvoiceNumber is null, exceeds 12 characters, or was rejected because it does not follow the specification.Make sure you are sending the invoice number exactly as it appeared on the original IAP Purchase request.
9062Company number mismatchThe original transaction number exists but is not associated with your company number.Make sure the original IAP Purchase was processed under your company number.
9063Merchant number mismatchThe original transaction number exists but is not associated with your merchant number.Make sure the original IAP Purchase was processed under your merchant number.
9064Original invoice number mismatchThe OriginalInvoiceNumber sent does not match the invoice number recorded on the original IAP Purchase.The original invoice number must be identical to the one used in the original IAP Purchase request.
9066Invalid original transaction statusThe original IAP Purchase status does not allow a correction β€” it was already corrected, batch has closed, or it was declined.Verify the original IAP Purchase was approved and that the batch has not yet closed. If the batch has closed, use IAP Refund (/v1/iapRefund) instead.
9067Original authorization number mismatchThe OriginalAuthorizationNumber is not associated with the submitted original transaction number.Make sure the OriginalAuthorizationNumber matches the value returned in the original IAP Purchase response.
9068Original transaction number not foundNo transaction matching the submitted OriginalTransactionNumber exists in the system.Check your application. Make sure you are sending the correct transaction number from the original IAP Purchase response.
9069Original transaction is not an IAP PurchaseThe original transaction referenced is not an IAP Purchase. IAP Purchase Corrections can only be applied to IAP Purchase transactions.Make sure the original transaction number corresponds to an IAP Purchase. For IAP Pre-Authorization/Completion transactions, use Void (/v1/void) instead.
3666One or more terminals are busyAll of the merchant's terminals are currently processing transactions.Wait and retry. If the problem persists, contact PayFacto customer service.
3667Semi-integrated terminal is busyThe target terminal is currently processing another transaction or a recovery is in progress.Wait 15 seconds and retry. If the problem persists, contact PayFacto customer service.
3668Waiting for a recoveryAn error occurred with the semi-integrated terminal. A recovery must be completed before another operation can be processed.Make sure everything is plugged in correctly. If needed, restart the driver and unplug then replug the terminal power. Wait 35 seconds and retry. If the problem persists, contact PayFacto customer service.
3777Inexistent terminal and/or merchantThe merchant or terminal has not been configured in the Dispatcher module.If the problem persists, contact PayFacto customer service.
9051Time outTransaction processing timed out. Often caused by an inactive Dispatcher module.Retry the transaction. If the problem persists, contact PayFacto customer service.
9049 / 9050Fatal errorA critical error occurred while processing the transaction.Retry the transaction. If the problem persists, contact PayFacto customer service.