tempest_fastapi_sdk.integrations.payment.settlement¶
Confirmar um Pix no provedor antes de liberar qualquer coisa.
confirm_pix_payment
async
¶
confirm_pix_payment(
provider: PixProvider, charge_id: str, *, reference: str, amount_cents: int
) -> PixPaymentConfirmation
Re-read a charge and check it pays this order, in full.
Pass the charge id the service stored when it opened the charge, not the one a webhook delivery names: the delivery is only the trigger to look, so a forged or replayed one can at most make the service ask the provider about a charge it already owns.
The amount must match exactly. A charge that settled for another amount — a different charge, or one whose value the provider adjusted — is a decision for the service, not something to release silently at the wrong price.
Nothing is written. Release the order under
:func:~tempest_fastapi_sdk.wallet.claim_once when this returns
:attr:PixPaymentConfirmation.paid, so the same paid charge confirmed
twice — a webhook retry, a reconciliation sweep — releases once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
PixProvider
|
Any provider that implements the contract. |
required |
charge_id
|
str
|
The stored
:attr: |
required |
reference
|
str
|
The order's reference, sent as
:attr: |
required |
amount_cents
|
int
|
What the order costs, in cents. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PixPaymentConfirmation |
PixPaymentConfirmation
|
The outcome and the charge as read. |
Raises:
| Type | Description |
|---|---|
Exception
|
Whatever the provider's |
PixPaymentConfirmation
¶
Bases: _EnumSafeSchema
The result of re-reading a charge against what the order expects.
Attributes:
| Name | Type | Description |
|---|---|---|
outcome |
PixConfirmationOutcomeEnum
|
Which check decided the result. |
charge |
PixCharge
|
The charge as the provider reported it on this read — not the copy that arrived in the webhook. |
expected_reference |
str
|
The order reference the charge had to carry. |
expected_amount_cents |
int
|
The amount, in cents, the charge had to carry. |
paid
property
¶
Whether the confirmation authorizes releasing the order.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
PixConfirmationOutcomeEnum
¶
Bases: BaseStrEnum
Why a re-read charge does or does not authorize releasing an order.
The checks run in this order, and the first one that fails names the
outcome: a charge for another order is reported as
:attr:REFERENCE_MISMATCH even if it is also unpaid.
Attributes:
| Name | Type | Description |
|---|---|---|
PAID |
str
|
The charge belongs to the order, is paid, and carries the order's amount. The only outcome that authorizes release. |
REFERENCE_MISMATCH |
str
|
The charge's |
NOT_PAID |
str
|
The provider does not report the charge as
:attr: |
AMOUNT_MISMATCH |
str
|
Paid, but not the amount the order costs. |