refundCgInvoice

Overview

The refundCgInvoice command processes refunds for invoices generated through the EZcount system. This command creates a credit note that cancels or partially refunds the original invoice while maintaining proper tax compliance and audit trails.

Use cases

Use refundCgInvoice when you need to:

  • Process full refunds for customer returns or cancellations

  • Handle partial refunds for damaged or incomplete orders

  • Generate credit notes for tax compliance purposes

  • Maintain proper documentation for financial reconciliation

  • Reverse invoice charges while preserving audit trails

Request structure

For general API request structure and authentication, see API Request & Response General Structure.

The refundCgInvoice command uses the following endpoint:

POST https://your-hyp-environment-url/xpo/Relay

HTTP request format

The request must be sent as a POST request with application/x-www-form-urlencoded content type, containing three required body parameters:

Parameter
Type
Description

user

string

Your merchant username for API authentication

password

string

Your merchant password for API authentication

int_in

string

XML payload containing the command and parameters (see structure below)

XML request structure

Required parameters

invoiceAtranId - string

The unique invoice transaction ID returned from the original addCgInvoice call. This is the identifier for the invoice to be refunded.

Example: 119443246

createInvoice - string

Indicates whether to create a credit note for the refund. Set to `1` to generate the credit document.

Valid Values: 1 (create credit note)

Response structure

Success response

Key Response Fields:

  • result: 000 indicates successful API call

  • invoiceCreationCode: 000 indicates successful credit note creation

  • invoiceResponseCode: 100 indicates proper invoice request

  • invoiceDocNumber: The generated credit note number

  • invoiceDocUrl: Direct link to view/download the credit note

Error responses

Example 1: No invoice found for source transaction

Example 2: Transaction type mismatch

Code examples

Error codes

All invoice-related error codes are returned in the invoiceResponseCode and invoiceResponseName tags.

CG Gateway invoice error codes

Code
Description
Solution

668

Cannot Create Invoice

Check invoice parameters and retry

669

Currency not supported for invoice creation

Verify currency is supported for invoicing

670

Invoice Validation Failed

Check that invoice values are valid

671

Invoice not found

Verify the invoice identifier is correct

Invoice vendor response codes

Code
Description
Solution

100

Success

Invoice operation completed successfully

101

UsernameInvalid

Check username for invoice system

102

CompanyCodeAlreadyExists

Company code already exists in system

103

CompanyCodeDoesNotExist

Verify company code exists

104

CompanyCodeInvalidFormat

Company code must be numeric

105

DocumentInvalidSubject

Subject line is invalid

106

DocumentDoesNotExist

Document number was not found

107

SendEmailAborted

E-mailing document failed

108

EmailInvalid

Check email format

109

CultureInvalid

Invalid culture setting

110

KeyInvalid

Invalid key provided

111

AccountExpired

Account has expired

112

DocumentInvalidItemNumber

Multiple items in wrong format

113

DocumentInvalidQuantity

Quantity must be numeric

114

DocumentInvalidPrice

Price must be numeric

116

DocumentDoesNotExistForSpecifiedCompany

Document doesn't exist for company

117

CurrencyConversionServiceNotAvailable

Currency service unavailable

118

InvalidItemCode

Unacceptable item code

119

CurrencyInWrongFormat

Currency must be integer

120

DocumentMissingItem

Quantity, price, description and code must match

121

DocumentInvalidDateFormatDDMMYY

Date format must be DDMMYY

122

PaymentAmountDoesntMatchInvoice

Total receivables must be positive

123

DocumentAmountInvalid

Amount must be double

124

CashInvalidAmount

Cash amount must be double

125

CheckInvalidAmount

Check amount must be double

126

CCInvalidAmount

Credit card amount must be double

127

TransInvalidAmount

Transaction amount must be double

128

CheckInvalidDateFormatDDMMYY

Check date format must be DDMMYY

129

CCInvalidDateFormatDDMMYY

CC date format must be DDMMYY

130

TransInvalidDateFormatDDMMYY

Transaction date format must be DDMMYY

131

PaymentTotalMustBeEqualToInvoiceTotal

Payment must equal invoice total

132

TaxRateInTheDocsIsNotEqual

Tax rate mismatch in documents

133

ClientCompanyNameAlreadyExists

Company name already exists

134

ClientTicketAlreadyExists

Client ticket already exists

Best practices

  1. Use invoiceAtranId - This is the most reliable identifier for refund processing

  2. Always create credit notes - Set createInvoice to 1 to generate proper documentation

  3. Support partial refunds - Allow customers to refund partial amounts for damaged or incomplete orders

  4. Validate refund amounts - Ensure refund amounts don't exceed the original invoice total

  5. Store credit note information - Keep track of credit note numbers and URLs for customer service

  6. Handle tax implications - Credit notes properly handle VAT and tax reversals for compliance

Last updated

Was this helpful?