Pular para conteúdo

Customers reference

PixQrCodeClient

Bases: BaseClient

Source code in abacatepay/pixQrCode/client.py
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
class PixQrCodeClient(BaseClient):
  def create(self, data: Union[PixQrCodeIn, dict], **kwargs) -> 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:Optional[dict] = {}) -> 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,
        )
        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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def create(self, data: Union[PixQrCodeIn, dict], **kwargs) -> 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={})

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 {}.

{}

Returns:

Name Type Description
PixQrCode PixQrCode

The simulated Pix QR Code object.

Source code in abacatepay/pixQrCode/client.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def simulate(self, id: str, metadata:Optional[dict] = {}) -> 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,
      )
      return PixQrCode.model_validate(response.json()["data"])