示例#1
0
		// Add the company transaction
		$ct = new SI_CompanyTransaction();
		$ct->amount = -$payment->amount;
		$ct->company_id = $payment->company_id;
		$ct->description = "Credit card payment of ".$payment->amount." on ".date("n/j/y", $payment->timestamp);
		$ct->timestamp = time();
		if($ct->add() === FALSE){
			$error_msg .= "Error adding transaction to company account!\n";
			debug_message($ct->getLastError());
		}

		// Update the payment with the company transaction id and auth code
		$payment->trans_id = $ct->id;
		$payment->auth_code = $cc_processor->getAuthCode();
		if($payment->update() === FALSE){
			$error_msg .= "Error updating payment with company transaction id!\n";
			debug_message($payment->getLastError());
		}

		if(empty($error_msg)){
			if(isset($_POST['email_invoice']) && $_POST['email_invoice'] == 'Y'){
				$invoice = new SI_Invoice();
				if($invoice->get(intval($_POST['invoice_id'])) === FALSE){
					$error_msg .= "Error retreiving invoice!\n";
					debug_message($invoice->getLastError());
				}
				
				if($invoice->sendEmail('InvoiceEmail') === FALSE){
					$error_msg .= "Error sending invoice notification!\n";
					debug_message($invoice->getLastError());