» Refund Module SDK Documentation
» Refund Module SDK Documentation

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

ParameterTypeDescription
REFUND_IDStringThe 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)

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"
    )
)

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

ParameterTypeDescription
ACCOUNT_IDstringThe 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)

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"
        )
    )
)

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

ParameterTypeDescription
CREDIT_NOTE_IDStringThe unique identifier of the credit note for which the refund is being created.
STATUSStringThe current status of the refund .
AMOUNTStringThe monetary amount to be refunded.
DATEStringThe date of the refund.
REFERENCEString A unique reference or identifier for the refund.
NOTEStringOptional text providing additional context or information about the refund.
PAYMENT_METHODStringThe method of payment used for the refund.
PAYMENT_PROCESSORStringThe entity or system processing the refund.
ATTRIBUTE_NAMEStringThe name of the custom attribute.
ATTRIBUTE_VALUEStringThe 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)

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

ParameterTypeDescription
REFUND_IDStringUnique 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)

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
}