accountAddFunds(), accountCredit() and accountDebit()

These applications allow to refund or charge the Account's balance with the specified sum.


Input

These functions receive struct with the following fields:


Mandatory fields

  • i_account (integer) - ID of account. Integer.
  • amount - amount to refund or charge. Double.
  • currency - currency in iso_4217 format (3 letters). String.

Optional fields

  • payment_notes - String
  • payment_time - time of the payment in '%H:%M:%S.000 GMT %a %b %d %Y' format (e.g. 09:57:29.000 GMT Wed Nov 18 2009). (from version >= 5.0). String.


Output

The function returns:

  • result - 'OK'
  • XMLRPC fault in case of any error.

Example

Python example:

# this script requires httplib2 to be installed from http://code.google.com/p/httplib2/
import httplib2
import urllib
from xmlrpclib import ServerProxy, getparser, ProtocolError

class HTTPSDigestAuthTransport:
    def request(self, host, handler, request_body, verbose=0):
        auth, host = urllib.splituser(host)
        username, password = urllib.splitpasswd(auth)

        h = httplib2.Http()
        if verbose:
            h.debuglevel = 1
        h.add_credentials(username, password)

        resp, content = h.request("https://" + host + handler, "POST", body=request_body,
                                  headers={'content-type':'text/xml'})

        if resp.status != 200:
            raise ProtocolError("https://" + host + handler,
                                resp.status, resp.reason, None)

        p, u = getparser(0)
        p.feed(content)

        return u.close()

transport = HTTPSDigestAuthTransport()
client = ServerProxy("https://username:password@1.2.3.4/xmlapi/xmlapi", transport)
res = client.accountAddFunds({ 'i_account' : 1234, 'amount' : 1.23, 'currency' : 'USD', 'payment_notes' : 'Test credit' })
print res['result']