1 0 Tag Archives: transactions
post icon

Adding SWIFT to MyBanco

20. Apr, 2009

I have had a few emails regarding whether it would be possible to add Interbank communication support into MyBanco such as SWIFT, and I would just like to say here, YES! It is possible, and it is very easy to do.

If you are looking to write a new plugin to do SWIFT transactions (or any other type of external transactions) would be to do the following:

  1. Add a new $method to backend/Plugins/transfer.php
                    'swift' => Array (
                             'title' => 'International bank transfer via SWIFT',
                             'description' => 'Transfer to another {bank} account',
                             'icon' => 'swift'
                     )
  2. If necessary, change __transfer_listValidTransferMethods to make only particular users/bank account types to be able to transfer money via swift (it’s near the bottom of the function)
  3. Implement the following functions:
    • function _t_swift_required – This function returns a list of extra information that is required for the transaction to take place. (ie, extra fields that the user must enter, the account # and $amount is not necessary, as these are sent by default)
    • function _t_swift_check_data – Ensure that the data that has been imputed from the user is correct, for example, this would mean checking the LEK of a credit card transaction…
    • function _t_swift_preview – Send the data for preview. Nothing exciting here really
    • function _t_swift_transfer – This is where the fun stuff actually happens. This is where money would be removed from the account, the message put into the cron queue (if desired) or a real time message sent to SWIFTNet for the transaction to occur.

I would recommend that the way it be done would be to move the money wanting to be transferred into a temp. settlement account, and then add the item to a queue which would run on (another?) machine every 2-5 minutes. I really want to add an open source implementation of the SWIFT messaging system to MyBanco, however, like I said earlier, I no longer have access to any of the information or to any of the SWIFT servers to make this possible. If you have access to this sort of information, I would be happy to continue my development.

Hope this helps people out. By the way, if anyone has access to development documentation for SWIFTNet, I would really love to be able to access it, so just drop me a comment on this blog post.

Thanks,
- Tim

Read full story »


Written By Tim Groeneveld. \\ tags: , , , , , , ,
post icon

Making external applications add money to accounts in MyBanco

05. Aug, 2008

I got an email earlier this morning, asking me how hard it would be to “make something that can activate a transaction when an action happens in another code”. I thought about it for thirty seconds, and realised that it would not be too hard. Infact, it was super easy to do.

There are two ways that it can be done, the MyInfo way, which is complicated, and the MySQL way, which will be the easiest (for the moment). A simple transaction taking place will take about 12 lines of code.

In Psuedocode:

mysql_connect("database.server.com", "root", "password");
mysql_selectdb("myinfo");
if (mysql_error) die "Can't connect to DB";
$SQL = 'INSERT INTO `transactions` (
          `transactionTime`, `from_aid`,
          `to_aid`, `amount`, `description`
        ) VALUES (
          UNIX_TIME(), "$from", "$to",
          "$amount", "Transaction from app"
        )'
mysql_query($SQL);
if (mysql_error) die "fail.";

And that is pretty much it. Not only does it add money to an account (the $to variable)… but it takes it out of an existing account in MyBanco. The only bad thing with using this is that there are no checks done to ensure that the central bank account (the $from) does actually have the right amount of money in there.

Adding this is done with a simple peice of code (in PHP):

if (!$aid) return array('error' => 982);

$SQL = 'SELECT SUM(`amount`) as `positive`
	FROM `transactions`
	WHERE (`to_aid`="' . $aid . '")';

$mr1 = mysql_fetch_array(mysql_query($SQL));
$money_pos = 0;
if($mr1) {
        $money_pos = (is_numeric($mr1["positive"])) ?
                $mr1["positive"]:0;
}

$SQL = 'SELECT SUM(`amount`) as `negative`
        FROM `transactions`
        WHERE `from_aid`="' . $aid . '"
                AND `from_aid`<>`to_aid`';

$mr2 = mysql_fetch_array(mysql_query($SQL));
$money_neg=0;
if($mr2) {
	$money_neg=(is_numeric($mr2["negative"])) ?
                $mr2["negative"]:0;
}

return number_format($money_pos - $money_neg, 2);

Pretty easy, huh? Now all you have to do is before you insert the row into the transactions table, make sure that __bank_amountForAccount($from) is >$amount … and then you will never have “magic” money being circulated around the MyBanco bank system that ultimately should not exist.

Read full story »


Written By Tim Groeneveld. \\ tags: , , , , ,