Skip to content

Customer

CustomerClient

Bases: BaseAPIClient

Provides a wrapper for paystack Customer API

The Customers API allows you to create and manage customers in your integration. https://paystack.com/docs/api/customer/

Source code in src/pypaystack2/sub_clients/sync_clients/customers.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
class CustomerClient(BaseAPIClient):
    """Provides a wrapper for paystack Customer API

    The Customers API allows you to create and manage customers in your integration.
    https://paystack.com/docs/api/customer/
    """

    def create(
        self,
        email: str,
        first_name: str | None = None,
        last_name: str | None = None,
        phone: str | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Create a customer on your integration.

        Note:
            The `first_name`, `last_name` and `phone` are optional parameters. However,
            when creating a customer that would be assigned a Dedicated Virtual
            Account and your business category falls under Betting, Financial
            services, and General Service, then these parameters become compulsory.

        Args:
            email: Customer's email address
            first_name: Customer's first name
            last_name: Customer's last name
            phone: Customer's phone number
            metadata: A dictionary that you can attach to the customer. It can be used
                to store additional information in a structured format.
            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("/customer/")
        payload = {
            "email": email,
        }
        optional_params = [
            ("first_name", first_name),
            ("last_name", last_name),
            ("phone", phone),
            ("metadata", metadata),
        ]
        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 Customer,
        )

    def get_customers(
        self,
        start_date: str | None = None,
        end_date: str | None = None,
        page: int = 1,
        pagination: int = 50,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[list[Customer]] | Response[PaystackDataModel]:
        """Fetches customers available on your integration.

        Args:
            start_date: A timestamp from which to start listing customers e.g., 2016-09-24T00:00:05.000Z, 2016-09-21
            end_date: A timestamp at which to stop listing customers e.g., 2016-09-24T00:00:05.000Z, 2016-09-21
            page: Specify exactly what page you want to retrieve. If not specified, we use a default value of 1.
            pagination: Specifies how many records you want to retrieve per page.
                If not specified, we use a default value of 50.
            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.
        """

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

    def get_customer(
        self,
        email_or_code: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Get details of a customer on your integration.

        Args:
            email_or_code: An email or customer code for the customer you want to fetch
            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"/customer/{email_or_code}/")
        return self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or Customer,
        )

    def update(
        self,
        code: str,
        first_name: str | None = None,
        last_name: str | None = None,
        phone: str | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Update a customer's details on your integration

        Args:
            code: Customer's code
            first_name: Customer's first name
            last_name: Customer's last name
            phone: Customer's phone number
            metadata: A dictionary that you can attach to the customer. It can be used to store additional
                information in a structured format.
            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"/customer/{code}/")
        payload: dict[str, Any] = {}
        optional_params = [
            ("first_name", first_name),
            ("last_name", last_name),
            ("phone", phone),
            ("metadata", metadata),
        ]
        payload = add_to_payload(optional_params, payload)
        return self._handle_request(  # type: ignore
            HTTPMethod.PUT,
            url,
            payload,
            response_data_model_class=alternate_model_class or Customer,
        )

    def validate(
        self,
        email_or_code: str,
        first_name: str,
        last_name: str,
        identification_type: Identification,
        country: Country,
        bvn: str,
        identification_number: str | None = None,
        bank_code: str | None = None,
        account_number: str | None = None,
        middle_name: str | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[None] | Response[PaystackDataModel]:
        """Validate a customer's identity

        Args:
            email_or_code: Customer's email or code
            first_name: Customer's first name
            last_name: Customer's last name
            identification_type: Enum of Identification e.g `Identification.BVN`
            identification_number: An identification number based on the `identification_type`
            country: Customer's Country e.g `Country.NIGERIA`
            bvn: Customer's Bank Verification Number
            bank_code: You can get the list of Bank Codes by calling the
                Miscellaneous API `get_banks` method. (required if type is bank_account)
            account_number: Customer's bank account number. (required if type is bank_account)
            middle_name: Customer's middle name
            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.
        """

        if identification_type == Identification.BANK_ACCOUNT:
            if bank_code is None:
                raise ValueError(
                    "`bank_code` is required if identification type is `Identification.BANK_ACCOUNT`"
                )
            if account_number is None:
                raise ValueError(
                    "`account_number` is required if identification type is `Identification.BANK_ACCOUNT`"
                )

        url = self._full_url(f"/customer/{email_or_code}/identification")
        payload = {
            "first_name": first_name,
            "last_name": last_name,
            "type": identification_type,
            "country": country,
            "bvn": bvn,
        }
        optional_params = [
            ("bank_code", bank_code),
            ("account_number", account_number),
            ("middle_name", middle_name),
            ("value", identification_number),
        ]
        payload = add_to_payload(optional_params, payload)
        return self._handle_request(  # type: ignore
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

    def flag(
        self,
        customer: str,
        risk_action: RiskAction | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Whitelist or blacklist a customer on your integration

        Args:
            customer: Customer's code, or email address
            risk_action: One of the possible risk actions from the RiskAction enum e.g `RiskAction.DEFAULT`
            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("/customer/set_risk_action")
        payload = {
            "customer": customer,
        }
        optional_params = [
            ("risk_action", risk_action),
        ]
        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 Customer,
        )

    def initialize_authorization(
        self,
        email: str,
        callback_url: str | None = None,
        account: dict[str, Any] | None = None,
        address: dict[str, Any] | None = None,
        channel: str = "direct-debit",
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Initiate a request to create a reusable authorization code for recurring transactions.

        Args:
            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("/customer/authorization/initialize")
        payload = {
            "email": email,
            "channel": channel,
        }
        optional_params = [
            ("callback_url", callback_url),
            ("account", account),
            ("address", address),
        ]
        payload = add_to_payload(optional_params, payload)
        return self._handle_request(
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

    def verify_authorization(
        self,
        reference: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Check the status of an authorization request.

        Args:
            reference: The reference returned in the initialization response
            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"/customer/authorization/verify/{reference}")
        return self._handle_request(
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class,
        )

    def initialize_direct_debit(
        self,
        customer_id: str | int,
        account: dict[str, Any],
        address: dict[str, Any],
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Initialize the process of linking an account to a customer for Direct Debit transactions.

        Args:
            customer_id: The id of the customer.
            account: the customer's acount details. it should have a key `number`
                with a value that is the customer's account number, a key `bank_code`
                that is the code representing the customer's bank.
            address: the customer's address information. it should have the keys
                `street`, `city` and `state` that is the customer's address information
            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"/customer/{customer_id}/initialize-direct-debit")
        payload = {
            "account": account,
            "address": address,
        }
        return self._handle_request(
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

    def trigger_activation_charge(
        self,
        customer_id: str | int,
        authorization_id: str | int,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Trigger an activation charge on an inactive mandate on behalf of your customer.

        Args:
            customer_id: The customer ID attacted to the authorization
            authorization_id: The authorization ID gotten from the initiation response
            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"/customer/{customer_id}/directdebit-activation-charge")
        payload = {
            "authorization_id": authorization_id,
        }
        return self._handle_request(
            HTTPMethod.PUT,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

    def get_mandate_authorizations(
        self,
        id_: str | int,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Get the list of direct debit mandates associated with a customer.

        Args:
            id_: The customer ID for the authorizations to fetch
            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"/customer/{id_}/directdebit-mandate-authorizations")
        return self._handle_request(
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class,
        )

    def deactivate(
        self,
        auth_code: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[None] | Response[PaystackDataModel]:
        """Deactivate an authorization when the card needs to be forgotten

        Args:
            auth_code: Authorization code to be deactivated
            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("/customer/authorization/deactivate")
        payload = {
            "authorization_code": auth_code,
        }
        return self._handle_request(  # type: ignore
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

create(email, first_name=None, last_name=None, phone=None, metadata=None, alternate_model_class=None)

Create a customer on your integration.

Note

The first_name, last_name and phone are optional parameters. However, when creating a customer that would be assigned a Dedicated Virtual Account and your business category falls under Betting, Financial services, and General Service, then these parameters become compulsory.

Parameters:

Name Type Description Default
email str

Customer's email address

required
first_name str | None

Customer's first name

None
last_name str | None

Customer's last name

None
phone str | None

Customer's phone number

None
metadata dict[str, Any] | None

A dictionary that you can attach to the customer. It can be used to store additional information in a structured format.

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def create(
    self,
    email: str,
    first_name: str | None = None,
    last_name: str | None = None,
    phone: str | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Create a customer on your integration.

    Note:
        The `first_name`, `last_name` and `phone` are optional parameters. However,
        when creating a customer that would be assigned a Dedicated Virtual
        Account and your business category falls under Betting, Financial
        services, and General Service, then these parameters become compulsory.

    Args:
        email: Customer's email address
        first_name: Customer's first name
        last_name: Customer's last name
        phone: Customer's phone number
        metadata: A dictionary that you can attach to the customer. It can be used
            to store additional information in a structured format.
        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("/customer/")
    payload = {
        "email": email,
    }
    optional_params = [
        ("first_name", first_name),
        ("last_name", last_name),
        ("phone", phone),
        ("metadata", metadata),
    ]
    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 Customer,
    )

deactivate(auth_code, alternate_model_class=None)

Deactivate an authorization when the card needs to be forgotten

Parameters:

Name Type Description Default
auth_code str

Authorization code to be deactivated

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[None] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def deactivate(
    self,
    auth_code: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[None] | Response[PaystackDataModel]:
    """Deactivate an authorization when the card needs to be forgotten

    Args:
        auth_code: Authorization code to be deactivated
        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("/customer/authorization/deactivate")
    payload = {
        "authorization_code": auth_code,
    }
    return self._handle_request(  # type: ignore
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

flag(customer, risk_action=None, alternate_model_class=None)

Whitelist or blacklist a customer on your integration

Parameters:

Name Type Description Default
customer str

Customer's code, or email address

required
risk_action RiskAction | None

One of the possible risk actions from the RiskAction enum e.g RiskAction.DEFAULT

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def flag(
    self,
    customer: str,
    risk_action: RiskAction | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Whitelist or blacklist a customer on your integration

    Args:
        customer: Customer's code, or email address
        risk_action: One of the possible risk actions from the RiskAction enum e.g `RiskAction.DEFAULT`
        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("/customer/set_risk_action")
    payload = {
        "customer": customer,
    }
    optional_params = [
        ("risk_action", risk_action),
    ]
    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 Customer,
    )

get_customer(email_or_code, alternate_model_class=None)

Get details of a customer on your integration.

Parameters:

Name Type Description Default
email_or_code str

An email or customer code for the customer you want to fetch

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def get_customer(
    self,
    email_or_code: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Get details of a customer on your integration.

    Args:
        email_or_code: An email or customer code for the customer you want to fetch
        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"/customer/{email_or_code}/")
    return self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or Customer,
    )

get_customers(start_date=None, end_date=None, page=1, pagination=50, alternate_model_class=None)

Fetches customers available on your integration.

Parameters:

Name Type Description Default
start_date str | None

A timestamp from which to start listing customers e.g., 2016-09-24T00:00:05.000Z, 2016-09-21

None
end_date str | None

A timestamp at which to stop listing customers e.g., 2016-09-24T00:00:05.000Z, 2016-09-21

None
page int

Specify exactly what page you want to retrieve. If not specified, we use a default value of 1.

1
pagination int

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

50
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[Customer]] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def get_customers(
    self,
    start_date: str | None = None,
    end_date: str | None = None,
    page: int = 1,
    pagination: int = 50,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[list[Customer]] | Response[PaystackDataModel]:
    """Fetches customers available on your integration.

    Args:
        start_date: A timestamp from which to start listing customers e.g., 2016-09-24T00:00:05.000Z, 2016-09-21
        end_date: A timestamp at which to stop listing customers e.g., 2016-09-24T00:00:05.000Z, 2016-09-21
        page: Specify exactly what page you want to retrieve. If not specified, we use a default value of 1.
        pagination: Specifies how many records you want to retrieve per page.
            If not specified, we use a default value of 50.
        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.
    """

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

get_mandate_authorizations(id_, alternate_model_class=None)

Get the list of direct debit mandates associated with a customer.

Parameters:

Name Type Description Default
id_ str | int

The customer ID for the authorizations to fetch

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

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def get_mandate_authorizations(
    self,
    id_: str | int,
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Get the list of direct debit mandates associated with a customer.

    Args:
        id_: The customer ID for the authorizations to fetch
        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"/customer/{id_}/directdebit-mandate-authorizations")
    return self._handle_request(
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class,
    )

initialize_authorization(email, callback_url=None, account=None, address=None, channel='direct-debit', alternate_model_class=None)

Initiate a request to create a reusable authorization code for recurring transactions.

Parameters:

Name Type Description Default
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

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def initialize_authorization(
    self,
    email: str,
    callback_url: str | None = None,
    account: dict[str, Any] | None = None,
    address: dict[str, Any] | None = None,
    channel: str = "direct-debit",
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Initiate a request to create a reusable authorization code for recurring transactions.

    Args:
        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("/customer/authorization/initialize")
    payload = {
        "email": email,
        "channel": channel,
    }
    optional_params = [
        ("callback_url", callback_url),
        ("account", account),
        ("address", address),
    ]
    payload = add_to_payload(optional_params, payload)
    return self._handle_request(
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

initialize_direct_debit(customer_id, account, address, alternate_model_class=None)

Initialize the process of linking an account to a customer for Direct Debit transactions.

Parameters:

Name Type Description Default
customer_id str | int

The id of the customer.

required
account dict[str, Any]

the customer's acount details. it should have a key number with a value that is the customer's account number, a key bank_code that is the code representing the customer's bank.

required
address dict[str, Any]

the customer's address information. it should have the keys street, city and state that is the customer's address information

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

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def initialize_direct_debit(
    self,
    customer_id: str | int,
    account: dict[str, Any],
    address: dict[str, Any],
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Initialize the process of linking an account to a customer for Direct Debit transactions.

    Args:
        customer_id: The id of the customer.
        account: the customer's acount details. it should have a key `number`
            with a value that is the customer's account number, a key `bank_code`
            that is the code representing the customer's bank.
        address: the customer's address information. it should have the keys
            `street`, `city` and `state` that is the customer's address information
        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"/customer/{customer_id}/initialize-direct-debit")
    payload = {
        "account": account,
        "address": address,
    }
    return self._handle_request(
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

trigger_activation_charge(customer_id, authorization_id, alternate_model_class=None)

Trigger an activation charge on an inactive mandate on behalf of your customer.

Parameters:

Name Type Description Default
customer_id str | int

The customer ID attacted to the authorization

required
authorization_id str | int

The authorization ID gotten from the initiation response

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

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def trigger_activation_charge(
    self,
    customer_id: str | int,
    authorization_id: str | int,
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Trigger an activation charge on an inactive mandate on behalf of your customer.

    Args:
        customer_id: The customer ID attacted to the authorization
        authorization_id: The authorization ID gotten from the initiation response
        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"/customer/{customer_id}/directdebit-activation-charge")
    payload = {
        "authorization_id": authorization_id,
    }
    return self._handle_request(
        HTTPMethod.PUT,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

update(code, first_name=None, last_name=None, phone=None, metadata=None, alternate_model_class=None)

Update a customer's details on your integration

Parameters:

Name Type Description Default
code str

Customer's code

required
first_name str | None

Customer's first name

None
last_name str | None

Customer's last name

None
phone str | None

Customer's phone number

None
metadata dict[str, Any] | None

A dictionary that you can attach to the customer. It can be used to store additional information in a structured format.

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def update(
    self,
    code: str,
    first_name: str | None = None,
    last_name: str | None = None,
    phone: str | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Update a customer's details on your integration

    Args:
        code: Customer's code
        first_name: Customer's first name
        last_name: Customer's last name
        phone: Customer's phone number
        metadata: A dictionary that you can attach to the customer. It can be used to store additional
            information in a structured format.
        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"/customer/{code}/")
    payload: dict[str, Any] = {}
    optional_params = [
        ("first_name", first_name),
        ("last_name", last_name),
        ("phone", phone),
        ("metadata", metadata),
    ]
    payload = add_to_payload(optional_params, payload)
    return self._handle_request(  # type: ignore
        HTTPMethod.PUT,
        url,
        payload,
        response_data_model_class=alternate_model_class or Customer,
    )

validate(email_or_code, first_name, last_name, identification_type, country, bvn, identification_number=None, bank_code=None, account_number=None, middle_name=None, alternate_model_class=None)

Validate a customer's identity

Parameters:

Name Type Description Default
email_or_code str

Customer's email or code

required
first_name str

Customer's first name

required
last_name str

Customer's last name

required
identification_type Identification

Enum of Identification e.g Identification.BVN

required
identification_number str | None

An identification number based on the identification_type

None
country Country

Customer's Country e.g Country.NIGERIA

required
bvn str

Customer's Bank Verification Number

required
bank_code str | None

You can get the list of Bank Codes by calling the Miscellaneous API get_banks method. (required if type is bank_account)

None
account_number str | None

Customer's bank account number. (required if type is bank_account)

None
middle_name str | None

Customer's middle name

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[None] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def validate(
    self,
    email_or_code: str,
    first_name: str,
    last_name: str,
    identification_type: Identification,
    country: Country,
    bvn: str,
    identification_number: str | None = None,
    bank_code: str | None = None,
    account_number: str | None = None,
    middle_name: str | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[None] | Response[PaystackDataModel]:
    """Validate a customer's identity

    Args:
        email_or_code: Customer's email or code
        first_name: Customer's first name
        last_name: Customer's last name
        identification_type: Enum of Identification e.g `Identification.BVN`
        identification_number: An identification number based on the `identification_type`
        country: Customer's Country e.g `Country.NIGERIA`
        bvn: Customer's Bank Verification Number
        bank_code: You can get the list of Bank Codes by calling the
            Miscellaneous API `get_banks` method. (required if type is bank_account)
        account_number: Customer's bank account number. (required if type is bank_account)
        middle_name: Customer's middle name
        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.
    """

    if identification_type == Identification.BANK_ACCOUNT:
        if bank_code is None:
            raise ValueError(
                "`bank_code` is required if identification type is `Identification.BANK_ACCOUNT`"
            )
        if account_number is None:
            raise ValueError(
                "`account_number` is required if identification type is `Identification.BANK_ACCOUNT`"
            )

    url = self._full_url(f"/customer/{email_or_code}/identification")
    payload = {
        "first_name": first_name,
        "last_name": last_name,
        "type": identification_type,
        "country": country,
        "bvn": bvn,
    }
    optional_params = [
        ("bank_code", bank_code),
        ("account_number", account_number),
        ("middle_name", middle_name),
        ("value", identification_number),
    ]
    payload = add_to_payload(optional_params, payload)
    return self._handle_request(  # type: ignore
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

verify_authorization(reference, alternate_model_class=None)

Check the status of an authorization request.

Parameters:

Name Type Description Default
reference str

The reference returned in the initialization response

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

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

Source code in src/pypaystack2/sub_clients/sync_clients/customers.py
def verify_authorization(
    self,
    reference: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Check the status of an authorization request.

    Args:
        reference: The reference returned in the initialization response
        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"/customer/authorization/verify/{reference}")
    return self._handle_request(
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class,
    )

AsyncCustomerClient

Bases: BaseAsyncAPIClient

Provides a wrapper for paystack Customer API

The Customers API allows you to create and manage customers in your integration. https://paystack.com/docs/api/customer/

Source code in src/pypaystack2/sub_clients/async_clients/customers.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
class AsyncCustomerClient(BaseAsyncAPIClient):
    """Provides a wrapper for paystack Customer API

    The Customers API allows you to create and manage customers in your integration.
    https://paystack.com/docs/api/customer/
    """

    async def create(
        self,
        email: str,
        first_name: str | None = None,
        last_name: str | None = None,
        phone: str | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Create a customer on your integration.

        Note:
            The `first_name`, `last_name` and `phone` are optional parameters. However,
            when creating a customer that would be assigned a Dedicated Virtual
            Account and your business category falls under Betting, Financial
            services, and General Service, then these parameters become compulsory.

        Args:
            email: Customer's email address
            first_name: Customer's first name
            last_name: Customer's last name
            phone: Customer's phone number
            metadata: A dictionary that you can attach to the customer. It can be used
                to store additional information in a structured format.
            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("/customer/")
        payload = {
            "email": email,
        }
        optional_params = [
            ("first_name", first_name),
            ("last_name", last_name),
            ("phone", phone),
            ("metadata", metadata),
        ]
        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 Customer,
        )

    async def get_customers(
        self,
        start_date: str | None = None,
        end_date: str | None = None,
        page: int = 1,
        pagination: int = 50,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[list[Customer]] | Response[PaystackDataModel]:
        """Fetches customers available on your integration.

        Args:
            start_date: A timestamp from which to start listing customers e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
            end_date: A timestamp at which to stop listing customers e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
            page: Specify exactly what page you want to retrieve. If not specified, we use a default value of 1.
            pagination: Specifies how many records you want to retrieve per page.
                If not specified we use a default value of 50.
            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.
        """

        query_params = [
            ("page", page),
            ("from", start_date),
            ("to", end_date),
        ]
        url = self._full_url(f"/customer/?perPage={pagination}")
        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 Customer,
        )

    async def get_customer(
        self,
        email_or_code: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Get details of a customer on your integration.

        Args:
            email_or_code: An email or customer code for the customer you want to fetch
            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"/customer/{email_or_code}/")
        return await self._handle_request(  # type: ignore
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class or Customer,
        )

    async def update(
        self,
        code: str,
        first_name: str | None = None,
        last_name: str | None = None,
        phone: str | None = None,
        metadata: dict[str, Any] | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Update a customer's details on your integration

        Args:
            code: Customer's code
            first_name: Customer's first name
            last_name: Customer's last name
            phone: Customer's phone number
            metadata: A dictionary that you can attach to the customer. It can be used to store additional
                information in a structured format.
            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"/customer/{code}/")
        payload: dict[str, Any] = {}

        optional_params = [
            ("first_name", first_name),
            ("last_name", last_name),
            ("phone", phone),
            ("metadata", metadata),
        ]
        payload = add_to_payload(optional_params, payload)
        return await self._handle_request(  # type: ignore
            HTTPMethod.PUT,
            url,
            payload,
            response_data_model_class=alternate_model_class or Customer,
        )

    async def validate(
        self,
        email_or_code: str,
        first_name: str,
        last_name: str,
        identification_type: Identification,
        country: Country,
        bvn: str,
        identification_number: str | None = None,
        bank_code: str | None = None,
        account_number: str | None = None,
        middle_name: str | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[None] | Response[PaystackDataModel]:
        """Validate a customer's identity

        Args:
            email_or_code: Customer's email or code
            first_name: Customer's first name
            last_name: Customer's last name
            identification_type: Enum of Identification e.g `Identification.BVN`
            identification_number: An identification number based on the `identification_type`
            country: Customer's Country e.g `Country.NIGERIA`
            bvn: Customer's Bank Verification Number
            bank_code: You can get the list of Bank Codes by calling the
                Miscellaneous API `get_banks` method. (required if type is bank_account)
            account_number: Customer's bank account number. (required if type is bank_account)
            middle_name: Customer's middle name
            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.
        """

        if identification_type == Identification.BANK_ACCOUNT:
            if bank_code is None:
                raise ValueError(
                    "`bank_code` is required if identification type is `Identification.BANK_ACCOUNT`"
                )
            if account_number is None:
                raise ValueError(
                    "`account_number` is required if identification type is `Identification.BANK_ACCOUNT`"
                )

        url = self._full_url(f"/customer/{email_or_code}/identification")
        payload = {
            "first_name": first_name,
            "last_name": last_name,
            "type": identification_type,
            "country": country,
            "bvn": bvn,
        }
        optional_params = [
            ("bank_code", bank_code),
            ("account_number", account_number),
            ("middle_name", middle_name),
            ("value", identification_number),
        ]
        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,
        )

    async def flag(
        self,
        customer: str,
        risk_action: RiskAction | None = None,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[Customer] | Response[PaystackDataModel]:
        """Whitelist or blacklist a customer on your integration

        Args:
            customer: Customer's code, or email address
            risk_action: One of the possible risk actions from the RiskAction enum e.g `RiskAction.DEFAULT`
            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("/customer/set_risk_action")
        payload = {
            "customer": customer,
        }
        optional_params = [
            ("risk_action", risk_action),
        ]
        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 Customer,
        )

    async def initialize_authorization(
        self,
        email: str,
        callback_url: str | None = None,
        account: dict[str, Any] | None = None,
        address: dict[str, Any] | None = None,
        channel: str = "direct-debit",
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Initiate a request to create a reusable authorization code for recurring transactions.

        Args:
            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("/customer/authorization/initialize")
        payload = {
            "email": email,
            "channel": channel,
        }
        optional_params = [
            ("callback_url", callback_url),
            ("account", account),
            ("address", address),
        ]
        payload = add_to_payload(optional_params, payload)
        return await self._handle_request(
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

    async def verify_authorization(
        self,
        reference: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Check the status of an authorization request.

        Args:
            reference: The reference returned in the initialization response
            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"/customer/authorization/verify/{reference}")
        return await self._handle_request(
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class,
        )

    async def initialize_direct_debit(
        self,
        customer_id: str | int,
        account: dict[str, Any],
        address: dict[str, Any],
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Initialize the process of linking an account to a customer for Direct Debit transactions.

        Args:
            customer_id: The id of the customer.
            account: the customer's acount details. it should have a key `number`
                with a value that is the customer's account number, a key `bank_code`
                that is the code representing the customer's bank.
            address: the customer's address information. it should have the keys
                `street`, `city` and `state` that is the customer's address information
            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"/customer/{customer_id}/initialize-direct-debit")
        payload = {
            "account": account,
            "address": address,
        }
        return await self._handle_request(
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

    async def trigger_activation_charge(
        self,
        customer_id: str | int,
        authorization_id: str | int,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Trigger an activation charge on an inactive mandate on behalf of your customer.

        Args:
            customer_id: The customer ID attacted to the authorization
            authorization_id: The authorization ID gotten from the initiation response
            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"/customer/{customer_id}/directdebit-activation-charge")
        payload = {
            "authorization_id": authorization_id,
        }
        return await self._handle_request(
            HTTPMethod.PUT,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

    async def get_mandate_authorizations(
        self,
        id_: str | int,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ):
        """Get the list of direct debit mandates associated with a customer.

        Args:
            id_: The customer ID for the authorizations to fetch
            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"/customer/{id_}/directdebit-mandate-authorizations")
        return await self._handle_request(
            HTTPMethod.GET,
            url,
            response_data_model_class=alternate_model_class,
        )

    async def deactivate(
        self,
        auth_code: str,
        alternate_model_class: type[PaystackDataModel] | None = None,
    ) -> Response[None] | Response[PaystackDataModel]:
        """Deactivate an authorization when the card needs to be forgotten

        Args:
            auth_code: Authorization code to be deactivated
            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("/customer/authorization/deactivate")
        payload = {
            "authorization_code": auth_code,
        }
        return await self._handle_request(  # type: ignore
            HTTPMethod.POST,
            url,
            payload,
            response_data_model_class=alternate_model_class,
        )

create(email, first_name=None, last_name=None, phone=None, metadata=None, alternate_model_class=None) async

Create a customer on your integration.

Note

The first_name, last_name and phone are optional parameters. However, when creating a customer that would be assigned a Dedicated Virtual Account and your business category falls under Betting, Financial services, and General Service, then these parameters become compulsory.

Parameters:

Name Type Description Default
email str

Customer's email address

required
first_name str | None

Customer's first name

None
last_name str | None

Customer's last name

None
phone str | None

Customer's phone number

None
metadata dict[str, Any] | None

A dictionary that you can attach to the customer. It can be used to store additional information in a structured format.

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def create(
    self,
    email: str,
    first_name: str | None = None,
    last_name: str | None = None,
    phone: str | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Create a customer on your integration.

    Note:
        The `first_name`, `last_name` and `phone` are optional parameters. However,
        when creating a customer that would be assigned a Dedicated Virtual
        Account and your business category falls under Betting, Financial
        services, and General Service, then these parameters become compulsory.

    Args:
        email: Customer's email address
        first_name: Customer's first name
        last_name: Customer's last name
        phone: Customer's phone number
        metadata: A dictionary that you can attach to the customer. It can be used
            to store additional information in a structured format.
        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("/customer/")
    payload = {
        "email": email,
    }
    optional_params = [
        ("first_name", first_name),
        ("last_name", last_name),
        ("phone", phone),
        ("metadata", metadata),
    ]
    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 Customer,
    )

deactivate(auth_code, alternate_model_class=None) async

Deactivate an authorization when the card needs to be forgotten

Parameters:

Name Type Description Default
auth_code str

Authorization code to be deactivated

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[None] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def deactivate(
    self,
    auth_code: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[None] | Response[PaystackDataModel]:
    """Deactivate an authorization when the card needs to be forgotten

    Args:
        auth_code: Authorization code to be deactivated
        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("/customer/authorization/deactivate")
    payload = {
        "authorization_code": auth_code,
    }
    return await self._handle_request(  # type: ignore
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

flag(customer, risk_action=None, alternate_model_class=None) async

Whitelist or blacklist a customer on your integration

Parameters:

Name Type Description Default
customer str

Customer's code, or email address

required
risk_action RiskAction | None

One of the possible risk actions from the RiskAction enum e.g RiskAction.DEFAULT

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def flag(
    self,
    customer: str,
    risk_action: RiskAction | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Whitelist or blacklist a customer on your integration

    Args:
        customer: Customer's code, or email address
        risk_action: One of the possible risk actions from the RiskAction enum e.g `RiskAction.DEFAULT`
        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("/customer/set_risk_action")
    payload = {
        "customer": customer,
    }
    optional_params = [
        ("risk_action", risk_action),
    ]
    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 Customer,
    )

get_customer(email_or_code, alternate_model_class=None) async

Get details of a customer on your integration.

Parameters:

Name Type Description Default
email_or_code str

An email or customer code for the customer you want to fetch

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def get_customer(
    self,
    email_or_code: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Get details of a customer on your integration.

    Args:
        email_or_code: An email or customer code for the customer you want to fetch
        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"/customer/{email_or_code}/")
    return await self._handle_request(  # type: ignore
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class or Customer,
    )

get_customers(start_date=None, end_date=None, page=1, pagination=50, alternate_model_class=None) async

Fetches customers available on your integration.

Parameters:

Name Type Description Default
start_date str | None

A timestamp from which to start listing customers e.g. 2016-09-24T00:00:05.000Z, 2016-09-21

None
end_date str | None

A timestamp at which to stop listing customers e.g. 2016-09-24T00:00:05.000Z, 2016-09-21

None
page int

Specify exactly what page you want to retrieve. If not specified, we use a default value of 1.

1
pagination int

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

50
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[Customer]] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def get_customers(
    self,
    start_date: str | None = None,
    end_date: str | None = None,
    page: int = 1,
    pagination: int = 50,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[list[Customer]] | Response[PaystackDataModel]:
    """Fetches customers available on your integration.

    Args:
        start_date: A timestamp from which to start listing customers e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
        end_date: A timestamp at which to stop listing customers e.g. 2016-09-24T00:00:05.000Z, 2016-09-21
        page: Specify exactly what page you want to retrieve. If not specified, we use a default value of 1.
        pagination: Specifies how many records you want to retrieve per page.
            If not specified we use a default value of 50.
        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.
    """

    query_params = [
        ("page", page),
        ("from", start_date),
        ("to", end_date),
    ]
    url = self._full_url(f"/customer/?perPage={pagination}")
    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 Customer,
    )

get_mandate_authorizations(id_, alternate_model_class=None) async

Get the list of direct debit mandates associated with a customer.

Parameters:

Name Type Description Default
id_ str | int

The customer ID for the authorizations to fetch

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

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def get_mandate_authorizations(
    self,
    id_: str | int,
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Get the list of direct debit mandates associated with a customer.

    Args:
        id_: The customer ID for the authorizations to fetch
        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"/customer/{id_}/directdebit-mandate-authorizations")
    return await self._handle_request(
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class,
    )

initialize_authorization(email, callback_url=None, account=None, address=None, channel='direct-debit', alternate_model_class=None) async

Initiate a request to create a reusable authorization code for recurring transactions.

Parameters:

Name Type Description Default
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

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def initialize_authorization(
    self,
    email: str,
    callback_url: str | None = None,
    account: dict[str, Any] | None = None,
    address: dict[str, Any] | None = None,
    channel: str = "direct-debit",
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Initiate a request to create a reusable authorization code for recurring transactions.

    Args:
        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("/customer/authorization/initialize")
    payload = {
        "email": email,
        "channel": channel,
    }
    optional_params = [
        ("callback_url", callback_url),
        ("account", account),
        ("address", address),
    ]
    payload = add_to_payload(optional_params, payload)
    return await self._handle_request(
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

initialize_direct_debit(customer_id, account, address, alternate_model_class=None) async

Initialize the process of linking an account to a customer for Direct Debit transactions.

Parameters:

Name Type Description Default
customer_id str | int

The id of the customer.

required
account dict[str, Any]

the customer's acount details. it should have a key number with a value that is the customer's account number, a key bank_code that is the code representing the customer's bank.

required
address dict[str, Any]

the customer's address information. it should have the keys street, city and state that is the customer's address information

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

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def initialize_direct_debit(
    self,
    customer_id: str | int,
    account: dict[str, Any],
    address: dict[str, Any],
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Initialize the process of linking an account to a customer for Direct Debit transactions.

    Args:
        customer_id: The id of the customer.
        account: the customer's acount details. it should have a key `number`
            with a value that is the customer's account number, a key `bank_code`
            that is the code representing the customer's bank.
        address: the customer's address information. it should have the keys
            `street`, `city` and `state` that is the customer's address information
        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"/customer/{customer_id}/initialize-direct-debit")
    payload = {
        "account": account,
        "address": address,
    }
    return await self._handle_request(
        HTTPMethod.POST,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

trigger_activation_charge(customer_id, authorization_id, alternate_model_class=None) async

Trigger an activation charge on an inactive mandate on behalf of your customer.

Parameters:

Name Type Description Default
customer_id str | int

The customer ID attacted to the authorization

required
authorization_id str | int

The authorization ID gotten from the initiation response

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

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def trigger_activation_charge(
    self,
    customer_id: str | int,
    authorization_id: str | int,
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Trigger an activation charge on an inactive mandate on behalf of your customer.

    Args:
        customer_id: The customer ID attacted to the authorization
        authorization_id: The authorization ID gotten from the initiation response
        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"/customer/{customer_id}/directdebit-activation-charge")
    payload = {
        "authorization_id": authorization_id,
    }
    return await self._handle_request(
        HTTPMethod.PUT,
        url,
        payload,
        response_data_model_class=alternate_model_class,
    )

update(code, first_name=None, last_name=None, phone=None, metadata=None, alternate_model_class=None) async

Update a customer's details on your integration

Parameters:

Name Type Description Default
code str

Customer's code

required
first_name str | None

Customer's first name

None
last_name str | None

Customer's last name

None
phone str | None

Customer's phone number

None
metadata dict[str, Any] | None

A dictionary that you can attach to the customer. It can be used to store additional information in a structured format.

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[Customer] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def update(
    self,
    code: str,
    first_name: str | None = None,
    last_name: str | None = None,
    phone: str | None = None,
    metadata: dict[str, Any] | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[Customer] | Response[PaystackDataModel]:
    """Update a customer's details on your integration

    Args:
        code: Customer's code
        first_name: Customer's first name
        last_name: Customer's last name
        phone: Customer's phone number
        metadata: A dictionary that you can attach to the customer. It can be used to store additional
            information in a structured format.
        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"/customer/{code}/")
    payload: dict[str, Any] = {}

    optional_params = [
        ("first_name", first_name),
        ("last_name", last_name),
        ("phone", phone),
        ("metadata", metadata),
    ]
    payload = add_to_payload(optional_params, payload)
    return await self._handle_request(  # type: ignore
        HTTPMethod.PUT,
        url,
        payload,
        response_data_model_class=alternate_model_class or Customer,
    )

validate(email_or_code, first_name, last_name, identification_type, country, bvn, identification_number=None, bank_code=None, account_number=None, middle_name=None, alternate_model_class=None) async

Validate a customer's identity

Parameters:

Name Type Description Default
email_or_code str

Customer's email or code

required
first_name str

Customer's first name

required
last_name str

Customer's last name

required
identification_type Identification

Enum of Identification e.g Identification.BVN

required
identification_number str | None

An identification number based on the identification_type

None
country Country

Customer's Country e.g Country.NIGERIA

required
bvn str

Customer's Bank Verification Number

required
bank_code str | None

You can get the list of Bank Codes by calling the Miscellaneous API get_banks method. (required if type is bank_account)

None
account_number str | None

Customer's bank account number. (required if type is bank_account)

None
middle_name str | None

Customer's middle name

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[None] | Response[PaystackDataModel]

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def validate(
    self,
    email_or_code: str,
    first_name: str,
    last_name: str,
    identification_type: Identification,
    country: Country,
    bvn: str,
    identification_number: str | None = None,
    bank_code: str | None = None,
    account_number: str | None = None,
    middle_name: str | None = None,
    alternate_model_class: type[PaystackDataModel] | None = None,
) -> Response[None] | Response[PaystackDataModel]:
    """Validate a customer's identity

    Args:
        email_or_code: Customer's email or code
        first_name: Customer's first name
        last_name: Customer's last name
        identification_type: Enum of Identification e.g `Identification.BVN`
        identification_number: An identification number based on the `identification_type`
        country: Customer's Country e.g `Country.NIGERIA`
        bvn: Customer's Bank Verification Number
        bank_code: You can get the list of Bank Codes by calling the
            Miscellaneous API `get_banks` method. (required if type is bank_account)
        account_number: Customer's bank account number. (required if type is bank_account)
        middle_name: Customer's middle name
        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.
    """

    if identification_type == Identification.BANK_ACCOUNT:
        if bank_code is None:
            raise ValueError(
                "`bank_code` is required if identification type is `Identification.BANK_ACCOUNT`"
            )
        if account_number is None:
            raise ValueError(
                "`account_number` is required if identification type is `Identification.BANK_ACCOUNT`"
            )

    url = self._full_url(f"/customer/{email_or_code}/identification")
    payload = {
        "first_name": first_name,
        "last_name": last_name,
        "type": identification_type,
        "country": country,
        "bvn": bvn,
    }
    optional_params = [
        ("bank_code", bank_code),
        ("account_number", account_number),
        ("middle_name", middle_name),
        ("value", identification_number),
    ]
    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,
    )

verify_authorization(reference, alternate_model_class=None) async

Check the status of an authorization request.

Parameters:

Name Type Description Default
reference str

The reference returned in the initialization response

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

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

Source code in src/pypaystack2/sub_clients/async_clients/customers.py
async def verify_authorization(
    self,
    reference: str,
    alternate_model_class: type[PaystackDataModel] | None = None,
):
    """Check the status of an authorization request.

    Args:
        reference: The reference returned in the initialization response
        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"/customer/authorization/verify/{reference}")
    return await self._handle_request(
        HTTPMethod.GET,
        url,
        response_data_model_class=alternate_model_class,
    )