Exemple #1
0
 public function postPayment(Payment $payment)
 {
     //Payment is used to create account entries
     //from buyer in sale
     //post tx to sales/income revenue and paypal/mpesa/cash in hand account
     $receipt = PaymentProcessor::ProcessPayment($this, $payment);
     if ($receipt) {
         //payment has gone trough;
         #status 0 - awaiting payment, 1- partially paid, 2-overdue, 3-paid
         $this->payments[] = $payment;
         if ($payment->amount->amount > $this->balance) {
             //$this->balance = $this->balance - $payment->amount->amount;
             $this->balance = 0.0;
             $this->status = 3;
         } else {
             if ($payment->amount->amount == $this->balance) {
                 $this->balance = 0.0;
                 $this->status = 3;
             } else {
                 $this->balance = $this->balance - $payment->amount->amount;
                 $this->status = 1;
             }
         }
         $this->updateInvoice();
         return $receipt;
     } else {
         return false;
     }
 }