Skip to content

Refunds

RefundClient

Bases: BaseAPIClient

Provides a wrapper for paystack Refunds API

The Refunds API allows you to create and manage transaction refunds. https://paystack.com/docs/api/refund/

Source code in src/pypaystack2/sub_clients/sync_clients/refunds.py
class RefundClient(BaseAPIClient):
    """Provides a wrapper for paystack Refunds API

    The Refunds API allows you to create and manage transaction refunds.
    https://paystack.com/docs/api/refund/
    """

    def create(
        self,
        transaction: int | str,
        amount: int | None = None,
        currency: Currency | None = None,
        customer_note: str | None = None,
        merchant_note: str | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Refund] | Response[PaystackDataModel]:
        """Initiate a refund on your integration

        Args:
            transaction: Transaction reference or id
            amount: Amount ( in kobo if currency is NGN, pesewas, if currency is
                GHS, and cents, if currency is ZAR ) to be refunded to the
                customer. Amount is optional(defaults to original
                transaction amount) and cannot be more than the original
                transaction amount
            currency: Any value from the ``Currency`` enum
            customer_note: Customer reason
            merchant_note: Merchant reason
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url("/refund")
        payload = {"transaction": transaction}
        optional_params = [
            ("amount", amount),
            ("currency", currency),
            ("customer_note", customer_note),
            ("merchant_note", merchant_note),
        ]
        payload = add_to_payload(optional_params, payload)
        return self._handle_request(  # type: ignore
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class or Refund,
        )

    def get_refunds(
        self,
        reference: str | None = None,
        currency: Currency | None = None,
        pagination: int = 50,
        page: int = 1,
        start_date: str | None = None,
        end_date: str | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[list[Refund]] | Response[PaystackDataModel]:
        """Fetch refunds available on your integration.

        Args:
            reference: Identifier for transaction to be refunded
            currency: Any value from the ``Currency`` enum
            pagination: Specifies how many records you want to retrieve per page.
                If not specified we use a default value of 50.
            page: Specifies exactly what refund you want to page.
                If not specified we use a default value of 1.
            start_date: A timestamp from which to start listing refund e.g. 2016-09-21
            end_date: A timestamp at which to stop listing refund e.g. 2016-09-21
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url(f"/refund?perPage={pagination}")
        query_params = [
            ("reference", reference),
            ("currency", currency),
            ("page", page),
            ("start_date", start_date),
            ("end_date", end_date),
        ]
        url = append_query_params(query_params, url)
        return self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or Refund,
        )

    def get_refund(
        self,
        reference: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Refund] | Response[PaystackDataModel]:
        """Get details of a refund on your integration.

        Args:
            reference: Identifier for transaction to be refunded
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url(f"/refund/{reference}")
        return self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or Refund,
        )

create(transaction, amount=None, currency=None, customer_note=None, merchant_note=None, alternate_model_class=None)

Initiate a refund on your integration

Parameters:

Name Type Description Default
transaction int | str

Transaction reference or id

required
amount int | None

Amount ( in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR ) to be refunded to the customer. Amount is optional(defaults to original transaction amount) and cannot be more than the original transaction amount

None
currency Currency | None

Any value from the Currency enum

None
customer_note str | None

Customer reason

None
merchant_note str | None

Merchant reason

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[Refund] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/sync_clients/refunds.py
def create(
    self,
    transaction: int | str,
    amount: int | None = None,
    currency: Currency | None = None,
    customer_note: str | None = None,
    merchant_note: str | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Refund] | Response[PaystackDataModel]:
    """Initiate a refund on your integration

    Args:
        transaction: Transaction reference or id
        amount: Amount ( in kobo if currency is NGN, pesewas, if currency is
            GHS, and cents, if currency is ZAR ) to be refunded to the
            customer. Amount is optional(defaults to original
            transaction amount) and cannot be more than the original
            transaction amount
        currency: Any value from the ``Currency`` enum
        customer_note: Customer reason
        merchant_note: Merchant reason
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url("/refund")
    payload = {"transaction": transaction}
    optional_params = [
        ("amount", amount),
        ("currency", currency),
        ("customer_note", customer_note),
        ("merchant_note", merchant_note),
    ]
    payload = add_to_payload(optional_params, payload)
    return self._handle_request(  # type: ignore
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class or Refund,
    )

get_refund(reference, alternate_model_class=None)

Get details of a refund on your integration.

Parameters:

Name Type Description Default
reference str

Identifier for transaction to be refunded

required
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[Refund] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/sync_clients/refunds.py
def get_refund(
    self,
    reference: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Refund] | Response[PaystackDataModel]:
    """Get details of a refund on your integration.

    Args:
        reference: Identifier for transaction to be refunded
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url(f"/refund/{reference}")
    return self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or Refund,
    )

get_refunds(reference=None, currency=None, pagination=50, page=1, start_date=None, end_date=None, alternate_model_class=None)

Fetch refunds available on your integration.

Parameters:

Name Type Description Default
reference str | None

Identifier for transaction to be refunded

None
currency Currency | None

Any value from the Currency enum

None
pagination int

Specifies how many records you want to retrieve per page. If not specified we use a default value of 50.

50
page int

Specifies exactly what refund you want to page. If not specified we use a default value of 1.

1
start_date str | None

A timestamp from which to start listing refund e.g. 2016-09-21

None
end_date str | None

A timestamp at which to stop listing refund e.g. 2016-09-21

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[list[Refund]] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/sync_clients/refunds.py
def get_refunds(
    self,
    reference: str | None = None,
    currency: Currency | None = None,
    pagination: int = 50,
    page: int = 1,
    start_date: str | None = None,
    end_date: str | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[list[Refund]] | Response[PaystackDataModel]:
    """Fetch refunds available on your integration.

    Args:
        reference: Identifier for transaction to be refunded
        currency: Any value from the ``Currency`` enum
        pagination: Specifies how many records you want to retrieve per page.
            If not specified we use a default value of 50.
        page: Specifies exactly what refund you want to page.
            If not specified we use a default value of 1.
        start_date: A timestamp from which to start listing refund e.g. 2016-09-21
        end_date: A timestamp at which to stop listing refund e.g. 2016-09-21
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url(f"/refund?perPage={pagination}")
    query_params = [
        ("reference", reference),
        ("currency", currency),
        ("page", page),
        ("start_date", start_date),
        ("end_date", end_date),
    ]
    url = append_query_params(query_params, url)
    return self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or Refund,
    )

AsyncRefundClient

Bases: BaseAsyncAPIClient

Provides a wrapper for paystack Refunds API

The Refunds API allows you to create and manage transaction refunds. https://paystack.com/docs/api/refund/

Source code in src/pypaystack2/sub_clients/async_clients/refunds.py
class AsyncRefundClient(BaseAsyncAPIClient):
    """Provides a wrapper for paystack Refunds API

    The Refunds API allows you to create and manage transaction refunds.
    https://paystack.com/docs/api/refund/
    """

    async def create(
        self,
        transaction: str,
        amount: int | None = None,
        currency: Currency | None = None,
        customer_note: str | None = None,
        merchant_note: str | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Refund] | Response[PaystackDataModel]:
        """Initiate a refund on your integration

        Args:
            transaction: Transaction reference or id
            amount: Amount ( in kobo if currency is NGN, pesewas, if currency is
                GHS, and cents, if currency is ZAR ) to be refunded to the
                customer. Amount is optional(defaults to original
                transaction amount) and cannot be more than the original
                transaction amount
            currency: Any value from the ``Currency`` enum
            customer_note: Customer reason
            merchant_note: Merchant reason
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url("/refund")
        payload = {"transaction": transaction}
        optional_params = [
            ("amount", amount),
            ("currency", currency),
            ("customer_note", customer_note),
            ("merchant_note", merchant_note),
        ]
        payload = add_to_payload(optional_params, payload)
        return await self._handle_request(  # type: ignore
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class or Refund,
        )

    async def get_refunds(
        self,
        reference: str | None = None,
        currency: Currency | None = None,
        pagination: int = 50,
        page: int = 1,
        start_date: str | None = None,
        end_date: str | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[list[Refund]] | Response[PaystackDataModel]:
        """Fetch refunds available on your integration.

        Args:
            reference: Identifier for transaction to be refunded
            currency: Any value from the ``Currency`` enum
            pagination: Specifies how many records you want to retrieve per page.
                If not specified we use a default value of 50.
            page: Specifies exactly what refund you want to page.
                If not specified we use a default value of 1.
            start_date: A timestamp from which to start listing refund e.g. 2016-09-21
            end_date: A timestamp at which to stop listing refund e.g. 2016-09-21
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url(f"/refund?perPage={pagination}")
        query_params = [
            ("reference", reference),
            ("currency", currency),
            ("page", page),
            ("start_date", start_date),
            ("end_date", end_date),
        ]
        url = append_query_params(query_params, url)
        return await self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or Refund,
        )

    async def get_refund(
        self,
        reference: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Refund] | Response[PaystackDataModel]:
        """Get details of a refund on your integration.

        Args:
            reference: Identifier for transaction to be refunded
            alternate_model_class: A pydantic model class to use instead of the
                default pydantic model used by the library to present the data in
                the `Response.data`. The default behaviour of the library is to
                set  `Response.data` to `None` if it fails to serialize the data
                returned from paystack with the model provided in the library.
                Providing a pydantic model class via this parameter overrides
                the library default model with the model class you provide.
                This can come in handy when the models in the library do not
                accurately represent the data returned, and you prefer working with the
                data as a pydantic model instead of as a dict of the response returned
                by  paystack before it is serialized with pydantic models, The original
                data can be accessed via `Response.raw`.

        Returns:
            A pydantic model containing the response gotten from paystack's server.
        """

        url = self._full_url(f"/refund/{reference}")
        return await self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or Refund,
        )

create(transaction, amount=None, currency=None, customer_note=None, merchant_note=None, alternate_model_class=None) async

Initiate a refund on your integration

Parameters:

Name Type Description Default
transaction str

Transaction reference or id

required
amount int | None

Amount ( in kobo if currency is NGN, pesewas, if currency is GHS, and cents, if currency is ZAR ) to be refunded to the customer. Amount is optional(defaults to original transaction amount) and cannot be more than the original transaction amount

None
currency Currency | None

Any value from the Currency enum

None
customer_note str | None

Customer reason

None
merchant_note str | None

Merchant reason

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[Refund] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/async_clients/refunds.py
async def create(
    self,
    transaction: str,
    amount: int | None = None,
    currency: Currency | None = None,
    customer_note: str | None = None,
    merchant_note: str | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Refund] | Response[PaystackDataModel]:
    """Initiate a refund on your integration

    Args:
        transaction: Transaction reference or id
        amount: Amount ( in kobo if currency is NGN, pesewas, if currency is
            GHS, and cents, if currency is ZAR ) to be refunded to the
            customer. Amount is optional(defaults to original
            transaction amount) and cannot be more than the original
            transaction amount
        currency: Any value from the ``Currency`` enum
        customer_note: Customer reason
        merchant_note: Merchant reason
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url("/refund")
    payload = {"transaction": transaction}
    optional_params = [
        ("amount", amount),
        ("currency", currency),
        ("customer_note", customer_note),
        ("merchant_note", merchant_note),
    ]
    payload = add_to_payload(optional_params, payload)
    return await self._handle_request(  # type: ignore
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class or Refund,
    )

get_refund(reference, alternate_model_class=None) async

Get details of a refund on your integration.

Parameters:

Name Type Description Default
reference str

Identifier for transaction to be refunded

required
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[Refund] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/async_clients/refunds.py
async def get_refund(
    self,
    reference: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Refund] | Response[PaystackDataModel]:
    """Get details of a refund on your integration.

    Args:
        reference: Identifier for transaction to be refunded
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url(f"/refund/{reference}")
    return await self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or Refund,
    )

get_refunds(reference=None, currency=None, pagination=50, page=1, start_date=None, end_date=None, alternate_model_class=None) async

Fetch refunds available on your integration.

Parameters:

Name Type Description Default
reference str | None

Identifier for transaction to be refunded

None
currency Currency | None

Any value from the Currency enum

None
pagination int

Specifies how many records you want to retrieve per page. If not specified we use a default value of 50.

50
page int

Specifies exactly what refund you want to page. If not specified we use a default value of 1.

1
start_date str | None

A timestamp from which to start listing refund e.g. 2016-09-21

None
end_date str | None

A timestamp at which to stop listing refund e.g. 2016-09-21

None
alternate_model_class type[PaystackDataModel] | None

A pydantic model class to use instead of the default pydantic model used by the library to present the data in the Response.data. The default behaviour of the library is to set Response.data to None if it fails to serialize the data returned from paystack with the model provided in the library. Providing a pydantic model class via this parameter overrides the library default model with the model class you provide. This can come in handy when the models in the library do not accurately represent the data returned, and you prefer working with the data as a pydantic model instead of as a dict of the response returned by paystack before it is serialized with pydantic models, The original data can be accessed via Response.raw.

None

Returns:

Type Description
Response[list[Refund]] | Response[PaystackDataModel]

A pydantic model containing the response gotten from paystack's server.

Source code in src/pypaystack2/sub_clients/async_clients/refunds.py
async def get_refunds(
    self,
    reference: str | None = None,
    currency: Currency | None = None,
    pagination: int = 50,
    page: int = 1,
    start_date: str | None = None,
    end_date: str | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[list[Refund]] | Response[PaystackDataModel]:
    """Fetch refunds available on your integration.

    Args:
        reference: Identifier for transaction to be refunded
        currency: Any value from the ``Currency`` enum
        pagination: Specifies how many records you want to retrieve per page.
            If not specified we use a default value of 50.
        page: Specifies exactly what refund you want to page.
            If not specified we use a default value of 1.
        start_date: A timestamp from which to start listing refund e.g. 2016-09-21
        end_date: A timestamp at which to stop listing refund e.g. 2016-09-21
        alternate_model_class: A pydantic model class to use instead of the
            default pydantic model used by the library to present the data in
            the `Response.data`. The default behaviour of the library is to
            set  `Response.data` to `None` if it fails to serialize the data
            returned from paystack with the model provided in the library.
            Providing a pydantic model class via this parameter overrides
            the library default model with the model class you provide.
            This can come in handy when the models in the library do not
            accurately represent the data returned, and you prefer working with the
            data as a pydantic model instead of as a dict of the response returned
            by  paystack before it is serialized with pydantic models, The original
            data can be accessed via `Response.raw`.

    Returns:
        A pydantic model containing the response gotten from paystack's server.
    """

    url = self._full_url(f"/refund?perPage={pagination}")
    query_params = [
        ("reference", reference),
        ("currency", currency),
        ("page", page),
        ("start_date", start_date),
        ("end_date", end_date),
    ]
    url = append_query_params(query_params, url)
    return await self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or Refund,
    )