cvs: pear /Payment_DTA DTAZV.php

From: Date: Wed, 13 May 2009 17:05:09 +0000
Subject: cvs: pear /Payment_DTA DTAZV.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-56089@lists.php.net to get a copy of this message
mschuett Wed May 13 17:05:09 2009 UTC Modified files: /pear/Payment_DTA DTAZV.php Log: fix DTAZV checksum calculation over amounts http://cvs.php.net/viewvc.cgi/pear/Payment_DTA/DTAZV.php?r1=1.5&r2=1.6&diff_format=u Index: pear/Payment_DTA/DTAZV.php diff -u pear/Payment_DTA/DTAZV.php:1.5 pear/Payment_DTA/DTAZV.php:1.6 --- pear/Payment_DTA/DTAZV.php:1.5 Wed May 13 15:29:33 2009 +++ pear/Payment_DTA/DTAZV.php Wed May 13 17:05:09 2009 @@ -63,7 +63,7 @@ * @copyright 2008 Martin Schütte * @copyright 2003-2005 Hermann Stainer, Web-Gear * @license http://www.debian.org/misc/bsd.license BSD License (3 Clause) - * @version CVS: $Id: DTAZV.php,v 1.5 2009/05/13 15:29:33 mschuett Exp $ + * @version CVS: $Id: DTAZV.php,v 1.6 2009/05/13 17:05:09 mschuett Exp $ * @link http://pear.php.net/package/Payment_DTA */ @@ -314,7 +314,11 @@ { $content = ""; - $sum_amounts = 0; + /* The checksum in DTAZV adds only the integer parts of all + * transfered amounts and is different from the sum of amounts. + */ + $checksum_amounts = 0; + $sum_amounts = 0; /** * data record Q @@ -364,7 +368,8 @@ */ foreach ($this->exchanges as $exchange) { - $sum_amounts += (int)$exchange['amount']; + $sum_amounts += intval($exchange['amount']); + $checksum_amounts += intval($exchange['amount']/100); // T01 record length $content .= "0768"; @@ -412,7 +417,8 @@ // T13 currency $content .= "EUR"; // T14a amount (integer) - $content .= str_pad(intval($exchange['amount']/100), 14, "0", STR_PAD_LEFT); + $content .= str_pad(intval($exchange['amount']/100), + 14, "0", STR_PAD_LEFT); // T14b amount (decimal places) $content .= str_pad(($exchange['amount']%100)*10, 3, "0", STR_PAD_LEFT); // T15 purpose @@ -449,9 +455,9 @@ $content .= "0256"; // Z02 record type $content .= "Z"; - // Z03 sum of amounts (integers) + // Z03 sum of amounts (integer parts in T14a) assert($sum_amounts == $this->sum_amounts); - $content .= str_pad(intval($sum_amounts/100), 15, "0", STR_PAD_LEFT); + $content .= str_pad(intval($checksum_amounts), 15, "0", STR_PAD_LEFT); // Z04 number of records type T $content .= str_pad(count($this->exchanges), 15, "0", STR_PAD_LEFT); // Z05 reserve

« previous php.pear.cvs (#56089) next »