feat: use web page for cryptopay in web app
This commit is contained in:
@@ -2138,6 +2138,7 @@ async def _create_subscription_payment(
|
|||||||
amount=price,
|
amount=price,
|
||||||
description=description,
|
description=description,
|
||||||
sale_mode="subscription",
|
sale_mode="subscription",
|
||||||
|
url_kind="web",
|
||||||
)
|
)
|
||||||
if not url:
|
if not url:
|
||||||
return _json_error(502, "payment_failed", "Failed to create payment")
|
return _json_error(502, "payment_failed", "Failed to create payment")
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ class CryptoPayService:
|
|||||||
amount: float,
|
amount: float,
|
||||||
description: str,
|
description: str,
|
||||||
sale_mode: str = "subscription",
|
sale_mode: str = "subscription",
|
||||||
|
url_kind: str = "bot",
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
if not self.configured or not self.client:
|
if not self.configured or not self.client:
|
||||||
logging.error("CryptoPayService not configured")
|
logging.error("CryptoPayService not configured")
|
||||||
@@ -128,6 +129,12 @@ class CryptoPayService:
|
|||||||
payment_record.payment_id,
|
payment_record.payment_id,
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
if url_kind == "web":
|
||||||
|
return (
|
||||||
|
getattr(invoice, "web_app_invoice_url", None)
|
||||||
|
or getattr(invoice, "mini_app_invoice_url", None)
|
||||||
|
or invoice.bot_invoice_url
|
||||||
|
)
|
||||||
return invoice.bot_invoice_url
|
return invoice.bot_invoice_url
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("CryptoPay invoice creation failed.")
|
logging.exception("CryptoPay invoice creation failed.")
|
||||||
|
|||||||
Reference in New Issue
Block a user