Refund

Request to refund previously captured funds. A refund transaction triggers the movement of funds from the biller's account to the cardholders account.

URL https://ap-gateway.mastercard.com/api/rest/version/6/merchant/{merchantId}/order/{orderid}/transaction/{transactionid}
HTTP Method PUT
Authentication This operation requires authentication via one of the following methods:
  • Certificate authentication.
  • Basic HTTP authentication as described at w3.org. To authenticate to the API, leave the userid portion (to the left of the colon) blank and fill the password section with the API password provided to you.

Request Parameters

apiOperation  String =REFUND FIXED

Existence
FIXED
Fixed value
REFUND
Validation Rules
Any sequence of zero or more unicode characters.
XSD type
string

transaction   = COMPULSORY

Fixed value

transaction.amount  Decimal = COMPULSORY

Expressed as a decimal number in the units of the currency. For example 12.34 in USD is the amount 12 dollars and 34 cents.
Existence
COMPULSORY
Fixed value
Validation Rules
Data is a string that consists of the characters 0-9 and '.' and represents a valid decimal number.
JSON type
String
minimum length
1
maximum length
14

transaction.currency  Upper case alphabetic text = COMPULSORY

Existence
COMPULSORY
Fixed value
Validation Rules
Data must consist of the characters A-Z
JSON type
String
minimum length
3
maximum length
3

apiOperation  String =REFUND FIXED

Existence
FIXED
Fixed value
REFUND
Validation Rules
Any sequence of zero or more unicode characters.
XSD type
string

cardDetails   = OPTIONAL

Precedence rules will be applied in that order, i.e. Card Details will override From Session details which will override Card Token details. Each of these may represent partial details, however the combination must result in a full and complete set of card details. See Using Multiple Sources of Card Details for examples.
Fixed value

cardDetails.card   = OPTIONAL

Details as shown on the card.
Fixed value

cardDetails.card.expiry   = OPTIONAL

Expiry date, as shown on the card.
Fixed value

cardDetails.card.expiry.month  Digits = COMPULSORY

Months are numbered January=1, through to December=12.
Existence
COMPULSORY
Fixed value
Validation Rules
Data is a number between 1 and 12 represented as a string.
JSON type
String

cardDetails.card.expiry.year  Digits = COMPULSORY

The Common Era year is 2000 plus this value.
Existence
COMPULSORY
Fixed value
Validation Rules
Data is a string that consists of the characters 0-9.
JSON type
String
minimum length
2
maximum length
2

cardDetails.card.number  Digits = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
Data is a string that consists of the characters 0-9.
JSON type
String
minimum length
9
maximum length
19

cardDetails.card.securityCode  Digits = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
Data is a string that consists of the characters 0-9.
JSON type
String
minimum length
3
maximum length
4

cardDetails.card.sequenceNumber  Digits = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
Data is a number between 0 and 999 represented as a string.
JSON type
String

cardDetails.card.track1  String = OPTIONAL

Start and end sentinels as well as the LRC must be included.
Existence
OPTIONAL
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
2
maximum length
79

cardDetails.card.track2  String = OPTIONAL

Start and end sentinels as well as the LRC must be included. The contents of this field must match the PAN and expiry fields included in the Transaction Request.
Existence
OPTIONAL
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
2
maximum length
40

cardDetails.cardToken  Alphanumeric = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
Data may consist of the characters 0-9, a-z, A-Z
JSON type
String
minimum length
1
maximum length
40

cardDetails.session  ASCII Text = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
Data consists of ASCII characters
JSON type
String
minimum length
31
maximum length
35

correlationId  String = OPTIONAL

The value provided is not validated, does not persist in the gateway, and is returned as provided in the response to the request.
Existence
OPTIONAL
Fixed value
Validation Rules
Data can consist of any characters
XSD type
string
minimum length
1
maximum length
100

order   = OPTIONAL

Fixed value

order.reference  String = OPTIONAL

For example, a shopping cart number, an order number, or an invoice number.
Existence
OPTIONAL
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
40

posTerminal   = OPTIONAL

Fixed value

posTerminal.entryMode  Digits = OPTIONAL

The first two digits indicate the PAN entry mode and the last digit indicates the PIN entry mode. For example, 011 may indicate manual PAN entry (01) with PIN entry on the terminal (1).

PAN ENTRY Mode
01 - Manual Entry
02 - Magnetic stripe read, but full unaltered contents not provided
04 - OCR/MICR coding read
05 - PAN auto entry via chip
07 - Auto-entry via contactless magnetic chip
79 - Chip card at chip-capable terminal was unable to process transaction using data on the chip or magnetic stripe on the card-therefore, PAN entry via manual entry
80 - Chip card at chip-capable terminal was unable to process transaction using data on the chip therefore; the terminal defaulted to the magnetic stripe read for the PAN. This is referred to as fallback.
90 - Magnetic stripe read and full, unaltered contents provided
91 - Auto-entry via contactless magnetic strip

PIN Entry Mode
0 - Unspecified or unknown
1 - Terminal has PIN entry capability
2 - Terminal does not have PIN entry capability (default)
8 - Terminal has PIN entry capability but PIN pad is not currently operative
Existence
OPTIONAL
Fixed value
Validation Rules
Data is a string that consists of the characters 0-9.
JSON type
String
minimum length
3
maximum length
3

transaction   = COMPULSORY

Fixed value

transaction.acquirer   = OPTIONAL

Additional information to be passed to acquirer.
Fixed value

transaction.acquirer.customData  String = OPTIONAL

This field must not contain sensitive data.
Existence
OPTIONAL
Fixed value
Validation Rules
Data can consist of any characters, but sensitive data will be rejected
JSON type
String
minimum length
1
maximum length
2048

transaction.amount  Decimal = COMPULSORY

Expressed as a decimal number in the units of the currency. For example 12.34 in USD is the amount 12 dollars and 34 cents.
Existence
COMPULSORY
Fixed value
Validation Rules
Data is a string that consists of the characters 0-9 and '.' and represents a valid decimal number.
JSON type
String
minimum length
1
maximum length
14

transaction.currency  Upper case alphabetic text = COMPULSORY

Existence
COMPULSORY
Fixed value
Validation Rules
Data must consist of the characters A-Z
JSON type
String
minimum length
3
maximum length
3

transaction.reference  String = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
40

transaction.source  Enumeration = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
JSON type
String
Value must be a member of the following list. The values are case sensitive.
CALL_CENTRE
Transaction conducted via a call centre.
CARD_PRESENT
Transaction where the card is presented to the merchant.
INTERNET
Transaction conducted over the Internet.
MAIL_ORDER
Transaction received by mail.
MOTO
Transaction received by mail or telephone.
TELEPHONE_ORDER
Transaction received by telephone.
VOICE_RESPONSE
Transaction conducted by a voice/DTMF recognition system.

transaction.tax   = OPTIONAL

Fixed value

transaction.tax.local   = OPTIONAL

Fixed value

transaction.tax.local.amount  Decimal = OPTIONAL

Expressed as a decimal number in the units of the currency. For example 12.34 in USD is the amount 12 dollars and 34 cents.
Existence
OPTIONAL
Fixed value
Validation Rules
Data is a string that consists of the characters 0-9 and '.' and represents a valid decimal number.
JSON type
String
minimum length
1
maximum length
14

transaction.tax.local.exempt  Boolean = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
JSON boolean values 'true' or 'false'.
JSON type
String

transaction.tax.local.reference  String = OPTIONAL

Existence
OPTIONAL
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
20

{merchantId}  Alphanumeric + additional characters COMPULSORY

Existence
COMPULSORY
Validation Rules
Data may consist of the characters 0-9, a-z, A-Z, '-', '_'
XSD type
string
minimum length
1
maximum length
40

{orderid}  Integer COMPULSORY

Existence
COMPULSORY
Validation Rules
A number comprising the digits 0-9, having at least one digit. (For a complete description, see http://www.w3.org/TR/xmlschema-2/#nonNegativeInteger.)
XSD type
nonNegativeInteger
minimum value
0
maximum value
9999999999999999

{transactionid}  String COMPULSORY

Existence
COMPULSORY
Validation Rules
Data can consist of any characters
XSD type
string
minimum length
1
maximum length
40

Response Parameters

merchant  Alphanumeric + additional characters = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
Data may consist of the characters 0-9, a-z, A-Z, '-', '_'
JSON type
String
minimum length
1
maximum length
40

order   = Always Provided

Information about the order
Fixed value

order.id  Integer = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
JSON number data type, restricted to being positive or zero. In addition, the represented number may have no fractional part.
JSON type
Number
minimum value
0
maximum value
9999999999999999

order.totalAuthorizedAmount  Decimal = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
Data is a decimal number.
JSON type
Number
maximum value
1000000000000
minimum value
0
maximum post-decimal digits
3

order.totalCapturedAmount  Decimal = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
Data is a decimal number.
JSON type
Number
maximum value
1000000000000
minimum value
0
maximum post-decimal digits
3

order.totalRefundedAmount  Decimal = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
Data is a decimal number.
JSON type
Number
maximum value
1000000000000
minimum value
0
maximum post-decimal digits
3

response   = Always Provided

Fixed value

response.gatewayCode  Enumeration = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
JSON type
String
Value must be a member of the following list. The values are case sensitive.
ABORTED
Transaction aborted by payer
ACQUIRER_SYSTEM_ERROR
Acquirer system error occurred processing the transaction
APPROVED
Transaction Approved
APPROVED_PENDING_SETTLEMENT
Transaction Approved - pending batch settlement
AUTHENTICATION_FAILED
Payer authentication failed
BLOCKED
Transaction blocked due to Risk or 3D Secure blocking rules
CANCELLED
Transaction cancelled by payer
DECLINED
The requested operation was not successful. For example, a payment was declined by issuer or payer authentication was not able to be successfully completed.
DECLINED_AVS
Transaction declined due to address verification
DECLINED_AVS_CSC
Transaction declined due to address verification and card security code
DECLINED_CSC
Transaction declined due to card security code
DECLINED_DO_NOT_CONTACT
Transaction declined - do not contact issuer
DECLINED_PAYMENT_PLAN
Transaction declined due to payment plan
DEFERRED_TRANSACTION_RECEIVED
Deferred transaction received and awaiting processing
DUPLICATE_BATCH
Transaction declined due to duplicate batch
EXCEEDED_RETRY_LIMIT
Transaction retry limit exceeded
EXPIRED_CARD
Transaction declined due to expired card
INSUFFICIENT_FUNDS
Transaction declined due to insufficient funds
INVALID_CSC
Invalid card security code
LOCK_FAILURE
Order locked - another transaction is in progress for this order
NOT_ENROLLED_3D_SECURE
Card holder is not enrolled in 3D Secure
NOT_SUPPORTED
Transaction type not supported
PENDING
Transaction is pending
REFERRED
Transaction declined - refer to issuer
SYSTEM_ERROR
Internal system error occurred processing the transaction
TIMED_OUT
The gateway has timed out the request to the acquirer because it did not receive a response. You can handle the transaction as a declined transaction. Where possible the gateway will attempt to reverse the transaction.
UNKNOWN
The transaction has been submitted to the acquirer but the gateway was not able to find out about the success or otherwise of the payment. If the gateway subsequently finds out about the success of the payment it will update the response code.
UNSPECIFIED_FAILURE
Transaction could not be processed

result  Enumeration = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
JSON type
String
Value must be a member of the following list. The values are case sensitive.
FAILURE
The operation was declined or rejected by the gateway, acquirer or issuer
PENDING
The operation is currently in progress or pending processing
SUCCESS
The operation was successfully processed
UNKNOWN
The result of the operation is unknown

transaction   = Always Provided

Fixed value

transaction.acquirer   = Always Provided

Fixed value

transaction.acquirer.id  String = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
40

transaction.amount  Decimal = Always Provided

Expressed as a decimal number in the units of the currency. For example 12.34 in USD is the amount 12 dollars and 34 cents.
Existence
Always Provided
Fixed value
Validation Rules
Data is a decimal number.
JSON type
Number
maximum value
1000000000000
minimum value
0
maximum post-decimal digits
3

transaction.currency  Upper case alphabetic text = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
Data must consist of the characters A-Z
JSON type
String
minimum length
3
maximum length
3

transaction.id  String = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
40

transaction.type  Enumeration = Always Provided

Existence
Always Provided
Fixed value
Validation Rules
JSON type
String
Value must be a member of the following list. The values are case sensitive.
AUTHORIZATION
Authorization
CAPTURE
Capture
PAYMENT
Payment (Purchase)
REFUND
Refund
VOID_AUTHORIZATION
Void Authorization
VOID_CAPTURE
Void Capture
VOID_PAYMENT
Void Payment
VOID_REFUND
Void Refund

Response parameters are the same as Transaction: Retrieve Transaction

error   = CONDITIONAL

Information on possible error conditions that may occur while processing an operation using the API.
Fixed value

error.cause  Enumeration = CONDITIONAL

For example, errors may occur due to invalid requests or internal system failures.
Fixed value
Validation Rules
JSON type
String
Value must be a member of the following list. The values are case sensitive.
INVALID_REQUEST
The request was rejected because it did not conform to the API protocol.
REQUEST_REJECTED
The request was rejected due to security reasons such as firewall rules, expired certificate, etc.
SERVER_BUSY
The server did not have enough resources to process the request at the moment.
SERVER_FAILED
There was an internal system failure.

error.explanation  String = CONDITIONAL

This field is returned only if the cause is INVALID_REQUEST or SERVER_BUSY.
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
1000

error.field  String = CONDITIONAL

This field is returned only if the cause is INVALID_REQUEST and a field level validation error was encountered.
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
100

error.supportCode  String = CONDITIONAL

This field is returned only if the cause is SERVER_FAILED or REQUEST_REJECTED.
Fixed value
Validation Rules
Data can consist of any characters
JSON type
String
minimum length
1
maximum length
100

error.validationType  Enumeration = CONDITIONAL

This field is returned only if the cause is INVALID_REQUEST and a field level validation error was encountered.
Fixed value
Validation Rules
JSON type
String
Value must be a member of the following list. The values are case sensitive.
INVALID
The request contained a field with a value that did not pass validation.
MISSING
The request was missing a mandatory field.
UNSUPPORTED
The request contained a field that is unsupported.

result  Enumeration = CONDITIONAL

Fixed value
Validation Rules
JSON type
String
Value must be a member of the following list. The values are case sensitive.
ERROR
The operation resulted in an error and hence cannot be processed.

Copyright © 2023 MasterCard