Getting Refund Details
Function: getRefundDetails()
Purpose
This function retrieves detailed information about a specific refund, including its status, amount, associated credit note, and any custom attributes, enabling accurate tracking and reconciliation.
Parameters
Parameter | Type | Description |
---|---|---|
REFUND_ID | String | The unique identifier of the refund to retrieve details for. |
Use Case
This function can be used for obtaining detailed refund data for auditing purposes, customer inquiries, or financial reconciliation. It provides a clear view of the refund's status, amount, and any related credit note or custom attributes.
def get_refund_details():
SDKConfig.PRINT_REQUEST_DATA = True
SDKConfig.PRINT_RAW_RESPONSE = True
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.refund.details(id="REFUND_ID")
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function getRefundDetails()
{
$id = 'REFUND_ID';
try {
$response = $this->refundService->readDetails($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
The response includes comprehensive details about the refund, such as its status, ID, amount, reference, associated credit note, custom attributes, version, and metadata like creation and last updated timestamps.
RefundDetailsDTO(
refund=RefundDataDTO(
status="STATUS",
id="REF-ID",
amount="AMOUNT",
reference="REFERENCE",
note="NOTE",
paymentMethod="PAYMENT_METHOD",
paymentProcessor="PAYMENT_PROCESSOR",
gatewayResponse="GATEWAY_RESPONSE",
creditNoteId="CRN-ID",
customAttributes=[
{"name": "CUSTOM_ATTRIBUTE_NAME_1", "value": "CUSTOM_ATTRIBUTE_VALUE_1"},
{"name": "CUSTOM_ATTRIBUTE_NAME_2", "value": "CUSTOM_ATTRIBUTE_VALUE_2"}
],
version="VERSION",
createdBy="CREATOR",
createdOn="YYYY-MM-DDTHH:MM:SSZ",
lastUpdatedBy="UPDATER",
lastUpdatedOn="YYYY-MM-DDTHH:MM:SSZ",
uuid="UUID",
date="DATE"
)
)
{
"refund": {
"status": "STATUS",
"id": "REF-ID",
"amount": "AMOUNT",
"reference": "REFERENCE",
"note": "NOTE",
"payment_method": "PAYMENT_METHOD",
"payment_processor": "PAYMENT_PROCESSOR",
"gateway_response": "GATEWAY_RESPONSE",
"credit_note_id": "CRN-ID",
"custom_attributes": [
{
"name": "CUSTOM_ATTRIBUTE_NAME_1",
"value": "CUSTOM_ATTRIBUTE_VALUE_1"
},
{
"name": "CUSTOM_ATTRIBUTE_NAME_2",
"value": "CUSTOM_ATTRIBUTE_VALUE_2"
}
],
"version": "VERSION",
"created_by": "CREATOR",
"created_on": "YYYY-MM-DDTHH:MM:SSZ",
"last_updated_by": "UPDATER",
"last_updated_on": "YYYY-MM-DDTHH:MM:SSZ",
"uuid": "UUID"
}
}
Getting Refund List of a Specific Account
Function: getAccountRefundList()
Purpose
This function retrieves a paginated list of refunds associated with a specific account, providing details such as refund status, amount, payment method, and custom attributes for audit or reconciliation purposes.
Parameters
Parameter | Type | Description |
---|---|---|
ACCOUNT_ID | string | The unique identifier of the account for which refunds need to be retrieved. |
Use Case
This function can be used to fetch a detailed refund history for an account, aiding in financial audits, reconciliation, and customer support inquiries. The pagination metadata helps in handling large datasets efficiently.
def get_account_refund_list():
SDKConfig.PRINT_REQUEST_DATA = True
SDKConfig.PRINT_RAW_RESPONSE = True
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.refund.account_refund_list(id="ACCOUNT_ID")
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function getAccountRefundList()
{
$accountId = 'ACCOUNT_ID';
try {
$response = $this->refundService->readAccountRefunds($accountId);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
The response contains a list of refunds associated with the specified account, along with metadata such as pagination details, refund status, and other related attributes.
AccountRefundListDTO(
account=RefundListDTO(
refunds=[
RefundDataDTO(
status="STATUS",
id="REF-ID",
amount="AMOUNT",
reference="REFERENCE",
note="NOTE",
paymentMethod="PAYMENT_METHOD",
paymentProcessor="PAYMENT_PROCESSOR",
gatewayResponse="GATEWAY_RESPONSE",
creditNoteId="CRN-ID",
customAttributes=[
{"name": "CUSTOM_ATTRIBUTE_NAME_1", "value": "CUSTOM_ATTRIBUTE_VALUE_1"},
{"name": "CUSTOM_ATTRIBUTE_NAME_2", "value": "CUSTOM_ATTRIBUTE_VALUE_2"}
],
version="VERSION",
createdBy="CREATOR",
createdOn="YYYY-MM-DDTHH:MM:SSZ",
lastUpdatedBy="UPDATER",
lastUpdatedOn="YYYY-MM-DDTHH:MM:SSZ",
uuid="UUID",
date=None
)
],
pagination=PaginationDTO(
records=RECORD_COUNT,
limit=LIMIT,
offset=OFFSET,
previousPage="PREVIOUS_PAGE",
nextPage="NEXT_PAGE"
)
)
)
{
"account": {
"refunds": [
{
"status": "STATUS",
"id": "REF-ID",
"amount": "AMOUNT",
"reference": "REFERENCE",
"note": "NOTE",
"payment_method": "PAYMENT_METHOD",
"payment_processor": "PAYMENT_PROCESSOR",
"gateway_response": "GATEWAY_RESPONSE",
"credit_note_id": "CREDIT_NOTE_ID",
"custom_attributes": [
{
"name": "CUSTOM_ATTRIBUTE_NAME_1",
"value": "CUSTOM_ATTRIBUTE_VALUE_1"
},
{
"name": "CUSTOM_ATTRIBUTE_NAME_2",
"value": "CUSTOM_ATTRIBUTE_VALUE_2"
}
],
"version": "VERSION",
"created_by": "CREATED_BY",
"created_on": "YYYY-MM-DDTHH:MM:SSZ",
"last_updated_by": "LAST_UPDATED_BY",
"last_updated_on": "YYYY-MM-DDTHH:MM:SSZ",
"uuid": "UUID"
}
],
"pagination": {
"records": "RECORD_COUNT",
"limit": "LIMIT",
"offset": "OFFSET",
"previous_page": "PREVIOUS_PAGE",
"next_page": "NEXT_PAGE"
}
}
}
Creating a Refund
Function: createRefund()
Purpose
This function creates a refund associated with a specified credit note. It includes key refund details like amount, date, payment method, and custom attributes, allowing for precise financial tracking and reconciliation.
Parameters
Parameter | Type | Description |
---|---|---|
CREDIT_NOTE_ID | String | The unique identifier of the credit note for which the refund is being created. |
STATUS | String | The current status of the refund . |
AMOUNT | String | The monetary amount to be refunded. |
DATE | String | The date of the refund. |
REFERENCE | String | A unique reference or identifier for the refund. |
NOTE | String | Optional text providing additional context or information about the refund. |
PAYMENT_METHOD | String | The method of payment used for the refund. |
PAYMENT_PROCESSOR | String | The entity or system processing the refund. |
ATTRIBUTE_NAME | String | The name of the custom attribute. |
ATTRIBUTE_VALUE | String | The value associated with the custom attribute. |
Use Case
This function can be used to initiate refunds tied to specific credit notes. It helps businesses manage refund operations effectively, with traceability via custom attributes and detailed metadata.
def create_refund():
SDKConfig.PRINT_REQUEST_DATA = True
SDKConfig.PRINT_RAW_RESPONSE = True
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
request_data = RefundDetailsDTO(refund=RefundDataDTO(
status="STATUS",
id="REFUND_ID",
date="DATE",
amount="AMOUNT",
reference="REFERENCE",
note="NOTE",
paymentMethod="PAYMENT_METHOD",
paymentProcessor="PAYMENT_PROCESSOR",
))
response = exsited_sdk.refund.create(cn_id='CREDIT_NOTE_ID', request_data=request_data)
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function createRefund()
{
$creditNotesId = 'CREDIT_NOTE_ID';
$params = [
"refund" => [
"id"=>"REFUND_ID",
"date" => "DATE",
"amount" => "AMOUNT",
"reference" => "REFERENCE",
"note" => "NOTE",
"payment_method" => "PAYMENT_METHOD",
"payment_processor" => "PAYMENT_PROCESSOR",
"custom_attributes" => [
[
"name" => "ATTRIBUTE_NAME",
"value" => "ATTRIBUTE_VALUE"
]
]
]
];
try {
$response = $this->refundService->create($creditNotesId,$params);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
The response provides details of the created refund, including its status, associated credit note ID, and metadata such as custom attributes, version, and creation details.
Deleting a Refund
Function: deleteRefund()
Purpose
This function removes a specific refund entry identified by its unique ID. It is used to delete outdated, invalid, or test refund records to ensure the system maintains accurate and up-to-date financial data.
Parameters
Parameter | Type | Description |
---|---|---|
REFUND_ID | String | Unique identifier of the refund to be delete. |
Use Case
This function can be used when a refund entry needs to be permanently removed, such as invalid test data or refunds mistakenly recorded. It is particularly helpful for financial record management, ensuring the database only contains valid and necessary refunds.
def delete_refund():
SDKConfig.PRINT_REQUEST_DATA = False
SDKConfig.PRINT_RAW_RESPONSE = False
exsited_sdk: ExsitedSDK = ExsitedSDK().init_sdk(request_token_dto=CommonData.get_request_token_dto())
try:
response = exsited_sdk.refund.delete(id="REFUND_ID")
print(response)
except ABException as ab:
print(ab)
print(ab.get_errors())
print(ab.raw_response)
public function deleteRefund()
{
$id = 'REFUND_ID';
try {
$response = $this->refundService->delete($id);
echo '<pre>' . json_encode($response, JSON_PRETTY_PRINT) . '</pre>';
} catch (Exception $e) {
echo 'Error: ' . $e->getMessage();
}
}
Response
If the refund is deleted successfully, the response confirms the operation with a success message. If the refund does not exist or cannot be deleted, an error message with details and an HTTP status code is provided.
{
"success": True,
"status_code": 204
}
null