Tested, fixed
This commit is contained in:
parent
4c6a2f3dc7
commit
54e59a6fa6
|
@ -57,12 +57,12 @@ const emptyCart = () => {
|
||||||
}); recountCart()
|
}); recountCart()
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = async () => {
|
||||||
fetch(
|
let res; try { res = await fetch(
|
||||||
`${API_DOMAIN}/order/${qstr.id}?key=${qstr.key}`,
|
`${API_DOMAIN}/order/${qstr.id}?key=${qstr.key}`,
|
||||||
{ method:'DELETE' }
|
{ method:'DELETE' }
|
||||||
)
|
) } catch (err) { console.error(err) }
|
||||||
window.location = '/shop/cart/'
|
finally { window.location = '/shop/cart/' }
|
||||||
}
|
}
|
||||||
|
|
||||||
let xmr_price = 160 // For getting fees in USD before the first price loads
|
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.paidDate().toDateString()
|
||||||
)
|
)
|
||||||
self.isPaidUSD = ko.observable(false)
|
self.isPaidUSD = ko.observable(false)
|
||||||
|
self.isPaidXMR = ko.pureComputed(() =>
|
||||||
|
( (self.paymentMethod()==='XMR') &&
|
||||||
|
( self.unlocked() >= self.totalxmr() ) )
|
||||||
|
)
|
||||||
self.isPaid = ko.pureComputed(() =>
|
self.isPaid = ko.pureComputed(() =>
|
||||||
(self.isPaidUSD() || // USD paid
|
(self.isPaidUSD() || self.isPaidXMR())
|
||||||
( self.unlocked() >= self.totalxmr() )) // XMR paid
|
|
||||||
)
|
)
|
||||||
self.isOverpaid = ko.pureComputed( () =>
|
self.isOverpaid = ko.pureComputed( () =>
|
||||||
( self.submitted() > self.totalxmr() )
|
( self.submitted() > self.totalxmr() )
|
||||||
|
@ -184,7 +187,7 @@ class Checkout { constructor(data) {
|
||||||
)
|
)
|
||||||
self.tracking_url = ko.pureComputed(() => {
|
self.tracking_url = ko.pureComputed(() => {
|
||||||
if (self.shipCarrier()==='USPS')
|
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 ''
|
else return ''
|
||||||
})
|
})
|
||||||
self.isShipped = ko.pureComputed(() =>
|
self.isShipped = ko.pureComputed(() =>
|
||||||
|
|
|
@ -157,10 +157,8 @@ title: Order
|
||||||
<hr>
|
<hr>
|
||||||
<h2>📦 Shipment</h2>
|
<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="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>
|
<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">
|
<pre data-bind="visible:isShipped"><code data-bind="text:trackingNumbers_newlined"></code></pre>
|
||||||
<code data-bind="text:trackingNumbers_newlined"></code>
|
|
||||||
</pre>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
12
api/index.js
12
api/index.js
|
@ -4,7 +4,7 @@ const {json} = require('express')
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const CORS_OPTIONS = {
|
const CORS_OPTIONS = {
|
||||||
'origin': process.env.SITE_DOMAIN,
|
'origin': process.env.SITE_DOMAIN,
|
||||||
'methods': 'GET,POST,OPTIONS',
|
'methods': 'GET,POST,OPTIONS,DELETE',
|
||||||
}
|
}
|
||||||
const cors = require('cors')(CORS_OPTIONS)
|
const cors = require('cors')(CORS_OPTIONS)
|
||||||
const jsonBodyParser = express.json()
|
const jsonBodyParser = express.json()
|
||||||
|
@ -21,13 +21,13 @@ httpServer.listen(Number(process.env.API_PORT))
|
||||||
app.get('/', (req, res) => res.sendStatus(200))
|
app.get('/', (req, res) => res.sendStatus(200))
|
||||||
|
|
||||||
// Create new order
|
// Create new order
|
||||||
app.options('/order', cors)
|
app.route('/order').options(cors)
|
||||||
.post('/order', jsonBodyParser, cors, require('./order-add'))
|
.post(jsonBodyParser, cors, require('./order-add'))
|
||||||
|
|
||||||
// Get or delete an order
|
// Get or delete an order
|
||||||
app.options('/order/:orderid', cors)
|
app.route('/order/:orderid').options(cors)
|
||||||
.get('/order/:orderid', cors, require('./order-get'))
|
.get(cors, require('./order-get'))
|
||||||
.delete('/order/:orderid', cors, require('./order-del'))
|
.delete(cors, require('./order-del'))
|
||||||
|
|
||||||
// XMR transactions polling (just proxying it to moneropay)
|
// XMR transactions polling (just proxying it to moneropay)
|
||||||
app.get('/xmr-receive/:addr', cors, async (req, res) => {
|
app.get('/xmr-receive/:addr', cors, async (req, res) => {
|
||||||
|
|
|
@ -40,6 +40,7 @@ const xmrPaidCheck = async (order) => {
|
||||||
order.paidDate = new Date()
|
order.paidDate = new Date()
|
||||||
order.xmr_txs = res.data.transactions.map((tx) => {
|
order.xmr_txs = res.data.transactions.map((tx) => {
|
||||||
tx.fee_usd = xmrToUsd(tx.fee)
|
tx.fee_usd = xmrToUsd(tx.fee)
|
||||||
|
return tx
|
||||||
})
|
})
|
||||||
const orderFile = `${ORDERS_DIR}/${order.id}.json`
|
const orderFile = `${ORDERS_DIR}/${order.id}.json`
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue