Skip to content

Payment Drafts Asynchronous Endpoints

This Payment Drafts endpoint provides asynchronous methods to interact with the payment drafts of the authenticated user.

Example usage of the Payment Drafts endpoint object:

import asyncio
from pyrevolut.client import AsyncClient

CREDS_JSON_LOC = "path/to/creds.json"

client = AsyncClient(
    creds_loc=CREDS_JSON_LOC,
    sandbox=True,
)

async def run():
    async with client:
        drafts = await client.PaymentDrafts.get_all_payment_drafts()
        print(drafts)

asyncio.run(run())

EndpointPaymentDraftsAsync

Bases: BaseEndpointAsync

The async Payment Drafts API

Create a payment draft to request an approval for a payment from a business owner or admin before the payment is executed. The business owner or admin must manually approve it in the Revolut Business User Interface.

You can also retrieve one or all payment drafts, and delete a payment draft.

Source code in pyrevolut/api/payment_drafts/endpoint/asynchronous.py
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
class EndpointPaymentDraftsAsync(BaseEndpointAsync):
    """The async Payment Drafts API

    Create a payment draft to request an approval for a payment from a
    business owner or admin before the payment is executed.
    The business owner or admin must manually approve it in the
    Revolut Business User Interface.

    You can also retrieve one or all payment drafts, and delete a payment draft.
    """

    async def get_all_payment_drafts(
        self,
        **kwargs,
    ) -> dict | RetrieveAllPaymentDrafts.Response:
        """
        Get a list of all the payment drafts that aren't processed.

        Parameters
        ----------
        None

        Returns
        -------
        dict | RetrieveAllPaymentDrafts.Response
            A dict with the information about the payment drafts.
        """
        endpoint = RetrieveAllPaymentDrafts
        path = endpoint.ROUTE
        params = endpoint.Params()

        return await self.client.get(
            path=path,
            response_model=endpoint.Response,
            params=params,
            **kwargs,
        )

    async def get_payment_draft(
        self,
        payment_draft_id: UUID,
        **kwargs,
    ) -> dict | RetrievePaymentDraft.Response:
        """
        Get the information about a specific payment draft by ID.

        Parameters
        ----------
        payment_draft_id : UUID
            The ID of the payment draft.

        Returns
        -------
        dict | RetrievePaymentDraft.Response
            A dict with the information about the payment draft.
        """
        endpoint = RetrievePaymentDraft
        path = endpoint.ROUTE.format(payment_draft_id=payment_draft_id)
        params = endpoint.Params()

        return await self.client.get(
            path=path,
            response_model=endpoint.Response,
            params=params,
            **kwargs,
        )

    async def create_payment_draft(
        self,
        account_id: UUID,
        counterparty_ids: list[UUID] = [],
        counterparty_account_ids: list[UUID | None] = [],
        counterparty_card_ids: list[UUID | None] = [],
        amounts: list[float] = [],
        currencies: list[str] = [],
        references: list[str] = [],
        title: str | None = None,
        schedule_for: date | Date | str | None = None,
        **kwargs,
    ) -> dict | CreatePaymentDraft.Response:
        """
        Create a payment draft.

        Parameters
        ----------
        account_id : UUID
            The ID of the account to pay from.
        counterparty_ids : list[UUID]
            The IDs of the counterparty accounts. Each ID corresponds to a payment.
        counterparty_account_ids : list[UUID | None]
            The IDs of the counterparty accounts. Each ID corresponds to a payment.
            If the counterparty has multiple payment methods available, use it to
            specify the account to which you want to send the money. Otherwise, use None.
        counterparty_card_ids : list[UUID | None]
            The IDs of the counterparty cards. Each ID corresponds to a payment.
            If the counterparty has multiple payment methods available, use it to
            specify the card to which you want to send the money. Otherwise, use None.
        amounts : list[float]
            The amounts of the payments.
        currencies : list[str]
            The ISO 4217 currency codes in upper case.
        references : list[str]
            The references for the payments.
        title : str, optional
            The title of the payment draft.
        schedule_for : date | Date | str, optional
            The scheduled date of the payment draft in ISO 8601 format.

        Returns
        -------
        dict | CreatePaymentDraft.Response
            A dict with the information about the payment draft created.
        """
        assert (
            len(counterparty_ids)
            == len(counterparty_account_ids)
            == len(counterparty_card_ids)
            == len(amounts)
            == len(currencies)
            == len(references)
        ), (
            "The number of elements in the lists must be equal. "
            f"Got {len(counterparty_ids)} counterparty_ids, "
            f"{len(counterparty_account_ids)} counterparty_account_ids, "
            f"{len(counterparty_card_ids)} counterparty_card_ids, "
            f"{len(amounts)} amounts, "
            f"{len(currencies)} currencies, "
            f"and {len(references)} references."
        )

        endpoint = CreatePaymentDraft
        path = endpoint.ROUTE
        body = endpoint.Body(
            title=title,
            schedule_for=schedule_for,
            payments=[
                endpoint.Body.ModelPayment(
                    account_id=account_id,
                    receiver=endpoint.Body.ModelPayment.ModelReceiver(
                        counterparty_id=counterparty_id,
                        account_id=counterparty_account_id,
                        card_id=counterparty_card_id,
                    ),
                    amount=amount,
                    currency=currency,
                    reference=reference,
                )
                for counterparty_id, counterparty_account_id, counterparty_card_id, amount, currency, reference in zip(
                    counterparty_ids,
                    counterparty_account_ids,
                    counterparty_card_ids,
                    amounts,
                    currencies,
                    references,
                )
            ],
        )

        return await self.client.post(
            path=path,
            response_model=endpoint.Response,
            body=body,
            **kwargs,
        )

    async def delete_payment_draft(
        self,
        payment_draft_id: UUID,
        **kwargs,
    ) -> dict | DeletePaymentDraft.Response:
        """
        Delete a payment draft with the given ID.
        You can delete a payment draft only if it isn't processed.

        Parameters
        ----------
        payment_draft_id : UUID
            The ID of the payment draft.

        Returns
        -------
        dict | DeletePaymentDraft.Response
            A dict with the information about the payment draft deleted.
        """
        endpoint = DeletePaymentDraft
        path = endpoint.ROUTE.format(payment_draft_id=payment_draft_id)
        params = endpoint.Params()

        return await self.client.delete(
            path=path,
            response_model=endpoint.Response,
            params=params,
            **kwargs,
        )

create_payment_draft(account_id, counterparty_ids=[], counterparty_account_ids=[], counterparty_card_ids=[], amounts=[], currencies=[], references=[], title=None, schedule_for=None, **kwargs) async

Create a payment draft.

Parameters:

Name Type Description Default
account_id UUID

The ID of the account to pay from.

required
counterparty_ids list[UUID]

The IDs of the counterparty accounts. Each ID corresponds to a payment.

[]
counterparty_account_ids list[UUID | None]

The IDs of the counterparty accounts. Each ID corresponds to a payment. If the counterparty has multiple payment methods available, use it to specify the account to which you want to send the money. Otherwise, use None.

[]
counterparty_card_ids list[UUID | None]

The IDs of the counterparty cards. Each ID corresponds to a payment. If the counterparty has multiple payment methods available, use it to specify the card to which you want to send the money. Otherwise, use None.

[]
amounts list[float]

The amounts of the payments.

[]
currencies list[str]

The ISO 4217 currency codes in upper case.

[]
references list[str]

The references for the payments.

[]
title str

The title of the payment draft.

None
schedule_for date | Date | str

The scheduled date of the payment draft in ISO 8601 format.

None

Returns:

Type Description
dict | Response

A dict with the information about the payment draft created.

Source code in pyrevolut/api/payment_drafts/endpoint/asynchronous.py
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
async def create_payment_draft(
    self,
    account_id: UUID,
    counterparty_ids: list[UUID] = [],
    counterparty_account_ids: list[UUID | None] = [],
    counterparty_card_ids: list[UUID | None] = [],
    amounts: list[float] = [],
    currencies: list[str] = [],
    references: list[str] = [],
    title: str | None = None,
    schedule_for: date | Date | str | None = None,
    **kwargs,
) -> dict | CreatePaymentDraft.Response:
    """
    Create a payment draft.

    Parameters
    ----------
    account_id : UUID
        The ID of the account to pay from.
    counterparty_ids : list[UUID]
        The IDs of the counterparty accounts. Each ID corresponds to a payment.
    counterparty_account_ids : list[UUID | None]
        The IDs of the counterparty accounts. Each ID corresponds to a payment.
        If the counterparty has multiple payment methods available, use it to
        specify the account to which you want to send the money. Otherwise, use None.
    counterparty_card_ids : list[UUID | None]
        The IDs of the counterparty cards. Each ID corresponds to a payment.
        If the counterparty has multiple payment methods available, use it to
        specify the card to which you want to send the money. Otherwise, use None.
    amounts : list[float]
        The amounts of the payments.
    currencies : list[str]
        The ISO 4217 currency codes in upper case.
    references : list[str]
        The references for the payments.
    title : str, optional
        The title of the payment draft.
    schedule_for : date | Date | str, optional
        The scheduled date of the payment draft in ISO 8601 format.

    Returns
    -------
    dict | CreatePaymentDraft.Response
        A dict with the information about the payment draft created.
    """
    assert (
        len(counterparty_ids)
        == len(counterparty_account_ids)
        == len(counterparty_card_ids)
        == len(amounts)
        == len(currencies)
        == len(references)
    ), (
        "The number of elements in the lists must be equal. "
        f"Got {len(counterparty_ids)} counterparty_ids, "
        f"{len(counterparty_account_ids)} counterparty_account_ids, "
        f"{len(counterparty_card_ids)} counterparty_card_ids, "
        f"{len(amounts)} amounts, "
        f"{len(currencies)} currencies, "
        f"and {len(references)} references."
    )

    endpoint = CreatePaymentDraft
    path = endpoint.ROUTE
    body = endpoint.Body(
        title=title,
        schedule_for=schedule_for,
        payments=[
            endpoint.Body.ModelPayment(
                account_id=account_id,
                receiver=endpoint.Body.ModelPayment.ModelReceiver(
                    counterparty_id=counterparty_id,
                    account_id=counterparty_account_id,
                    card_id=counterparty_card_id,
                ),
                amount=amount,
                currency=currency,
                reference=reference,
            )
            for counterparty_id, counterparty_account_id, counterparty_card_id, amount, currency, reference in zip(
                counterparty_ids,
                counterparty_account_ids,
                counterparty_card_ids,
                amounts,
                currencies,
                references,
            )
        ],
    )

    return await self.client.post(
        path=path,
        response_model=endpoint.Response,
        body=body,
        **kwargs,
    )

delete_payment_draft(payment_draft_id, **kwargs) async

Delete a payment draft with the given ID. You can delete a payment draft only if it isn't processed.

Parameters:

Name Type Description Default
payment_draft_id UUID

The ID of the payment draft.

required

Returns:

Type Description
dict | Response

A dict with the information about the payment draft deleted.

Source code in pyrevolut/api/payment_drafts/endpoint/asynchronous.py
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
async def delete_payment_draft(
    self,
    payment_draft_id: UUID,
    **kwargs,
) -> dict | DeletePaymentDraft.Response:
    """
    Delete a payment draft with the given ID.
    You can delete a payment draft only if it isn't processed.

    Parameters
    ----------
    payment_draft_id : UUID
        The ID of the payment draft.

    Returns
    -------
    dict | DeletePaymentDraft.Response
        A dict with the information about the payment draft deleted.
    """
    endpoint = DeletePaymentDraft
    path = endpoint.ROUTE.format(payment_draft_id=payment_draft_id)
    params = endpoint.Params()

    return await self.client.delete(
        path=path,
        response_model=endpoint.Response,
        params=params,
        **kwargs,
    )

get_all_payment_drafts(**kwargs) async

Get a list of all the payment drafts that aren't processed.

Parameters:

Name Type Description Default
None
required

Returns:

Type Description
dict | Response

A dict with the information about the payment drafts.

Source code in pyrevolut/api/payment_drafts/endpoint/asynchronous.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
async def get_all_payment_drafts(
    self,
    **kwargs,
) -> dict | RetrieveAllPaymentDrafts.Response:
    """
    Get a list of all the payment drafts that aren't processed.

    Parameters
    ----------
    None

    Returns
    -------
    dict | RetrieveAllPaymentDrafts.Response
        A dict with the information about the payment drafts.
    """
    endpoint = RetrieveAllPaymentDrafts
    path = endpoint.ROUTE
    params = endpoint.Params()

    return await self.client.get(
        path=path,
        response_model=endpoint.Response,
        params=params,
        **kwargs,
    )

get_payment_draft(payment_draft_id, **kwargs) async

Get the information about a specific payment draft by ID.

Parameters:

Name Type Description Default
payment_draft_id UUID

The ID of the payment draft.

required

Returns:

Type Description
dict | Response

A dict with the information about the payment draft.

Source code in pyrevolut/api/payment_drafts/endpoint/asynchronous.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
async def get_payment_draft(
    self,
    payment_draft_id: UUID,
    **kwargs,
) -> dict | RetrievePaymentDraft.Response:
    """
    Get the information about a specific payment draft by ID.

    Parameters
    ----------
    payment_draft_id : UUID
        The ID of the payment draft.

    Returns
    -------
    dict | RetrievePaymentDraft.Response
        A dict with the information about the payment draft.
    """
    endpoint = RetrievePaymentDraft
    path = endpoint.ROUTE.format(payment_draft_id=payment_draft_id)
    params = endpoint.Params()

    return await self.client.get(
        path=path,
        response_model=endpoint.Response,
        params=params,
        **kwargs,
    )