Skip to content

Commit 57dcc32

Browse files
committed
fixes payments
1 parent 01b33a5 commit 57dcc32

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

services/payments/src/simcore_service_payments/api/rest/_acknowledgements.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,23 @@ async def acknowledge_payment(
7777
)
7878

7979
if ack.saved:
80-
inserted = await payments_methods.insert_payment_method(
81-
repo=repo_methods,
82-
payment_method_id=ack.saved.payment_method_id,
83-
user_id=transaction.user_id,
84-
wallet_id=transaction.wallet_id,
85-
ack=ack.saved,
86-
)
87-
background_tasks.add_task(
88-
payments_methods.on_payment_method_completed,
89-
payment_method=inserted,
90-
notifier=notifier,
91-
)
80+
if ack.saved.payment_method_id is None:
81+
_logger.error("Failed to ") # failed to save create-card
82+
# TODO: notify failure to save !
83+
else:
84+
inserted = await payments_methods.insert_payment_method(
85+
repo=repo_methods,
86+
payment_method_id=ack.saved.payment_method_id,
87+
user_id=transaction.user_id,
88+
wallet_id=transaction.wallet_id,
89+
ack=ack.saved,
90+
)
91+
92+
background_tasks.add_task(
93+
payments_methods.on_payment_method_completed,
94+
payment_method=inserted,
95+
notifier=notifier,
96+
)
9297

9398

9499
@router.post("/payments-methods/{payment_method_id}:ack")

services/payments/src/simcore_service_payments/models/schemas/acknowledgements.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AckPaymentMethod(_BaseAck):
4242

4343

4444
class SavedPaymentMethod(AckPaymentMethod):
45-
payment_method_id: PaymentMethodID
45+
payment_method_id: PaymentMethodID | None = None
4646

4747

4848
#
@@ -83,11 +83,14 @@ class SavedPaymentMethod(AckPaymentMethod):
8383

8484
class AckPayment(_BaseAckPayment):
8585

86-
saved: SavedPaymentMethod | None = Field(
87-
default=None,
88-
description="Gets the payment-method if user opted to save it during payment."
89-
"If used did not opt to save of payment-method was already saved, then it defaults to None",
90-
)
86+
saved: Annotated[
87+
SavedPaymentMethod | None,
88+
Field(
89+
description="Gets the payment-method if user opted to save it during payment."
90+
"If used did not opt to save of payment-method was already saved, then it defaults to None",
91+
),
92+
] = None
93+
9194
model_config = ConfigDict(
9295
json_schema_extra={
9396
"example": _EXAMPLES[1].copy(), # shown in openapi.json

0 commit comments

Comments
 (0)