fix: remove customer_id

This commit is contained in:
Vlad Stan
2026-05-21 14:12:43 +03:00
parent 0c74adc494
commit 5b7f9fa255
3 changed files with 22 additions and 18 deletions
-4
View File
@@ -95,10 +95,6 @@ class FiatSubscriptionPaymentOptions(BaseModel):
description="Unique ID that can be used to identify the subscription request."
"If not provided, one will be generated.",
)
customer_id: str | None = Field(
default=None,
description="The fiat provider customer ID to use for the subscription.",
)
customer_email: str | None = Field(
default=None,
description="The customer email to use for the subscription.",
+4 -9
View File
@@ -372,16 +372,11 @@ class RevolutWallet(FiatProvider):
async def _get_subscription_customer_id(
self, payment_options: FiatSubscriptionPaymentOptions
) -> tuple[str | None, str | None]:
if payment_options.customer_id:
return payment_options.customer_id, None
if not payment_options.customer_email:
payment_options.customer_email = "test@lnbits.com"
# TODO: Remove the above line and uncomment the
# below return statement once we require customer_email for subscriptions.
# return (
# None,
# "Revolut subscriptions require customer_id or customer_email.",
# )
return (
None,
"Revolut subscriptions require customer_email.",
)
customer = await self._get_customer_by_email(payment_options.customer_email)
customer_id = customer.get("id") if customer else None
+18 -5
View File
@@ -876,6 +876,16 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
wallet = RevolutWallet()
client = MockHTTPClient(
[
MockHTTPResponse(
json_data={
"customers": [
{
"id": "CUSTOMER123",
"email": "customer@example.com",
}
]
}
),
MockHTTPResponse(
json_data={
"id": "SUBSCRIPTION123",
@@ -896,7 +906,7 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
wallet_id="wallet_1",
memo="Monthly Gold",
tag="gold",
customer_id="CUSTOMER123",
customer_email="customer@example.com",
extra={"link": "link-1"},
success_url="https://lnbits.example/subscription-success",
)
@@ -911,11 +921,14 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
response.checkout_session_url
== "https://checkout.revolut.com/payment-link/sub_123"
)
assert client.calls[0][0] == "/api/subscriptions"
payload = client.calls[0][1]["json"]
assert client.calls[0][0] == "/api/customers"
assert client.calls[0][1]["params"] == {"limit": 500}
assert client.calls[0][1]["timeout"] == 30
assert client.calls[1][0] == "/api/subscriptions"
payload = client.calls[1][1]["json"]
assert payload["plan_variation_id"] == "PLAN_VARIATION_123"
assert payload["customer_id"] == "CUSTOMER123"
assert client.calls[0][1]["timeout"] == 30
assert client.calls[1][1]["timeout"] == 30
assert payload["setup_order_redirect_url"] == (
"https://lnbits.example/subscription-success"
)
@@ -924,7 +937,7 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
assert reference["tag"] == "gold"
assert reference["memo"] == "Monthly Gold"
assert reference["extra"]["link"] == "link-1"
assert client.calls[1][0] == "/api/orders/ORDER123"
assert client.calls[2][0] == "/api/orders/ORDER123"
@pytest.mark.anyio