Instantly share code, notes, and snippets.

Embed
What would you like to do?
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