feat: show failed order error message
This commit is contained in:
parent
b6b86f5a02
commit
93e362530b
3 changed files with 14 additions and 5 deletions
|
|
@ -309,6 +309,7 @@ class OrderExtra(BaseModel):
|
||||||
btc_price: str
|
btc_price: str
|
||||||
shipping_cost: float = 0
|
shipping_cost: float = 0
|
||||||
shipping_cost_sat: float = 0
|
shipping_cost_sat: float = 0
|
||||||
|
fail_message: Optional[str]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def from_products(cls, products: List[Product]):
|
async def from_products(cls, products: List[Product]):
|
||||||
|
|
|
||||||
10
services.py
10
services.py
|
|
@ -260,7 +260,7 @@ async def compute_products_new_quantity(
|
||||||
return (
|
return (
|
||||||
False,
|
False,
|
||||||
[],
|
[],
|
||||||
f"Quantity not sufficient for product: {p.id}. Required {required_quantity} but only have {p.quantity}",
|
f"Quantity not sufficient for product: '{p.name}' ({p.id}). Required '{required_quantity}' but only have '{p.quantity}'.",
|
||||||
)
|
)
|
||||||
|
|
||||||
p.quantity -= required_quantity
|
p.quantity -= required_quantity
|
||||||
|
|
@ -437,10 +437,9 @@ async def _handle_incoming_structured_dm(
|
||||||
|
|
||||||
return DirectMessageType.PAYMENT_REQUEST, json_resp
|
return DirectMessageType.PAYMENT_REQUEST, json_resp
|
||||||
|
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
logger.warning(ex)
|
logger.warning(ex)
|
||||||
|
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -538,13 +537,14 @@ async def create_new_failed_order(
|
||||||
merchant_public_key: str,
|
merchant_public_key: str,
|
||||||
dm: DirectMessage,
|
dm: DirectMessage,
|
||||||
json_data: dict,
|
json_data: dict,
|
||||||
failed_message: str,
|
fail_message: str,
|
||||||
) -> PaymentRequest:
|
) -> PaymentRequest:
|
||||||
order = await extract_customer_order_from_dm(
|
order = await extract_customer_order_from_dm(
|
||||||
merchant_id, merchant_public_key, dm, json_data
|
merchant_id, merchant_public_key, dm, json_data
|
||||||
)
|
)
|
||||||
|
order.extra.fail_message = fail_message
|
||||||
await create_order(merchant_id, order)
|
await create_order(merchant_id, order)
|
||||||
return PaymentRequest(id=order.id, message=failed_message, payment_options=[])
|
return PaymentRequest(id=order.id, message=fail_message, payment_options=[])
|
||||||
|
|
||||||
|
|
||||||
async def _handle_new_customer(event, merchant: Merchant):
|
async def _handle_new_customer(event, merchant: Merchant):
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,14 @@
|
||||||
<div class="col-3 col-sm-1"></div>
|
<div class="col-3 col-sm-1"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="props.row.extra.fail_message" class="row items-center no-wrap q-mb-md">
|
||||||
|
<div class="col-3 q-pr-lg">Error:</div>
|
||||||
|
<div class="col-6 col-sm-8 q-pr-lg">
|
||||||
|
<q-badge color="pink"><span v-text="props.row.extra.fail_message"></span></q-badge>
|
||||||
|
</div>
|
||||||
|
<div class="col-3 col-sm-1"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row items-center no-wrap q-mb-md">
|
<div class="row items-center no-wrap q-mb-md">
|
||||||
<div class="col-3 q-pr-lg">Address:</div>
|
<div class="col-3 q-pr-lg">Address:</div>
|
||||||
<div class="col-6 col-sm-8 q-pr-lg">
|
<div class="col-6 col-sm-8 q-pr-lg">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue