aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2016-11-22 17:04:29 -0800
committerAdam Soltys <[email protected]>2016-12-26 14:22:39 -0800
commit69fe9bc5e29415e66e5463adb37d9524d7ac185a (patch)
tree562562000e31e2f4861c53681bca4bdc98b8f969
parent6101cbf5db17faa2c32d81fc28a3971fb3b98c12 (diff)
downloadcoinos-server-69fe9bc5e29415e66e5463adb37d9524d7ac185a.tar.gz
coinos-server-69fe9bc5e29415e66e5463adb37d9524d7ac185a.zip
Listen for testnet payments
-rw-r--r--public/js/calculator.coffee6
-rw-r--r--public/js/calculator.js11
-rw-r--r--routes/transactions.js2
-rw-r--r--src/routes/transactions.coffee2
-rw-r--r--views/transactions/notification.html4
5 files changed, 18 insertions, 7 deletions
diff --git a/public/js/calculator.coffee b/public/js/calculator.coffee
index 7d185f24..7dfb6186 100644
--- a/public/js/calculator.coffee
+++ b/public/js/calculator.coffee
@@ -1,6 +1,8 @@
EXCHANGE_FAIL = "Problem fetching exchange rate"
SOCKET_FAIL = "Problem connecting to payment server, notifications may not appear"
ADDRESS_FAIL = "Invalid address"
+API_URL = "wss://socket.blockcypher.com/v1/btc/main"
+TEST_URL = "wss://socket.blockcypher.com/v1/btc/test3"
g = exports ? this
g.errors = []
@@ -90,6 +92,8 @@ setup = ->
$('#logo').attr('src', src).show()
getAddress()
+ if g.user.address[0] is 'm'
+ API_URL = TEST_URL
$('.symbol').html(g.user.currency)
$('.currency').html(g.user.currency)
@@ -169,7 +173,7 @@ listen = ->
setTimeout(listen, 12000)
else
fail(SOCKET_FAIL) if g.attempts > 3
- g.blockchain = new WebSocket("wss://socket.blockcypher.com/v1/btc/main")
+ g.blockchain = new WebSocket(API_URL)
g.blockchain.onopen = ->
if g.blockchain.readyState is 1
diff --git a/public/js/calculator.js b/public/js/calculator.js
index 3a564034..c85c9bb3 100644
--- a/public/js/calculator.js
+++ b/public/js/calculator.js
@@ -1,5 +1,5 @@
(function() {
- var ADDRESS_FAIL, EXCHANGE_FAIL, SOCKET_FAIL, clear, fail, fetchExchangeRate, g, getAddress, listen, logTransaction, multiplier, setup, updateTotal;
+ var ADDRESS_FAIL, API_URL, EXCHANGE_FAIL, SOCKET_FAIL, TEST_URL, clear, fail, fetchExchangeRate, g, getAddress, listen, logTransaction, multiplier, setup, updateTotal;
EXCHANGE_FAIL = "Problem fetching exchange rate";
@@ -7,6 +7,10 @@
ADDRESS_FAIL = "Invalid address";
+ API_URL = "wss://socket.blockcypher.com/v1/btc/main";
+
+ TEST_URL = "wss://socket.blockcypher.com/v1/btc/test3";
+
g = typeof exports !== "undefined" && exports !== null ? exports : this;
g.errors = [];
@@ -96,6 +100,9 @@
$('#logo').attr('src', src).show();
}
getAddress();
+ if (g.user.address[0] === 'm') {
+ API_URL = TEST_URL;
+ }
$('.symbol').html(g.user.currency);
$('.currency').html(g.user.currency);
$('.unit').html(g.user.unit);
@@ -173,7 +180,7 @@
if (g.attempts > 3) {
fail(SOCKET_FAIL);
}
- g.blockchain = new WebSocket("wss://socket.blockcypher.com/v1/btc/main");
+ g.blockchain = new WebSocket(API_URL);
g.blockchain.onopen = function() {
if (g.blockchain.readyState === 1) {
g.attempts = 0;
diff --git a/routes/transactions.js b/routes/transactions.js
index 63e416e6..c6a86271 100644
--- a/routes/transactions.js
+++ b/routes/transactions.js
@@ -81,7 +81,7 @@
helper = require('sendgrid').mail;
from_email = new helper.Email('[email protected]');
to_email = new helper.Email(user.email);
- subject = 'Transaction Sent';
+ subject = 'Payment Received';
content = new helper.Content('text/html', html);
mail = new helper.Mail(from_email, subject, to_email, content);
sg = require('sendgrid')(config.sendgrid_token);
diff --git a/src/routes/transactions.coffee b/src/routes/transactions.coffee
index 70447901..2eca7766 100644
--- a/src/routes/transactions.coffee
+++ b/src/routes/transactions.coffee
@@ -59,7 +59,7 @@ module.exports =
helper = require('sendgrid').mail
from_email = new helper.Email('[email protected]')
to_email = new helper.Email(user.email)
- subject = 'Transaction Sent'
+ subject = 'Payment Received'
content = new helper.Content('text/html', html)
mail = new helper.Mail(from_email, subject, to_email, content)
diff --git a/views/transactions/notification.html b/views/transactions/notification.html
index 5f066cf8..3e6946a4 100644
--- a/views/transactions/notification.html
+++ b/views/transactions/notification.html
@@ -1,3 +1,3 @@
-<h1>Transaction Received</h1>
+<h1>Payment Received</h1>
-You received {{amount}} from {{address}}. Visit <a href="https://blockchain.info/tx/{{txid}}">https://blockchain.info/tx/{{txid}}</a> for more details.
+You received {{amount}} from {{address}}. <a href="https://blockchain.info/tx/{{txid}}">Click here</a> for more details.