WebMoneyUtils.class.php

Go to the documentation of this file.
00001 <?php
00002     final class WebMoneyUtils extends StaticFactory
00003     {
00004         // order does matter!
00005         static private $firstFields = array(
00006             'LMI_PAYEE_PURSE',
00007             'LMI_PAYMENT_AMOUNT',
00008             'LMI_PAYMENT_NO',
00009             'LMI_MODE',
00010             'LMI_SYS_INVS_NO',
00011             'LMI_SYS_TRANS_NO',
00012             'LMI_SYS_TRANS_DATE'
00013         );
00014 
00015         static private $secondFields = array(
00016             'LMI_PAYER_PURSE',
00017             'LMI_PAYER_WM'
00018         );
00019 
00023         public static function makePaymentHash($secretKey, $postData)
00024         {
00025             $data = null;
00026 
00027             foreach (self::$firstFields as $field)
00028                 if (!isset($postData[$field]))
00029                     return null;
00030                 else
00031                     $data .= $postData[$field];
00032 
00033             $data .= $secretKey;
00034 
00035             foreach (self::$secondFields as $field)
00036                 if (!isset($postData[$field]))
00037                     return null;
00038                 else
00039                     $data .= $postData[$field];
00040 
00041             return mb_strtoupper(md5($data));
00042         }
00043 
00047         public static function isValidPayment($expected, $test)
00048         {
00049             return $expected == $test;
00050         }
00051     }
00052 ?>