Compare commits
10 commits
89145b39cd
...
c2e8fca613
| Author | SHA1 | Date | |
|---|---|---|---|
| c2e8fca613 | |||
| 94b8ea5f48 | |||
| 8d9768aeff | |||
| 0d28d221cd | |||
| 2287ea7440 | |||
| 9252c86f5c | |||
| 22ad5fd974 | |||
| 8b91c7bd72 | |||
| 396b012707 | |||
| 1fcffac670 |
1 changed files with 3 additions and 12 deletions
|
|
@ -236,8 +236,7 @@ export function useCheckout(): UseCheckoutReturn {
|
||||||
|
|
||||||
async function payBolt11Raw(
|
async function payBolt11Raw(
|
||||||
bolt11: string,
|
bolt11: string,
|
||||||
adminkey: string,
|
adminkey: string
|
||||||
extra?: Record<string, unknown>
|
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const response = await fetch(`${apiBaseUrl}/api/v1/payments`, {
|
const response = await fetch(`${apiBaseUrl}/api/v1/payments`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
@ -245,7 +244,7 @@ export function useCheckout(): UseCheckoutReturn {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'X-Api-Key': adminkey,
|
'X-Api-Key': adminkey,
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ out: true, bolt11, ...(extra ? { extra } : {}) }),
|
body: JSON.stringify({ out: true, bolt11 }),
|
||||||
})
|
})
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
let detail = response.statusText
|
let detail = response.statusText
|
||||||
|
|
@ -273,15 +272,7 @@ export function useCheckout(): UseCheckoutReturn {
|
||||||
state.value.step = 'paying'
|
state.value.step = 'paying'
|
||||||
state.value.currentRestaurantSlug = placed.restaurantSlug
|
state.value.currentRestaurantSlug = placed.restaurantSlug
|
||||||
try {
|
try {
|
||||||
// Tag the outgoing payment so the customer's wallet history
|
await payBolt11Raw(placed.invoice.bolt11, adminkey)
|
||||||
// can later surface it as a restaurant order. Mirrors the
|
|
||||||
// `extra={"tag": "restaurant", ...}` the extension stamps on
|
|
||||||
// its incoming invoice.
|
|
||||||
await payBolt11Raw(placed.invoice.bolt11, adminkey, {
|
|
||||||
tag: 'restaurant',
|
|
||||||
restaurant_id: placed.restaurantId,
|
|
||||||
order_id: placed.order.id,
|
|
||||||
})
|
|
||||||
// Set semantics keeps `paidOrderIds` from re-renders; rebuild
|
// Set semantics keeps `paidOrderIds` from re-renders; rebuild
|
||||||
// it on update so Vue picks up the change.
|
// it on update so Vue picks up the change.
|
||||||
state.value.paidOrderIds = new Set([
|
state.value.paidOrderIds = new Set([
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue