Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Decoder
- *
- * - Bank payment received --> Application insert total amount --> System Reload promised Balance
- *
- */
- class Application_Model_Payments
- {
- /**
- * Round follow up: A - G
- */
- public static function getAdvise($data)
- {
- /* Round A - TransactionID to User profile grep OK */
- $db = Application_Model_Db::db_load();
- $sql = "select *from
- sh_account
- where
- transaction_id='{$data->transaction_id}'
- ";
- $result = $db->fetchAll($sql);
- $res = (object) $result[0];
- /* Round B - Amount received in Bank OK */
- $target = $data->amount;
- /* Round C - Residential users 0% VAT OK */
- if ($res->signup_group == '2')
- {
- switch($data->from)
- {
- case 'paypal':
- /* Round D - Input->Find->Pormised->Discount OK */
- $sql = "
- select *from sh_payment_discount
- where
- signup_group = '2' and
- paymentmethod = 'paypal' and
- inputamount >= {$data->amount}
- order by
- inputamount asc
- limit 1 ";
- $result = $db->fetchAll($sql);
- if ( count($result) > 0)
- {
- $row = (object) $result[0];
- /* Round E - Mr. Customer i promised 0.95 or 0.93 OK */
- $percent = 100 - $result[0]['percent'];
- $percent = $percent / 100;
- /* Round F - Mr. Customer i have handling cost for this OK */
- $final_price = ($data->amount - 0.35) / 1.034/$percent;
- /* Round G - Mr. Customer,
- i am trying to remember what i promised ERROR ERROR*/
- $target = array(
- 'subtotal' => Zend_Locale_Format::toNumber($final_price,array('number_format' => '##0.00','locale' => 'en')),
- 'discount' => $percent,
- 'paypal' => 0,
- 'vat' => Zend_Locale_Format::toNumber(0,array('number_format' => '##0.00','locale' => 'en')),
- 'total' => Zend_Locale_Format::toNumber($data->amount,array('number_format' => '##0.00','locale' => 'en'))
- );
- break;
- }
- break;
- case 'wire':
- ....
- break;
- case 'payphone':
- ....
- break;
- case 'receipt':
- ....
- break;
- }
- }
- /* Done - with suggestion algorithm - please decide now what requires */
- return array(
- 'raw' => $reserved,
- 'result' => $target,
- );
- }
- ....
Add Comment
Please, Sign In to add comment