Log in with Ripple

  
  function Strategy(options, verify) {
  options = options || {};
  options.authorizationURL = options.authorizationURL || 'https://id.ripple.com/dialog/authorize';
  options.tokenURL = options.tokenURL || 'https://id.ripple.com/oauth/token';
  options.scopeSeparator = options.scopeSeparator || ',';
  options.customHeaders = options.customHeaders || {};

  if (!options.customHeaders['User-Agent']) {
    options.customHeaders['User-Agent'] = options.userAgent || 'passport-ripple';
  }

  OAuth2Strategy.call(this, options, verify);
  this.name = 'ripple';
  //this._oauth2.setAccessTokenName("oauth_token");

  this._userProfileURL = options.userProfileURL || 'https://id.ripple.com/api/identity/profile';
}


Ripple Basicincome.co uses https://github.com/ripple/passport-ripple. Bitcoin Basicincome.co uses https://github.com/bitid/bitid. Other financial platforms that you add will use the same sort of authorization.
Set dividendRate

var request = require('request')

request.post(
    'https://api.basicincome.co/v1/set_dividendRate',
    { form: { 
    oauth: {},
    address: your_account, 
    currency: "XYZ", 
    dividendRate: x.xx } },
    function (err, res, body) {
        
    });

You need to verify that you are the account holder when you update your dividendRates on the server. Provide your basicincome_co-password, or one of the other verification methods.

var ripple = require('ripple-lib')
var vaultClient = new ripple.VaultClient();

login(username, password)

function login(username, password){
vaultClient.loginAndUnlock(username, password, "basicincome.co", userBlob)
}

function userBlob(err, blob) {
console.log(blob)
blob.blob.unshift("/basicincome_co", {"currency": "XYZ", "dividendRate": "x.xx"})
};


Optional: double-check
You can choose to store dividendRate values in your wallet. That way, when you sign dividends, you can double-check the data that basicincome.co sends you.
Sign Dividends

var request = require('request')

request.post(
    'https://api.basicincome.co/v1/sign_dividends',
    { form: { address: your_account } },
    function (err, res, body) {
        

       if (!error && response.statusCode == 200) {
       
       
        // iterate each currency
        for(var i=0;ibody.length;i++){
        create_transaction(body[i].account, body[i].currency, body[i].unsigned_dividends, body[i].destination_tag)
        }
        
        }
    });

The system calculates how much dividends you should pay, based on the dividendRate you've set, and then divides your payments on everyone who's connected to your swarm via dividend pathways. It then runs an optimization algorithm, and routes all your dividends to one single node. You still pay the same amount, and everyone still recieves the same amount.



function create_transaction(destination, currency, amount, destination_tag){ 
    

var ripple = require('ripple-lib')
var Remote = ripple.Remote;
var remote = new Remote({
  servers: [ 'wss://s1.ripple.com:443' ]
});

remote.connect(function() {
  /* remote connected */
  
})
    
var vaultClient = new ripple.VaultClient();

login(username, password)

function login(username, password){
vaultClient.loginAndUnlock(username, password, "basicincome.co", userBlob)

function userBlob(err, blob) {

    
    remote.setSecret(blob.blob.data.account_id, blob.secret);
    var transaction = remote.createTransaction('Payment', {
      account: blob.blob.data.account_id,
      destination: destination,
      amount: {currency: currency, value: String(amount), issuer: blob.blob.data.account_id}
    });
    
    
    transaction.tx_json.DestinationTag = destination_tag;
    
    transaction.on('resubmitted', function() {
    });
    transaction.submit(function(err, res) {
         if (err){
        console.log(err) 
        
         }
         else console.log(res);
    });
    
}}

}

Make sure to specify the destination_tag that basicincome.co sent you, this is how basicincome.co knows you've payed your dividends.
Optional: Store last signed dividend

var ripple = require('ripple-lib')
var vaultClient = new ripple.VaultClient();

login(username, password)

function login(username, password){
vaultClient.loginAndUnlock(username, password, "basicincome.co", userBlob)
}

function userBlob(err, blob) {
console.log(blob)
blob.blob.unshift("/basicincome_co", {"last_signed_dividend": "tx_hash"})
};


To double-check the data Basicincome.co sends you, store your dividendRate and the last transaction you payed dividends for, in your wallet. Then when you sign new dividends, double-check so that the amount doesn't exceed the transactions you've recieved since you last payed dividends * the dividendRate you've stored in your wallet.