Skip to content

Duplicate refund Function Definitions Overwriting Each Other #289

@akashagg30

Description

@akashagg30

The refund method is defined twice in the same class in the Razorpay Python SDK. Since Python does not support function overloading, the second definition overwrites the first, leading to the loss of functionality for the refund method that uses the amount parameter.

Here are the conflicting definitions:

def refund(self, payment_id, amount, data={}, **kwargs):  
    """
    Refund Payment for given Id
    Args:
        payment_id : Id for which payment object has to be refunded
        amount : Amount for which the payment has to be refunded
    """
    url = "{}/{}/refund".format(self.base_url, payment_id)
    data['amount'] = amount
    return self.post_url(url, data, **kwargs)

def refund(self, payment_id, data={}, **kwargs):  
    """
    Create a normal refund
    """
    url = "{}/{}/refund".format(self.base_url, payment_id)
    return self.post_url(url, data, **kwargs)

Proposed Solution:
Remove the first definition (refund with the amount parameter) as it is already being overwritten. If both functionalities are required, consider combining the logic into a single function.

Impact:
This issue can lead to confusion and unexpected behavior when performing refunds requiring the amount parameter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions