Pular para conteúdo

Customers reference

PixQrCodeAsyncClient

Bases: BaseAsyncClient

Source code in abacatepay/pixQrCode/client.py
 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
class PixQrCodeAsyncClient(BaseAsyncClient):
    async def create(self, data: PixQrCodeIn | dict[str, Any], **kwargs: Any) -> PixQrCode:
        """
        Create a new Pix QR Code.

        Args:
            amount (int): The amount to be paid in cents.
            expires_in (int, optional): The expiration time in seconds.
                Defaults to None.
            description (str, optional): A description for the Pix QR Code.
                Defaults to None.
            customer (CustomerMetadata | dict, optional): Customer information.
                Defaults to None.
        Returns:
            PixQrCode: The created Pix QR Code object.
        """
        json_data = prepare_data(data or kwargs, PixQrCodeIn)
        logger.debug('Creating Pix QR Code: %s', json_data)

        response = await self._request(
            f'{BASE_URL}/pixQrCode/create',
            method='POST',
            json=json_data,
        )
        logger.debug('Pix QR Code created successfully: %s', response.json())
        return PixQrCode.model_validate(response.json()['data'])

    async def check(self, id: str) -> PixStatus:
        """
        Get the status of a Pix QR Code.

        Args:
            ID (str): The unique identifier of the Pix QR Code.

        Returns:
            PixStatus: The status of the Pix QR Code.
        """
        logger.debug(f'Getting status for Pix QR Code ID: {id}')
        response = await self._request(
            f'{BASE_URL}/pixQrCode/check?id={id}',
            method='GET',
        )
        return PixStatus.model_validate(response.json()['data'])

    async def simulate(self, id: str, metadata: dict[str, Any] | None = None) -> PixQrCode:
        """
        Simulate a Pix QR Code.

        Args:
            id (str): The unique identifier of the Pix QR Code.
            metadata (dict, optional): Additional metadata for the simulation.
                Defaults to {}.

        Returns:
            PixQrCode: The simulated Pix QR Code object.
        """
        logger.debug(f'Simulating Pix QR Code ID: {id}')
        response = await self._request(
            f'{BASE_URL}/pixQrCode/simulate-payment?id={id}',
            method='POST',
            json=metadata or {},
        )
        return PixQrCode.model_validate(response.json()['data'])

check(id) async

Get the status of a Pix QR Code.

Parameters:

Name Type Description Default
ID str

The unique identifier of the Pix QR Code.

required

Returns:

Name Type Description
PixStatus PixStatus

The status of the Pix QR Code.

Source code in abacatepay/pixQrCode/client.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
async def check(self, id: str) -> PixStatus:
    """
    Get the status of a Pix QR Code.

    Args:
        ID (str): The unique identifier of the Pix QR Code.

    Returns:
        PixStatus: The status of the Pix QR Code.
    """
    logger.debug(f'Getting status for Pix QR Code ID: {id}')
    response = await self._request(
        f'{BASE_URL}/pixQrCode/check?id={id}',
        method='GET',
    )
    return PixStatus.model_validate(response.json()['data'])

create(data, **kwargs) async

Create a new Pix QR Code.

Parameters:

Name Type Description Default
amount int

The amount to be paid in cents.

required
expires_in int

The expiration time in seconds. Defaults to None.

required
description str

A description for the Pix QR Code. Defaults to None.

required
customer CustomerMetadata | dict

Customer information. Defaults to None.

required

Returns: PixQrCode: The created Pix QR Code object.

Source code in abacatepay/pixQrCode/client.py
 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
async def create(self, data: PixQrCodeIn | dict[str, Any], **kwargs: Any) -> PixQrCode:
    """
    Create a new Pix QR Code.

    Args:
        amount (int): The amount to be paid in cents.
        expires_in (int, optional): The expiration time in seconds.
            Defaults to None.
        description (str, optional): A description for the Pix QR Code.
            Defaults to None.
        customer (CustomerMetadata | dict, optional): Customer information.
            Defaults to None.
    Returns:
        PixQrCode: The created Pix QR Code object.
    """
    json_data = prepare_data(data or kwargs, PixQrCodeIn)
    logger.debug('Creating Pix QR Code: %s', json_data)

    response = await self._request(
        f'{BASE_URL}/pixQrCode/create',
        method='POST',
        json=json_data,
    )
    logger.debug('Pix QR Code created successfully: %s', response.json())
    return PixQrCode.model_validate(response.json()['data'])

simulate(id, metadata=None) async

Simulate a Pix QR Code.

Parameters:

Name Type Description Default
id str

The unique identifier of the Pix QR Code.

required
metadata dict

Additional metadata for the simulation. Defaults to {}.

None

Returns:

Name Type Description
PixQrCode PixQrCode

The simulated Pix QR Code object.

Source code in abacatepay/pixQrCode/client.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
async def simulate(self, id: str, metadata: dict[str, Any] | None = None) -> PixQrCode:
    """
    Simulate a Pix QR Code.

    Args:
        id (str): The unique identifier of the Pix QR Code.
        metadata (dict, optional): Additional metadata for the simulation.
            Defaults to {}.

    Returns:
        PixQrCode: The simulated Pix QR Code object.
    """
    logger.debug(f'Simulating Pix QR Code ID: {id}')
    response = await self._request(
        f'{BASE_URL}/pixQrCode/simulate-payment?id={id}',
        method='POST',
        json=metadata or {},
    )
    return PixQrCode.model_validate(response.json()['data'])

PixQrCodeClient

Bases: BaseClient

Source code in abacatepay/pixQrCode/client.py
12
13
14
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
class PixQrCodeClient(BaseClient):
    def create(self, data: PixQrCodeIn | dict[str, Any], **kwargs: Any) -> PixQrCode:
        """
        Create a new Pix QR Code.

        Args:
            amount (int): The amount to be paid in cents.
            expires_in (int, optional): The expiration time in seconds.
                Defaults to None.
            description (str, optional): A description for the Pix QR Code.
                Defaults to None.
            customer (CustomerMetadata | dict, optional): Customer information.
                Defaults to None.
        Returns:
            PixQrCode: The created Pix QR Code object.
        """
        json_data = prepare_data(data or kwargs, PixQrCodeIn)
        logger.debug('Creating Pix QR Code: %s', json_data)

        response = self._request(
            f'{BASE_URL}/pixQrCode/create',
            method='POST',
            json=json_data,
        )
        logger.debug('Pix QR Code created successfully: %s', response.json())
        return PixQrCode.model_validate(response.json()['data'])

    def check(self, id: str) -> PixStatus:
        """
        Get the status of a Pix QR Code.

        Args:
            ID (str): The unique identifier of the Pix QR Code.

        Returns:
            PixStatus: The status of the Pix QR Code.
        """
        logger.debug(f'Getting status for Pix QR Code ID: {id}')
        response = self._request(
            f'{BASE_URL}/pixQrCode/check?id={id}',
            method='GET',
        )
        return PixStatus.model_validate(response.json()['data'])

    def simulate(self, id: str, metadata: dict[str, Any] | None = None) -> PixQrCode:
        """
        Simulate a Pix QR Code.

        Args:
            id (str): The unique identifier of the Pix QR Code.
            metadata (dict, optional): Additional metadata for the simulation.
                Defaults to {}.

        Returns:
            PixQrCode: The simulated Pix QR Code object.
        """
        logger.debug(f'Simulating Pix QR Code ID: {id}')
        response = self._request(
            f'{BASE_URL}/pixQrCode/simulate-payment?id={id}',
            method='POST',
            json=metadata or {},
        )
        return PixQrCode.model_validate(response.json()['data'])

check(id)

Get the status of a Pix QR Code.

Parameters:

Name Type Description Default
ID str

The unique identifier of the Pix QR Code.

required

Returns:

Name Type Description
PixStatus PixStatus

The status of the Pix QR Code.

Source code in abacatepay/pixQrCode/client.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def check(self, id: str) -> PixStatus:
    """
    Get the status of a Pix QR Code.

    Args:
        ID (str): The unique identifier of the Pix QR Code.

    Returns:
        PixStatus: The status of the Pix QR Code.
    """
    logger.debug(f'Getting status for Pix QR Code ID: {id}')
    response = self._request(
        f'{BASE_URL}/pixQrCode/check?id={id}',
        method='GET',
    )
    return PixStatus.model_validate(response.json()['data'])

create(data, **kwargs)

Create a new Pix QR Code.

Parameters:

Name Type Description Default
amount int

The amount to be paid in cents.

required
expires_in int

The expiration time in seconds. Defaults to None.

required
description str

A description for the Pix QR Code. Defaults to None.

required
customer CustomerMetadata | dict

Customer information. Defaults to None.

required

Returns: PixQrCode: The created Pix QR Code object.

Source code in abacatepay/pixQrCode/client.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def create(self, data: PixQrCodeIn | dict[str, Any], **kwargs: Any) -> PixQrCode:
    """
    Create a new Pix QR Code.

    Args:
        amount (int): The amount to be paid in cents.
        expires_in (int, optional): The expiration time in seconds.
            Defaults to None.
        description (str, optional): A description for the Pix QR Code.
            Defaults to None.
        customer (CustomerMetadata | dict, optional): Customer information.
            Defaults to None.
    Returns:
        PixQrCode: The created Pix QR Code object.
    """
    json_data = prepare_data(data or kwargs, PixQrCodeIn)
    logger.debug('Creating Pix QR Code: %s', json_data)

    response = self._request(
        f'{BASE_URL}/pixQrCode/create',
        method='POST',
        json=json_data,
    )
    logger.debug('Pix QR Code created successfully: %s', response.json())
    return PixQrCode.model_validate(response.json()['data'])

simulate(id, metadata=None)

Simulate a Pix QR Code.

Parameters:

Name Type Description Default
id str

The unique identifier of the Pix QR Code.

required
metadata dict

Additional metadata for the simulation. Defaults to {}.

None

Returns:

Name Type Description
PixQrCode PixQrCode

The simulated Pix QR Code object.

Source code in abacatepay/pixQrCode/client.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
def simulate(self, id: str, metadata: dict[str, Any] | None = None) -> PixQrCode:
    """
    Simulate a Pix QR Code.

    Args:
        id (str): The unique identifier of the Pix QR Code.
        metadata (dict, optional): Additional metadata for the simulation.
            Defaults to {}.

    Returns:
        PixQrCode: The simulated Pix QR Code object.
    """
    logger.debug(f'Simulating Pix QR Code ID: {id}')
    response = self._request(
        f'{BASE_URL}/pixQrCode/simulate-payment?id={id}',
        method='POST',
        json=metadata or {},
    )
    return PixQrCode.model_validate(response.json()['data'])

PixQrCode

Bases: BaseModel

A representation of a Pix QRCode.

Attributes:

Name Type Description
id str

Unique identifier of the Pix QRCode.

amount int

Amount to be paid.

status str

Information about the status of the Pix QRCode.

dev_mode bool

Environment in which the Pix QRCode was created.

brcode str

Copy-and-paste code of the Pix QRCode.

brcode_base64 str

Base64 image of the Pix QRCode.

platform_fee int

Platform fees.

created_at str

Creation date of the Pix QRCode.

updated_at str

Update date of the Pix QRCode.

expires_at str

Expiration date of the Pix QRCode.

Source code in abacatepay/pixQrCode/models.py
 9
10
11
12
13
14
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
class PixQrCode(BaseModel):
    """
    A representation of a Pix QRCode.

    Attributes:
        id (str): Unique identifier of the Pix QRCode.
        amount (int): Amount to be paid.
        status (str): Information about the status of the Pix QRCode.
        dev_mode (bool): Environment in which the Pix QRCode was created.
        brcode (str): Copy-and-paste code of the Pix QRCode.
        brcode_base64 (str): Base64 image of the Pix QRCode.
        platform_fee (int): Platform fees.
        created_at (str): Creation date of the Pix QRCode.
        updated_at (str): Update date of the Pix QRCode.
        expires_at (str): Expiration date of the Pix QRCode.
    """

    id: str = Field(
        description='Unique identifier of the Pix QRCode.',
        examples=['pix_char_123456'],
    )
    amount: int = Field(description='Amount to be paid.', examples=[100])
    status: PIX_QR_CODE_STATUS = Field(
        description=(
            'Information about the status of the Pix QRCode.'
            'Options: PENDING, EXPIRED, CANCELLED, PAID, REFUNDED'
        ),
        examples=['PENDING'],
    )
    dev_mode: bool = Field(
        description='Environment in which the Pix QRCode was created.',
        examples=[True],
        validation_alias='devMode',
    )
    brcode: str = Field(
        description='Copy-and-paste code of the Pix QRCode.',
        examples=['00020101021226950014br.gov.bcb.pix'],
        validation_alias='brCode',
    )
    brcode_base64: str = Field(
        description='Base64 image of the Pix QRCode.',
        examples=['data:image/png;base64,iVBORw0KGgoAAA'],
        validation_alias='brCodeBase64',
    )
    platform_fee: int = Field(
        description='Platform fees.',
        examples=[80],
        validation_alias='platformFee',
    )
    created_at: str = Field(
        description='Creation date of the Pix QRCode.',
        examples=['2025-03-24T21:50:20.772Z'],
        validation_alias='createdAt',
    )
    updated_at: str = Field(
        description='Update date of the Pix QRCode.',
        examples=['2025-03-24T21:50:20.772Z'],
        validation_alias='updatedAt',
    )
    expires_at: str = Field(
        description='Expiration date of the Pix QRCode.',
        examples=['2025-03-25T21:50:20.772Z'],
        validation_alias='expiresAt',
    )

PixQrCodeIn

Bases: BaseModel

Represents a Pix QRCode model for creation.

Attributes:

Name Type Description
amount int

Amount to be paid in cents.

expires_in int | None

Expiration time in seconds. Defaults to None.

description str | None

A description for the Pix QR Code. Defaults to None.

customer dict[str, Any] | CustomerMetadata

Customer information. Optional.

Source code in abacatepay/pixQrCode/models.py
 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
class PixQrCodeIn(BaseModel):
    """Represents a Pix QRCode model for creation.

    Attributes:
        amount (int): Amount to be paid in cents.
        expires_in (int | None): Expiration time in seconds. Defaults to None.
        description (str | None): A description for the Pix QR Code. Defaults
            to None.
        customer (dict[str, Any] | CustomerMetadata): Customer information.
            Optional.
    """

    amount: int = Field(
        description='Amount to be paid in cents.',
        examples=[100],
    )
    expires_in: int | None = Field(
        None,
        description='Expiration time in seconds. Defaults to None.',
        examples=[3600],
    )
    description: str | None = Field(
        None,
        description='A description for the Pix QR Code. Defaults to None.',
        examples=['Payment for services'],
    )
    customer: dict[str, Any] | CustomerMetadata = Field(
        {}, description='Customer information. Optional.'
    )

PixStatus

Bases: BaseModel

Represents the status of a Pix QRCode.

Attributes:

Name Type Description
status str

Information about the status of the Pix QRCode.

expires_at str

Expiration date of the Pix QRCode.

Source code in abacatepay/pixQrCode/models.py
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
class PixStatus(BaseModel):
    """Represents the status of a Pix QRCode.

    Attributes:
        status (str): Information about the status of the Pix QRCode.
        expires_at (str): Expiration date of the Pix QRCode.
    """

    status: PIX_QR_CODE_STATUS = Field(
        description=(
            'Information about the status of the Pix QRCode. '
            'Options: PENDING, EXPIRED, CANCELLED, PAID, REFUNDED'
        ),
        examples=['PENDING'],
    )
    expires_at: str | None = Field(
        None,
        description='Expiration date of the Pix QRCode.',
        examples=['2025-03-25T21:50:20.772Z'],
    )