Tested, fixed
This commit is contained in:
parent
4c6a2f3dc7
commit
54e59a6fa6
|
@ -57,12 +57,12 @@ const emptyCart = () => {
|
|||
}); recountCart()
|
||||
}
|
||||
|
||||
const cancel = () => {
|
||||
fetch(
|
||||
const cancel = async () => {
|
||||
let res; try { res = await fetch(
|
||||
`${API_DOMAIN}/order/${qstr.id}?key=${qstr.key}`,
|
||||
{ method:'DELETE' }
|
||||
)
|
||||
window.location = '/shop/cart/'
|
||||
) } catch (err) { console.error(err) }
|
||||
finally { window.location = '/shop/cart/' }
|
||||
}
|
||||
|
||||
let xmr_price = 160 // For getting fees in USD before the first price loads
|
||||
|
@ -137,9 +137,12 @@ class Checkout { constructor(data) {
|
|||
self.paidDate().toDateString()
|
||||
)
|
||||
self.isPaidUSD = ko.observable(false)
|
||||
self.isPaidXMR = ko.pureComputed(() =>
|
||||
( (self.paymentMethod()==='XMR') &&
|
||||
( self.unlocked() >= self.totalxmr() ) )
|
||||
)
|
||||
self.isPaid = ko.pureComputed(() =>
|
||||
(self.isPaidUSD() || // USD paid
|
||||
( self.unlocked() >= self.totalxmr() )) // XMR paid
|
||||
(self.isPaidUSD() || self.isPaidXMR())
|
||||
)
|
||||
self.isOverpaid = ko.pureComputed( () =>
|
||||
( self.submitted() > self.totalxmr() )
|
||||
|
@ -184,7 +187,7 @@ class Checkout { constructor(data) {
|
|||
)
|
||||
self.tracking_url = ko.pureComputed(() => {
|
||||
if (self.shipCarrier()==='USPS')
|
||||
return `https://tools.usps.com/go/TrackConfirmAction?tLabels=${self.trackingNumbers.join('%2C')}%2C`
|
||||
return `https://tools.usps.com/go/TrackConfirmAction?tLabels=${self.trackingNumbers().join('%2C')}%2C`
|
||||
else return ''
|
||||
})
|
||||
self.isShipped = ko.pureComputed(() =>
|
||||
|
|
|
@ -157,10 +157,8 @@ title: Order
|
|||
<hr>
|
||||
<h2>📦 Shipment</h2>
|
||||
<p data-bind="hidden:isShipped">Your order has not yet shipped. We will email you a tracking number when it goes out. You can also check back here for updates.</p>
|
||||
<p data-bind="visible:isShipped">Your order was shipped through <span data-bind="text:shipCarrier"></span> on <span data-bind="text:shipDate_pretty"></span>. You can <a data-bind="attr:{href:tracking_url}">track your package through <span data-bind="shipCarrier"></span></a> or copy-paste the tracking number below.</p>
|
||||
<pre data-bind="visible:isShipped">
|
||||
<code data-bind="text:trackingNumbers_newlined"></code>
|
||||
</pre>
|
||||
<p data-bind="visible:isShipped">Your order was shipped through <span data-bind="text:shipCarrier"></span> on <span data-bind="text:shipDate_pretty"></span>. You can <a data-bind="attr:{href:tracking_url}">track your package through <span data-bind="text:shipCarrier"></span></a> or copy-paste the tracking number below.</p>
|
||||
<pre data-bind="visible:isShipped"><code data-bind="text:trackingNumbers_newlined"></code></pre>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
|
12
api/index.js
12
api/index.js
|
@ -4,7 +4,7 @@ const {json} = require('express')
|
|||
const express = require('express')
|
||||
const CORS_OPTIONS = {
|
||||
'origin': process.env.SITE_DOMAIN,
|
||||
'methods': 'GET,POST,OPTIONS',
|
||||
'methods': 'GET,POST,OPTIONS,DELETE',
|
||||
}
|
||||
const cors = require('cors')(CORS_OPTIONS)
|
||||
const jsonBodyParser = express.json()
|
||||
|
@ -21,13 +21,13 @@ httpServer.listen(Number(process.env.API_PORT))
|
|||
app.get('/', (req, res) => res.sendStatus(200))
|
||||
|
||||
// Create new order
|
||||
app.options('/order', cors)
|
||||
.post('/order', jsonBodyParser, cors, require('./order-add'))
|
||||
app.route('/order').options(cors)
|
||||
.post(jsonBodyParser, cors, require('./order-add'))
|
||||
|
||||
// Get or delete an order
|
||||
app.options('/order/:orderid', cors)
|
||||
.get('/order/:orderid', cors, require('./order-get'))
|
||||
.delete('/order/:orderid', cors, require('./order-del'))
|
||||
app.route('/order/:orderid').options(cors)
|
||||
.get(cors, require('./order-get'))
|
||||
.delete(cors, require('./order-del'))
|
||||
|
||||
// XMR transactions polling (just proxying it to moneropay)
|
||||
app.get('/xmr-receive/:addr', cors, async (req, res) => {
|
||||
|
|
|
@ -40,6 +40,7 @@ const xmrPaidCheck = async (order) => {
|
|||
order.paidDate = new Date()
|
||||
order.xmr_txs = res.data.transactions.map((tx) => {
|
||||
tx.fee_usd = xmrToUsd(tx.fee)
|
||||
return tx
|
||||
})
|
||||
const orderFile = `${ORDERS_DIR}/${order.id}.json`
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue