diff --git a/pay.js b/pay.js index 9903023..b38e195 100644 --- a/pay.js +++ b/pay.js @@ -1,4 +1,4 @@ -// NanoPay 1.1.9 +// NanoPay 1.2.0 // March 18, 2024 // https://github.com/fwd/NanoPay // (c) @nano2dev @@ -563,7 +563,7 @@ var position = config.position || 'bottom' var button = config.button || 'Open' var symbol = config.symbol || 'NANO' - var description = config.description || config.text || config.note || config.memo || 'AMOUNT' + var description = config.description || config.text || config.note || config.memo || 'Total' var address = config.address var amount = config.amount ? Number(config.amount) : undefined var random = config.random || config.random === false || config.random === "false" ? config.random : true @@ -720,12 +720,12 @@ } else { - if (!address) { + if (!address && !node) { show_loading(false) return alert("NanoPay: Address or Username required.") } - if (line_items) { + if (line_items && !node) { if (!Array.isArray(line_items) || line_items && !line_items.find(a => a && a.price)) { show_loading(false) return alert("NanoPay: Invalid line_items. Example: [ { name: 'T-Shirt', price: 5 } ] ") @@ -733,7 +733,7 @@ description = original_config.description || 'Amount' } - rpc_checkout = (await RPC.post(node, { + rpc_checkout = (await RPC.post(node, { action: "checkout", line_items, shipping: Number(config.shipping) ? config.shipping : undefined, @@ -746,6 +746,13 @@ public_key })) + if (rpc_checkout.shipping) { + config.contact = true + config.shipping = rpc_checkout.shipping + } + if (rpc_checkout.title) config.title = rpc_checkout.title + if (rpc_checkout.line_items) config.line_items = rpc_checkout.line_items + } } @@ -777,7 +784,7 @@ #nano-pay-header { display: flex; align-items: center; } #nano-pay-header > svg { max-width: 22px; height: 22px } - #nano-pay-header > span { display: block;margin-left: 4px;font-size: 106%; } + #nano-pay-header > span { display: block;margin-left: 7px;font-size: 106%; } #nano-pay-header-container { box-sizing: border-box; width: 100%;display: flex;align-items: center;justify-content: space-between;padding: 14px;border-bottom: 1px solid ${ window.NanoPay.dark_mode ? '#ffffff08' : '#0000000f' }; } #nano-pay-cancel { color: #1f9ce9 } @@ -934,30 +941,30 @@ -
+
${strings.shipping}
${window.NanoPay.config.mailing_address && window.NanoPay.config.mailing_address.first_name ? fullAddress(window.NanoPay.config.mailing_address) : strings.shipping_placeholder}
-
+
-
${strings.subtotal}
-
${strings.shipping}
-
+
${strings.subtotal}
+
${strings.shipping}
+
${description}
-
${rpc_checkout.subtotal} ${symbol}
-
${rpc_checkout.shipping ? rpc_checkout.shipping + ' ' + symbol : 'FREE'}
-
+
${rpc_checkout.subtotal} ${symbol}
+
${rpc_checkout.shipping ? rpc_checkout.shipping + ' ' + symbol : 'FREE'}
+
${rpc_checkout.amount} ${symbol}
-
+
${strings.description || 'Amount'}
${strings.service_fee}