Skip to content

Instantly share code, notes, and snippets.

@owenkellogg
Created December 15, 2014 19:55
Show Gist options
  • Save owenkellogg/7557b85a07f0d31ced47 to your computer and use it in GitHub Desktop.
Save owenkellogg/7557b85a07f0d31ced47 to your computer and use it in GitHub Desktop.
bridge_services_lib.js
var Service = require('bridge-quote-service')
var RipplePaymentQuote = Service.RipplePaymentQuote
var ExternalPaymentQuote = Service.ExternalPaymentQuote
var BridgeQuote = Service.BridgeQuote
var RippleQuote = RipplePaymentQuote.extend({
authorize: function(payment) {
if (payment.to_currency !== 'XRP') {
this.reject('Destination Currency Must be XRP')
}
},
inbound: {
source: {
address: 'r4EwBWxrx5HxYRyisfGzMto3AT8FZiYdWk'
}
},
outbound: {
destination: {
address: 'r4EwBWxrx5HxYRyisfGzMto3AT8FZiYdWk'
}
},
rippleRest: 'https://api.ripple.com'
})
var ExternalQuote = ExternalPaymentQuote.extend({
build: function(payment) {
this.resolve(payment)
}
})
var BridgeQuote = BridgeQuote.extend({
ripple: RippleQuote,
external: ExternalQuote
})
var bridgeQuote = new BridgeQuote({
direction: 'from-ripple'
ripple: {
source: {
address: 'r4EwBWxrx5HxYRyisfGzMto3AT8FZiYdWk'
}
},
external: {
destination: {
account: {
name: 'me@stevenzeiler.com'
},
amount: {
currency: 'BTC',
value : 15.2
}
}
}
})
bridgeQuote.fetch().then(function(quote) {
console.log(quote)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment