コード例 #1
0
 /**
  * Updates the transaction according to the payment info
  * @param EE_Transaction or int $transaction the transaction to update, or its ID. Cannot be null.
  * @param EE_Payment or int $payment the payment just made or its ID. If empty that's actually OK. It just means no payment has been made.
  * @return boolean success
  */
 public function update_transaction_with_payment($transaction, $payment)
 {
     if (empty($transaction)) {
         return false;
     }
     $transaction = $this->_TXN->ensure_is_obj($transaction);
     /* @var $transaction EE_transaction */
     //now, if the payment's empty, we're going to update the transaction accordingly
     if (empty($payment)) {
         $transaction->set_status(EEM_Transaction::incomplete_status_code);
         $transaction->update_extra_meta('gateway', $this->_gateway_name);
         do_action('AHEE__EE_Gateway__update_transaction_with_payment__no_payment', $transaction);
     } else {
         $payment = $this->_PAY->ensure_is_obj($payment);
         //ok, now process the transaction according to the payment
         $transaction->update_based_on_payments();
         $transaction->update_extra_meta('gateway', $this->_gateway_name);
         do_action('AHEE__EE_Gateway__update_transaction_with_payment__done', $transaction, $payment);
     }
     $transaction->save();
     $transaction->finalize();
     return true;
 }