Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions barte/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,6 @@ def create_card_token(self, card_data: Dict[str, Any]) -> CardToken:
data_class=CardToken, data=response.json(), config=DACITE_CONFIG
)

def create_pix_charge(self, data: Dict[str, Any]) -> PixCharge:
"""Create a PIX charge"""
endpoint = f"{self.base_url}/v1/charges"

pix_data = {**data, "payment_method": "pix"}

response = requests.post(endpoint, headers=self.headers, json=pix_data)
response.raise_for_status()
return from_dict(
data_class=PixCharge, data=response.json(), config=DACITE_CONFIG
)

def get_pix_qrcode(self, charge_id: str) -> PixCharge:
"""Get PIX QR Code data for a charge"""
endpoint = f"{self.base_url}/v2/charges/{charge_id}"
Expand Down
30 changes: 0 additions & 30 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,36 +207,6 @@ def test_create_order(self, mock_post, barte_client, mock_order_response):
json=order_data,
)

@patch("requests.post")
def test_create_pix_charge(self, mock_post, barte_client, mock_pix_charge_response):
"""Test creating a PIX charge"""
mock_post.return_value.json.return_value = mock_pix_charge_response
mock_post.return_value.raise_for_status = Mock()

pix_data = {
"amount": 3,
"description": "PIX Test",
"customer": {
"name": "John Doe",
"tax_id": "123.456.789-00",
"email": "john@example.com",
},
}

charge = barte_client.create_pix_charge(pix_data)

assert isinstance(charge, PixCharge)
assert charge.paymentMethod == "PIX"
assert charge.value == 3
assert charge.customer.name == "John Doe"

expected_data = {**pix_data, "payment_method": "pix"}
mock_post.assert_called_once_with(
f"{barte_client.base_url}/v1/charges",
headers=barte_client.headers,
json=expected_data,
)

@patch("requests.post")
def test_create_card_token(self, mock_post, barte_client):
"""Test creating a card token"""
Expand Down