RippleAPI how to issue IOUs using preparePayment I'm trying out the API, and I've set up one 'user' account, and one 'gateway' account. The only difference between the two is that the user has extended a trustline to the gateway account. I would now like to issue USD IOUs from the gateway to the user account. 

I assume the functionality for this is built into api.preparePayment(). So far, I am able to transfer XRP using code found in the payment example of ripple-lib. The essence is:

const address = SENDER_ADDRESS;
const secret = SENDER_SECRET;

const payment = {
  source: {
    address: address,
    maxAmount: {
      value: '0.01',
      currency: 'XRP'
    }
  },
  destination: {
    address: RECEIVER_ADDRESS,
    amount: {
      value: '0.01',
      currency: 'XRP'
    }
  }
};


api.connect().then(() =&gt; {
  console.log('Connected...');

  return api.preparePayment(address, payment, instructions).then(prepared =&gt; {
    console.log('Payment transaction prepared...');
    const {signedTransaction} = api.sign(prepared.txJSON, secret);
    console.log('Payment transaction signed...');
    api.submit(signedTransaction);
  });


A few lines of code are missing but this is the basic structure. It works when I make either the Gateway or the user the sender, and the other the receiver. How should I modify it so that I can issue USD IOUs from the Gateway to the user? 

My trustline object was:

var trustline = {
  "currency": "USD",
  "counterparty": GATEWAY_ADDRESS, 
  "limit": "100",
  "qualityIn": 0.91,
  "qualityOut": 0.87,
  "ripplingDisabled": true,
  "frozen": false,
};
Okay I figured it out: first, I set up a trustline from USER_ADDR to GATEWAY_ADDR for 1000 EUR. I made sure that the qualityIn and qualityOut were set to 0, the default value:

var trustline = {
  "currency": "EUR",
  "counterparty": GATEWAY_ADDR, 
  "limit": "1000",
  "ripplingDisabled": true,
  "frozen": false,
  "memos": [
    {
      "type": "test2",
      "format": "plain/text",
      "data": "texted data2"
    }
  ]
};


I signed and submitted this trustline.

I then used the following payment object to create an IOU for 50 EUR from the gateway to the user, indicating that the user had deposited 50 EUR with the gateway outside the Ripple system:

const payment = {
  source: {
    address: GATEWAY_ADDR,
    maxAmount: {
      currency: 'EUR',
      value: '50',
      counterparty: GATEWAY_ADDR
    }
  },
  destination: {
    address: USER_ADDR,
    amount: {
      currency: 'EUR',
      value: '50',
      counterparty: GATEWAY_ADDR
    }
  }
};


Earlier, this was not working due to qualityIn and qualityOut being to 0.91 and 0.87