fix: remove customer_id
This commit is contained in:
@@ -95,10 +95,6 @@ class FiatSubscriptionPaymentOptions(BaseModel):
|
|||||||
description="Unique ID that can be used to identify the subscription request."
|
description="Unique ID that can be used to identify the subscription request."
|
||||||
"If not provided, one will be generated.",
|
"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(
|
customer_email: str | None = Field(
|
||||||
default=None,
|
default=None,
|
||||||
description="The customer email to use for the subscription.",
|
description="The customer email to use for the subscription.",
|
||||||
|
|||||||
@@ -372,16 +372,11 @@ class RevolutWallet(FiatProvider):
|
|||||||
async def _get_subscription_customer_id(
|
async def _get_subscription_customer_id(
|
||||||
self, payment_options: FiatSubscriptionPaymentOptions
|
self, payment_options: FiatSubscriptionPaymentOptions
|
||||||
) -> tuple[str | None, str | None]:
|
) -> tuple[str | None, str | None]:
|
||||||
if payment_options.customer_id:
|
|
||||||
return payment_options.customer_id, None
|
|
||||||
if not payment_options.customer_email:
|
if not payment_options.customer_email:
|
||||||
payment_options.customer_email = "test@lnbits.com"
|
return (
|
||||||
# TODO: Remove the above line and uncomment the
|
None,
|
||||||
# below return statement once we require customer_email for subscriptions.
|
"Revolut subscriptions require customer_email.",
|
||||||
# return (
|
)
|
||||||
# None,
|
|
||||||
# "Revolut subscriptions require customer_id or customer_email.",
|
|
||||||
# )
|
|
||||||
|
|
||||||
customer = await self._get_customer_by_email(payment_options.customer_email)
|
customer = await self._get_customer_by_email(payment_options.customer_email)
|
||||||
customer_id = customer.get("id") if customer else None
|
customer_id = customer.get("id") if customer else None
|
||||||
|
|||||||
@@ -876,6 +876,16 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
|
|||||||
wallet = RevolutWallet()
|
wallet = RevolutWallet()
|
||||||
client = MockHTTPClient(
|
client = MockHTTPClient(
|
||||||
[
|
[
|
||||||
|
MockHTTPResponse(
|
||||||
|
json_data={
|
||||||
|
"customers": [
|
||||||
|
{
|
||||||
|
"id": "CUSTOMER123",
|
||||||
|
"email": "customer@example.com",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
),
|
||||||
MockHTTPResponse(
|
MockHTTPResponse(
|
||||||
json_data={
|
json_data={
|
||||||
"id": "SUBSCRIPTION123",
|
"id": "SUBSCRIPTION123",
|
||||||
@@ -896,7 +906,7 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
|
|||||||
wallet_id="wallet_1",
|
wallet_id="wallet_1",
|
||||||
memo="Monthly Gold",
|
memo="Monthly Gold",
|
||||||
tag="gold",
|
tag="gold",
|
||||||
customer_id="CUSTOMER123",
|
customer_email="customer@example.com",
|
||||||
extra={"link": "link-1"},
|
extra={"link": "link-1"},
|
||||||
success_url="https://lnbits.example/subscription-success",
|
success_url="https://lnbits.example/subscription-success",
|
||||||
)
|
)
|
||||||
@@ -911,11 +921,14 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
|
|||||||
response.checkout_session_url
|
response.checkout_session_url
|
||||||
== "https://checkout.revolut.com/payment-link/sub_123"
|
== "https://checkout.revolut.com/payment-link/sub_123"
|
||||||
)
|
)
|
||||||
assert client.calls[0][0] == "/api/subscriptions"
|
assert client.calls[0][0] == "/api/customers"
|
||||||
payload = client.calls[0][1]["json"]
|
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["plan_variation_id"] == "PLAN_VARIATION_123"
|
||||||
assert payload["customer_id"] == "CUSTOMER123"
|
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"] == (
|
assert payload["setup_order_redirect_url"] == (
|
||||||
"https://lnbits.example/subscription-success"
|
"https://lnbits.example/subscription-success"
|
||||||
)
|
)
|
||||||
@@ -924,7 +937,7 @@ async def test_revolut_wallet_create_subscription(settings: Settings):
|
|||||||
assert reference["tag"] == "gold"
|
assert reference["tag"] == "gold"
|
||||||
assert reference["memo"] == "Monthly Gold"
|
assert reference["memo"] == "Monthly Gold"
|
||||||
assert reference["extra"]["link"] == "link-1"
|
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
|
@pytest.mark.anyio
|
||||||
|
|||||||
Reference in New Issue
Block a user