Skip to content

Instantly share code, notes, and snippets.

@ice09
Created September 3, 2014 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ice09/2f1aa773893a13f25e0a to your computer and use it in GitHub Desktop.
Save ice09/2f1aa773893a13f25e0a to your computer and use it in GitHub Desktop.
// Ripple account to watch for payment
var acct = 'rDPe2PCQtxngg5euANuGiL9o9XEsNfim2g'
// API key for Mailgun
var api_key = 'key-';
// Subdomain for Mailgun
var domain = 'domain.mailgun.org';
// create Mailgun
var Mailgun = require('mailgun-js');
var mailgun = new Mailgun({apiKey: api_key, domain: domain});
// create Ribble lib
var Remote = require('ripple-lib').Remote;
var remote = new Remote({
servers: [ 'wss://s1.ripple.com:443' ]
});
remote.connect(function() {
// listen for transaction_all events
remote.on('transaction_all', function on(transaction) {
var trx = transaction.transaction
if (trx.Destination) {
console.log(trx.Account + " ==> " + trx.Destination + " [" + trx.Amount + "]")
if (trx.Destination == acct) {
var data = {
from: 'XRP Watcher',
to: 'me@web.de',
subject: 'XRP received',
text: 'You received ' + trx.Amount + ' from Account ' + trx.Account
}
mailgun.messages().send(data, function (error, body) {
console.log(body);
});
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment