Adds support for stripe readers (#3678)
This commit is contained in:
parent
168cb726b1
commit
f0e8ae0f5c
1 changed files with 21 additions and 0 deletions
|
|
@ -35,6 +35,7 @@ class StripeTerminalOptions(BaseModel):
|
||||||
|
|
||||||
capture_method: Literal["automatic", "manual"] = "automatic"
|
capture_method: Literal["automatic", "manual"] = "automatic"
|
||||||
metadata: dict[str, str] = Field(default_factory=dict)
|
metadata: dict[str, str] = Field(default_factory=dict)
|
||||||
|
reader_id: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class StripeCheckoutOptions(BaseModel):
|
class StripeCheckoutOptions(BaseModel):
|
||||||
|
|
@ -295,6 +296,15 @@ class StripeWallet(FiatProvider):
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
|
async def _process_terminal_payment_intent(
|
||||||
|
self, reader_id: str, payment_intent_id: str
|
||||||
|
) -> None:
|
||||||
|
data = {"payment_intent": payment_intent_id}
|
||||||
|
r = await self.client.post(
|
||||||
|
f"/v1/terminal/readers/{reader_id}/process_payment_intent", data=data
|
||||||
|
)
|
||||||
|
r.raise_for_status()
|
||||||
|
|
||||||
async def _create_checkout_invoice(
|
async def _create_checkout_invoice(
|
||||||
self,
|
self,
|
||||||
amount_cents: int,
|
amount_cents: int,
|
||||||
|
|
@ -378,6 +388,17 @@ class StripeWallet(FiatProvider):
|
||||||
ok=False,
|
ok=False,
|
||||||
error_message="Error: missing PaymentIntent or client_secret",
|
error_message="Error: missing PaymentIntent or client_secret",
|
||||||
)
|
)
|
||||||
|
if term.reader_id:
|
||||||
|
try:
|
||||||
|
await self._process_terminal_payment_intent(term.reader_id, pi_id)
|
||||||
|
except Exception as exc:
|
||||||
|
logger.warning(exc)
|
||||||
|
return FiatInvoiceResponse(
|
||||||
|
ok=False,
|
||||||
|
error_message=(
|
||||||
|
"Error: unable to process PaymentIntent on reader"
|
||||||
|
),
|
||||||
|
)
|
||||||
return FiatInvoiceResponse(
|
return FiatInvoiceResponse(
|
||||||
ok=True, checking_id=pi_id, payment_request=client_secret
|
ok=True, checking_id=pi_id, payment_request=client_secret
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue