Skip to content

Instantly share code, notes, and snippets.

@owenkellogg
Last active August 29, 2015 14:12
Show Gist options
  • Save owenkellogg/631d90e895497419fde8 to your computer and use it in GitHub Desktop.
Save owenkellogg/631d90e895497419fde8 to your computer and use it in GitHub Desktop.
Gatewayd Protocol Outbound External

Gatewayd Protocol Outbound External

Purpose: To discover the interface for Gateway Services Protocol to be extended per a given use case

In gatewaydfile.js:

module.exports = function(gatewayd) {

  gatewayd.protocol.external.outbound.extend({
  
    quote: function(options, resolve, reject) {
    
      if (gatewayd.validator.isEmail(address)) {
        if (options.currency === 'BTC') {
          if (options.amount <= 0.1) {
            resolve({
              destination: options.destination,
              amount: options.amount * 1.01,
              currency: options.currency
            });
          } else {
            reject(new Error('amount must be less than 0.1'));
          }
        } else {
          reject(new Error('currency must be BTC'));
        }
      } else {
        reject(new Error('address must be email'));
      }
    }
  });
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment