示例#1
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COST" => 0);
     /*
     $input = "Y'ello. You have received
     UGX 1000000.00 from 
     ABACUS
     INVESTMENTS LIMITED
     COMMISSION
     (256774656827) on your
     mobile money account at
     2015-05-10
     13:35:12.Your new
     balance:UGX
     1068816.00.
     ";		
     */
     // REFACTOR: should be split into subclasses
     if (strpos($input, "You have received") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $temp = array();
         preg_match_all("/You have received[\\s\n]+UGX ([0-9\\.\\,]+) from[\\s\n]+([^\\(]+)[\\s\n]+\\(([0-9]+)\\) on your[\\s\n]+mobile money account at[\\s\n]+(\\d{4}-\\d\\d-\\d\\d?)[\\s\n]+(\\d\\d?:\\d\\d:\\d\\d)\\.Your new[\\s\n]+balance:UGX[\\s\n]+([0-9\\.\\,]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["TYPE"] = Transaction::UG_MTN_PRIVATE_PAYMENT_RECEIVED;
             $result["AMOUNT"] = Utility::numberInput($temp[1][0]);
             $result["NAME"] = $temp[2][0];
             $result["PHONE"] = $temp[3][0];
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
             $result["RECEIPT"] = $result["TIME"];
             // since no unique code is given we will use the timestamp
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::UG_MTN_PRIVATE_UNKOWN;
     }
     return $result;
 }
示例#2
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COSTS" => 0);
     if (strpos($input, "yuCash payment sent ") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Parser::PAYMENT_SENT;
         $temp = array();
         preg_match_all("/KES\\s+([0-9\\.\\,]+)\\s+yuCash payment sent to\\s+(.+)\\s+-\\s+([0-9]+)\\.\\s+Fees:\\s+KES\\s+([0-9\\.\\,]+)\\.\\s+Balance:\\s+KES\\s+([0-9\\.\\,]+)\\.\\s+TxnId:\\s+([0-9]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[6][0];
             $result["AMOUNT"] = Utility::numberInput($temp[1][0]);
             $result["NAME"] = $temp[2][0];
             $result["ACCOUNT"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[5][0]);
             $result["COSTS"] = Utility::numberInput($temp[4][0]);
         }
     } elseif (strpos($input, "Successful Deposit: ") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Parser::DEPOSIT;
         $temp = array();
         preg_match_all("/Successful Deposit: StoreName\\s+(.+)\\s+AgentID\\s+([0-9]+)\\s+Amt\\s+KES\\s+([0-9\\.\\,]+)\\s+Balance\\s+\nKES\\s+([0-9\\.\\,]+)\\s+Date\\s+(.+)\\s+Txn\\s+ ID\\s+([0-9]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[6][0];
             $result["AMOUNT"] = Utility::numberInput($temp[3][0]);
             $result["NAME"] = $temp[1][0];
             $result["ACCOUNT"] = $temp[2][0];
             $result["TIME"] = $this->timeInput($temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[4][0]);
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = PersonalParser::UNKNOWN;
     }
     return $result;
 }
示例#3
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COSTS" => 0);
     if (strpos($input, "You have received ") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Parser::PAYMENT_RECEIVED;
         $temp = array();
         preg_match_all("/You have received Rwf\\s+([0-9\\.\\,]+)\\s+from\\s+([0-9]+)\\.\r?\nReason:\\s+([^\r\n])\\.\r?\nYour\\s+balance\\s+is\\s+Rwf\\s+([0-9\\.\\,]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = "";
             // NOT GOOD - NO RECEIPT NUMBER
             $result["AMOUNT"] = Utility::numberInput($temp[1][0]);
             $result["NAME"] = "";
             $result["ACCOUNT"] = $temp[3][0];
             $result["PHONE"] = $temp[2][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[4][0]);
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = PersonalParser::UNKNOWN;
     }
     return $result;
 }
示例#4
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COST" => 0);
     // REFACTOR: should be split into subclasses
     if (strpos($input, "You have received") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*You have received Ksh([0-9\\.\\,]+00) from[\\s\n]+([0-9A-Z '\\.]+) ([0-9]+)[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["TYPE"] = Transaction::MPESA_PRIVATE_PAYMENT_RECEIVED;
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["PHONE"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         } else {
             preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*You have received Ksh([0-9\\.\\,]+00) from[\\s\n]+([0-9]+) - ([A-Z '\\.]+) [\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
             if (isset($temp[1][0])) {
                 $result["TYPE"] = Transaction::MPESA_PRIVATE_B2C_RECEIVED;
                 $result["RECEIPT"] = $temp[1][0];
                 $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
                 $result["ACCOUNT"] = $temp[3][0];
                 $result["NAME"] = $temp[4][0];
                 $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
                 $result["BALANCE"] = Utility::numberInput($temp[7][0]);
             }
         }
     } elseif (strpos($input, "received from") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_BUYGOODS_RECEIVED;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*Ksh([0-9\\.\\,]+00) received from[\\s\n]+([0-9]+) ([0-9A-Z '\\.]+)[\\s\n]*New Account balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = trim($temp[6][0]);
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["PHONE"] = $temp[5][0];
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         }
     } elseif (preg_match("/sent to .+ for account/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_PAYBILL_PAID;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*Ksh([0-9\\.\\,]+) sent to[\\s\n]*(.+)[\\s\n]*for account (.+)[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["ACCOUNT"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         }
     } elseif (preg_match("/Ksh[0-9\\.\\,]+ paid to /", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_BUY_GOODS;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*Ksh([0-9\\.\\,]+) paid to[\\s\n]*([.]+)[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/sent to .+ on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_PAYMENT_SENT;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*Ksh([0-9\\.\\,]+00) sent to ([0-9A-Z '\\.]+) ([0-9]+) on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["PHONE"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         }
     } elseif (preg_match("/Give Ksh[0-9\\.\\,]+ cash to/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_DEPOSIT;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*Give Ksh([0-9\\.\\,]+00) cash to (.+)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/Withdraw Ksh[0-9\\.\\,]+ from/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_WITHDRAW;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*Withdraw Ksh([0-9\\.\\,]+) from[\\s\n]*(.+)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/Ksh[0-9\\.\\,]+ withdrawn from/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_WITHDRAW_ATM;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M).[\\s\n]*Ksh([0-9\\.\\,]+) withdrawn from (\\d+) - AGENT ATM\\.[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/You bought Ksh[0-9\\.\\,]+ of airtime on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_AIRTIME_YOU;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) confirmed\\.[\\s\n]*You bought Ksh([0-9\\.\\,]+00) of airtime on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "Safaricom";
             $result["TIME"] = $this->dateInput($temp[3][0] . " " . $temp[4][0]);
             $result["BALANCE"] = Utility::numberInput($temp[5][0]);
         }
     } elseif (preg_match("/You bought Ksh[0-9\\.\\,]+ of airtime for (\\d+) on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_AIRTIME_OTHER;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) confirmed\\.[\\s\n]*You bought Ksh([0-9\\.\\,]+) of airtime for (\\d+) on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]*New M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (strpos($input, "from your M-Shwari account") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_FROM_MSHWARI;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*You have transferred Ksh([0-9\\.\\,]+00)[\\s\n]*from your M-Shwari account[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)\\.[\\s\n]*M-Shwari balance is Ksh[0-9\\.\\,]+\\.[\\s\n]*M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         $result["RECEIPT"] = $temp[1][0];
         $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
         $result["NAME"] = "M-Shwari";
         $result["TIME"] = $this->dateInput($temp[3][0] . " " . $temp[4][0]);
         $result["BALANCE"] = Utility::numberInput($temp[5][0]);
     } elseif (strpos($input, "transferred to M-Shwari account") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_TO_MSHWARI;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*Ksh([0-9\\.\\,]+00) transferred to M-Shwari account[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)\\.[\\s\n]*M-PESA balance is Ksh([0-9\\.\\,]+00)/mi", $input, $temp);
         $result["RECEIPT"] = $temp[1][0];
         $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
         $result["NAME"] = "M-Shwari";
         $result["TIME"] = $this->dateInput($temp[3][0] . " " . $temp[4][0]);
         $result["BALANCE"] = Utility::numberInput($temp[5][0]);
     } elseif (strpos($input, "Your M-PESA balance was") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_BALANCE_REQUEST;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]*Your M-PESA balance was Ksh([0-9\\.\\,]+00)[\\s\n]*on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["TIME"] = $this->dateInput($temp[3][0] . " " . $temp[4][0]);
             $result["BALANCE"] = Utility::numberInput($temp[2][0]);
         }
     } elseif (strpos($input, "Failed.") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_ERROR;
         $result["TIME"] = time();
         $result["NOTE"] = $input;
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::MPESA_PRIVATE_UNKNOWN;
     }
     $result["COST"] = ChargeCalculator::calculateCost($result["TYPE"], $result["TIME"], $result["AMOUNT"]);
     return $result;
 }
示例#5
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COST" => 0);
     // REFACTOR: should be split into subclasses
     if (strpos($input, "You have received") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+You have received Tsh([0-9\\.\\,]+) from[\\s\n]+([A-Z '\\.]+)[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Tsh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_PAYMENT_RECEIVED;
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["PHONE"] = "";
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/sent to .+ for account/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_PAYBILL_PAID;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+Tsh([0-9\\.\\,]+) sent to[\\s\n]+(.+)[\\s\n]+for account[\\s\n]+(.+)[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Tsh([0-9\\.\\,]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["ACCOUNT"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         }
     } elseif (preg_match("/Give Tsh[0-9\\.\\,]+ cash to/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_DEPOSIT;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+Give Tsh([0-9\\.\\,]+) cash to (.+)[\\s\n]+New M-PESA balance is Tsh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/Withdraw Tsh[0-9\\.\\,]+ from/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_WITHDRAW;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+Withdraw Tsh([0-9\\.\\,]+) from[\\s\n]+(.+)[\\s\n]+New M-PESA balance is Tsh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/sent to .+ on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_PAYMENT_SENT;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+Tsh([0-9\\.\\,]+) sent to ([A-Z '\\.]+) on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)\\.[\\s\n]+New M-PESA balance is Tsh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["PHONE"] = "";
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/You bought Tsh[0-9\\.\\,]+ of airtime on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_AIRTIME_YOU;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) confirmed\\.[\\s\n]+You bought Tsh([0-9\\.\\,]+) of airtime on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Tsh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "Vodaphone";
             $result["TIME"] = $this->dateInput($temp[3][0] . " " . $temp[4][0]);
             $result["BALANCE"] = Utility::numberInput($temp[5][0]);
         }
     } elseif (preg_match("/You bought Tsh[0-9\\.\\,]+ of airtime for (\\d+) on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_AIRTIME_OTHER;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) confirmed\\.[\\s\n]+You bought Tsh([0-9\\.\\,]+) of airtime for (\\d+) on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Tsh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (strpos($input, "Your M-PESA balance was") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_BALANCE_REQUEST;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+Your M-PESA balance was Tsh([0-9\\.\\,]+)[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["TIME"] = $this->dateInput($temp[3][0] . " " . $temp[4][0]);
             $result["BALANCE"] = Utility::numberInput($temp[2][0]);
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::TZ_MPESA_PRIVATE_UNKNOWN;
     }
     $result["COST"] = ChargeCalculator::calculateCost($result["TYPE"], $result["TIME"], $result["AMOUNT"]);
     return $result;
 }
示例#6
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COST" => 0);
     if (strpos($input, "You have received ") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Transaction::GH_AIRTEL_PAYMENT_RECEIVED;
         $temp = array();
         preg_match_all("/Trans\\.\\s+ID:\\s+([0-9]+)\\s+You have received ([0-9\\.\\,]+)GHS\\s+from([0-9]+)\\.\\s+Your available\\s+balance\\s+is\\s+([0-9\\.\\,]+)GHS/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "";
             $result["PHONE"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[4][0]);
         }
     } elseif (strpos($input, "You have sent ") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::GH_AIRTEL_PAYMENT_SENT;
         $temp = array();
         preg_match_all("/Trans\\.\\s+ID:\\s+([0-9]+)\\s+You have sent ([0-9\\.\\,]+)GHS\\s+to([0-9]+)\\.\\s+Your available\\s+balance\\s+is\\s+([0-9\\.\\,]+)GHS/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "";
             $result["PHONE"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[4][0]);
         }
     } elseif (strpos($input, "You have received Airtime of") != FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         // NOT CERTAIN - someone else may be giving us airtime.
         $result["TYPE"] = Transaction::GH_AIRTEL_AIRTIME;
         $temp = array();
         preg_match_all("/Trans\\.\\s+ID:\\s+([0-9]+)\\s+You have received Airtime of\\s+GHS\\s+([0-9\\.\\,]+)\\s+from([0-9]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "";
             $result["PHONE"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = -1;
             // Unkown
         }
     } elseif (strpos($input, "you have paid") != FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::GH_AIRTEL_PURCHASE;
         $temp = array();
         preg_match_all("/Trans\\s*ID:\\s+([0-9]+)\\s+Transaction successful, you have paid ([0-9\\.\\,]+)GHS\\s+to reference code ([0-9]+)/mi", $example, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["ACCOUNT"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = -1;
             // Unkown
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::GH_AIRTEL_UNKNOWN;
     }
     return $result;
 }
示例#7
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COST" => 0);
     // REFACTOR: should be split into subclasses
     if (strpos($input, "You have received") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $temp = array();
         preg_match_all("/New balance is Tsh ([0-9\\.\\,]+)[\\s\n]+You have received Tsh ([0-9\\.\\,]+)[\\s\n]+from ([A-Z '\\.]+),[\\s\n]+([0-9]+)\\. (\\d\\d?\\/\\d\\d?\\/\\d{4}) (\\d\\d?:\\d\\d [AP]M)\\; with TxnId:[\\s\n]+([^.]+\\.[^.]+\\.[^.]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_PAYMENT_RECEIVED;
             $result["RECEIPT"] = $temp[7][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["PHONE"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[1][0]);
         }
     } elseif (strpos($input, "Money sent successfully to") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_PAYMENT_SENT;
         $temp = array();
         preg_match_all("/New balance is Tsh ([0-9\\.\\,]+)[\\s\n]+Money sent successfully to[\\s\n]+([A-Z '\\.]+), ([0-9]+)\\.[\\s\n]+Amount: Tsh ([0-9\\.\\,]+) Fee: Tsh ([0-9\\.\\,]+)TxnID:[\\s\n]+([^.]+\\.[^.]+\\.[^.]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[6][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[2][0];
             $result["PHONE"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[1][0]);
             $result["COST"] = Utility::numberInput($temp[5][0]);
         }
     } elseif (strpos($input, "Cash-In of Tsh") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_DEPOSIT;
         $temp = array();
         preg_match_all("/New balance is Tsh ([0-9\\.\\,]+)[\\s\n]+Cash-In of Tsh ([0-9\\.\\,]+)[\\s\n]+successful\\. Agent ([A-Z '\\.]+)\\.[\\s\n]+TxnID:[\\s\n]+([^.]+\\.[^.]+\\.[^.]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[4][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[1][0]);
         }
     } elseif (strpos($input, "Cash-Out to") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_WITHDRAW;
         $temp = array();
         preg_match_all("/New balance is Tsh ([0-9\\.\\,]+)[\\s\n]+Cash-Out to ([A-Z '\\.]+) was successful\\. Amount Tsh[\\s\n]+([0-9\\.\\,]+) Charges Tsh ([0-9\\.\\,]+)TxnID[\\s\n]+([^.]+\\.[^.]+\\.[^.]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[5][0];
             $result["AMOUNT"] = Utility::numberInput($temp[3][0]);
             $result["NAME"] = $temp[2][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[1][0]);
             $result["COST"] = Utility::numberInput($temp[4][0]);
         }
     } elseif (strpos($input, "recharge request is successful") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_AIRTIME_YOU;
         $temp = array();
         preg_match_all("/New balance is Tsh ([0-9\\.\\,]+)[\\s\n]+Your[\\s\n]+recharge request is successful[\\s\n]+for amount Tsh ([0-9\\.\\,]+)[\\s\n]+TxnId :[\\s\n]+([^.]+\\.[^.]+\\.[^.]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[3][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "Tigo";
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[1][0]);
         }
     } elseif (strpos($input, "Bill Transaction has been sent") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_PAYBILL_PAID;
         $temp = array();
         preg_match_all("/Bill Transaction has been sent[\\s\n]+to ([A-Z '\\.]+)\\.Please wait for[\\s\n]+confirmation TxnId:[\\s\n]+([^.]+\\.[^.]+\\.[^,]+)\\, Bill[\\s\n]+Number:([0-9]+),[\\s\n]+transaction amount : ([0-9\\.\\,]+)[\\s\n]+Tsh,new balance :([0-9\\.\\,]+) Tsh,[\\s\n]+Company ([A-Z '\\.]+)\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[2][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["ACCOUNT"] = $temp[3][0];
             $result["NAME"] = $temp[1][0] != $temp[6][0] ? $temp[6][0] . " - " . $temp[1][0] : $temp[1][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[5][0]);
         }
     } elseif (strpos($input, "Bank payment successfull. The details are") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_DEPOSIT_BANK;
         $temp = array();
         preg_match_all("/Bank payment successfull\\. The details are : TxnId:[\\s\n]+([^.]+\\.[^.]+\\.[^,]+), Ref[\\s\n]+Number:([0-9]+),[\\s\n]+transaction amount : ([0-9\\.\\,]+)[\\s\n]+Tsh , charges: ([0-9\\.\\,]+) Tsh,new[\\s\n]+balance :([0-9\\.\\,]+) Tsh, Bank Name :[\\s\n]+([A-Z '\\.]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[3][0]);
             $result["ACCOUNT"] = $temp[2][0];
             $result["NAME"] = $temp[6][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[5][0]);
             $result["COST"] = Utility::numberInput($temp[4][0]);
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::TZ_TIGO_PRIVATE_UNKOWN;
     }
     return $result;
 }
示例#8
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COSTS" => 0);
     // REFACTOR: should be split into subclasses
     if (strpos($input, "You have received") > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = PersonalParser::PAYMENT_RECEIVED;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+You have received Ksh([0-9\\.\\,]+) from[\\s\n]+([A-Z ]+) ([0-9]+)[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["PHONE"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         }
     } elseif (preg_match("/sent to .+ for account/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = PersonalParser::PAYBILL_PAID;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+Ksh([0-9\\.\\,]+) sent to[\\s\n]+(.+)[\\s\n]+for account (.+)[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["ACCOUNT"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         }
     } elseif (preg_match("/Ksh[0-9\\.\\,]+ paid to /", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = PersonalParser::BUY_GOODS;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+Ksh([0-9\\.\\,]+) paid to[\\s\n]+([.]+)[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/sent to .+ on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = PersonalParser::PAYMENT_SENT;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+Ksh([0-9\\.\\,]+) sent to ([A-Z ]+) ([0-9]+) on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["PHONE"] = $temp[4][0];
             $result["TIME"] = $this->dateInput($temp[5][0] . " " . $temp[6][0]);
             $result["BALANCE"] = Utility::numberInput($temp[7][0]);
         }
     } elseif (preg_match("/Give Ksh[0-9\\.\\,]+ cash to/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_IN;
         $result["TYPE"] = PersonalParser::DEPOSIT;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+Give Ksh([0-9\\.\\,]+) cash to (.+)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/Withdraw Ksh[0-9\\.\\,]+ from/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = PersonalParser::WITHDRAW;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed\\.[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+Withdraw Ksh([0-9\\.\\,]+) from (.+)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/Ksh[0-9\\.\\,]+ withdrawn from/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = PersonalParser::WITHDRAW_ATM;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) Confirmed[\\s\n]+on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M).[\\s\n]+Ksh([0-9\\.\\,]+) withdrawn from (\\d+) - AGENT ATM\\.[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[4][0]);
             $result["NAME"] = $temp[5][0];
             $result["TIME"] = $this->dateInput($temp[2][0] . " " . $temp[3][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } elseif (preg_match("/You bought Ksh[0-9\\.\\,]+ of airtime on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = PersonalParser::AIRTIME_YOU;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) confirmed\\.[\\s\n]+You bought Ksh([0-9\\.\\,]+) of airtime on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "Safaricom";
             $result["TIME"] = $this->dateInput($temp[3][0] . " " . $temp[4][0]);
             $result["BALANCE"] = Utility::numberInput($temp[5][0]);
         }
     } elseif (preg_match("/You bought Ksh[0-9\\.\\,]+ of airtime for (\\d+) on/", $input) > 0) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = PersonalParser::AIRTIME_OTHER;
         $temp = array();
         preg_match_all("/([A-Z0-9]+) confirmed\\.[\\s\n]+You bought Ksh([0-9\\.\\,]+) of airtime for (\\d+) on (\\d\\d?\\/\\d\\d?\\/\\d\\d) at (\\d\\d?:\\d\\d [AP]M)[\\s\n]+New M-PESA balance is Ksh([0-9\\.\\,]+)/mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["TIME"] = $this->dateInput($temp[4][0] . " " . $temp[5][0]);
             $result["BALANCE"] = Utility::numberInput($temp[6][0]);
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = PersonalParser::UNKNOWN;
     }
     return $result;
 }
示例#9
0
 public function parse($input)
 {
     $result = array("SUPER_TYPE" => 0, "TYPE" => 0, "RECEIPT" => "", "TIME" => 0, "PHONE" => "", "NAME" => "", "ACCOUNT" => "", "STATUS" => "", "AMOUNT" => 0, "BALANCE" => 0, "NOTE" => "", "COST" => 0);
     // REFACTOR: should be split into subclasses
     // IMPORTANT Airtime is first to avoid clash with "received" wording or incomming money
     if (strpos($input, "You have received Airtime of") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $temp = array();
         preg_match_all("/Trans. ID: ([0-9]+)\\. You have received Airtime of[\\s\n]+([0-9\\.\\,]+)Ksh from your OWN account\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_AIRTIME_YOU;
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = "Airtel";
             $result["TIME"] = time();
         }
     } elseif (strpos($input, "You have received ") !== FALSE) {
         if (preg_match("/You have received [0-9]+\\.00Ksh/mi", $input) === 1) {
             $result["SUPER_TYPE"] = Transaction::MONEY_IN;
             $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_PAYMENT_RECEIVED;
             $temp = array();
             preg_match_all("/Trans. ID: ([0-9]+) You have received ([0-9\\.\\,]+)\\.00Ksh from[\\s\n]+([A-Z '\\.]+)\\. Your available[\\s\n]+balance is ([0-9\\.\\,]+)\\.00Ksh\\./mi", $input, $temp);
             if (isset($temp[1][0])) {
                 $result["RECEIPT"] = $temp[1][0];
                 $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
                 $result["NAME"] = $temp[3][0];
                 $result["TIME"] = time();
                 $result["BALANCE"] = Utility::numberInput($temp[4][0]);
                 $result["COST"] = -1;
                 // NOT DONE
             }
         } elseif (preg_match("/You have received [0-9]+Ksh/mi", $input) === 1) {
             $result["SUPER_TYPE"] = Transaction::MONEY_IN;
             $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_DEPOSIT;
             $temp = array();
             preg_match_all("/Trans. ID: ([0-9]+) You have received ([0-9\\.\\,]+)Ksh from[\\s\n]+([A-Z0-9'\\.]+)\\. Your available balance is ([0-9]+)\\.00Ksh\\./mi", $input, $temp);
             if (isset($temp[1][0])) {
                 $result["RECEIPT"] = $temp[1][0];
                 $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
                 $result["NAME"] = $temp[3][0];
                 $result["TIME"] = time();
                 $result["BALANCE"] = Utility::numberInput($temp[4][0]);
                 $result["COST"] = 0;
             }
         } else {
             $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
             $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_UNKOWN;
         }
     } elseif (preg_match("/You have sent [0-9\\.\\,]+\\.00Ksh to[\\s\n]+.+ in reference to/mi", $input) === 1) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_PAYBILL_PAID;
         $temp = array();
         preg_match_all("/Trans. ID: ([0-9]+) You have sent ([0-9\\.\\,]+)Ksh to[\\s\n]+([A-Z ']+) in reference to ([A-Z ']+)\\.[\\s\n]+Your available balance is[\\s\n]+([0-9]+)\\.00Ksh\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["ACCOUNT"] = $temp[4][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[5][0]);
         }
     } elseif (preg_match("/You[\\s\n]+have sent [0-9\\.\\,]+\\.00Ksh to/mi", $input) === 1) {
         $result["SUPER_TYPE"] = Transaction::MONEY_OUT;
         $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_PAYMENT_SENT;
         $temp = array();
         preg_match_all("/Trans. ID: ([0-9]+) You[\\s\n]+have sent ([0-9\\.\\,]+)\\.00Ksh to ([A-Z ']+)\\. Your available[\\s\n]+balance is ([0-9]+)\\.00Ksh\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["RECEIPT"] = $temp[1][0];
             $result["AMOUNT"] = Utility::numberInput($temp[2][0]);
             $result["NAME"] = $temp[3][0];
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[4][0]);
         }
     } elseif (strpos($input, "Your available bal. is Ksh") !== FALSE) {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_BALANCE_REQUEST;
         $temp = array();
         preg_match_all("/Your available bal\\. is Ksh([0-9\\.\\,]+)\\.00\\./mi", $input, $temp);
         if (isset($temp[1][0])) {
             $result["NAME"] = "Airtel";
             $result["TIME"] = time();
             $result["BALANCE"] = Utility::numberInput($temp[1][0]);
         }
     } else {
         $result["SUPER_TYPE"] = Transaction::MONEY_NEUTRAL;
         $result["TYPE"] = Transaction::KE_AIRTEL_PRIVATE_UNKOWN;
         $result["TIME"] = time();
     }
     return $result;
 }