fix: honor PayKilla invoice currency
This commit is contained in:
@@ -396,7 +396,7 @@ class PaykillaService(HttpClientMixin):
|
||||
|
||||
@property
|
||||
def currency(self) -> str:
|
||||
return (self.config.CURRENCY or "RUB").upper()
|
||||
return normalize_payment_currency_code(self.config.CURRENCY or "RUB")
|
||||
|
||||
@property
|
||||
def verify_webhook_signature(self) -> bool:
|
||||
@@ -416,7 +416,7 @@ class PaykillaService(HttpClientMixin):
|
||||
currency: Optional[str],
|
||||
description: str,
|
||||
) -> Dict[str, Any]:
|
||||
currency_code = normalize_payment_currency_code(currency or self.currency)
|
||||
currency_code = self.currency
|
||||
invoice_text = _invoice_text(getattr(self.settings, "WEBAPP_TITLE", None), payment_db_id)
|
||||
body: Dict[str, Any] = {
|
||||
"type": _invoice_type_for(self.config, currency_code),
|
||||
@@ -449,7 +449,8 @@ class PaykillaService(HttpClientMixin):
|
||||
logging.error("PaykillaService is not configured. Cannot create payment link.")
|
||||
return False, {"message": "service_not_configured"}
|
||||
|
||||
currency_code = normalize_payment_currency_code(currency or self.currency)
|
||||
payment_currency = normalize_payment_currency_code(currency or self.currency)
|
||||
currency_code = self.currency
|
||||
supported = parse_supported_currency_codes(self.config.SUPPORTED_CURRENCIES)
|
||||
if supported and currency_code not in supported:
|
||||
return False, {
|
||||
@@ -457,6 +458,13 @@ class PaykillaService(HttpClientMixin):
|
||||
"currency": currency_code,
|
||||
"supported_currencies": list(supported),
|
||||
}
|
||||
if payment_currency and payment_currency != currency_code:
|
||||
logging.info(
|
||||
"Paykilla create_payment_link: using configured invoice currency %s "
|
||||
"instead of payment record currency %s; amount is sent unchanged.",
|
||||
currency_code,
|
||||
payment_currency,
|
||||
)
|
||||
|
||||
body = self._invoice_body(
|
||||
payment_db_id=payment_db_id,
|
||||
@@ -986,7 +994,8 @@ _CONFIG_MANIFEST = (
|
||||
"string",
|
||||
"Invoice currency",
|
||||
description=(
|
||||
"Fiat or crypto invoice currency. FIAT_BASED is selected for RUB/USD/EUR/AED/GBP."
|
||||
"PayKilla invoice currency. Amount is sent unchanged, so keep tariffs "
|
||||
"priced in this currency or use a PayKilla-enabled fiat such as USD."
|
||||
),
|
||||
placeholder="RUB",
|
||||
subsection="PayKilla",
|
||||
|
||||
Reference in New Issue
Block a user