예제 #1
0
 /**
  * Adds order [and customer] info to wa_transaction DB table (for cases like Google Checkout)
  * @param $wa_transaction_id int
  * @param $result array
  * @param $state string
  * @return bool result
  */
 public static final function addTransactionData($wa_transaction_id, $result = null, $state = null)
 {
     $transaction_model = new waTransactionModel();
     $data = array();
     if (isset($result['order_id'])) {
         $data['order_id'] = $result['order_id'];
     }
     if (isset($result['customer_id'])) {
         $data['customer_id'] = $result['customer_id'];
     }
     if (isset($result['result'])) {
         $data['result'] = $result['result'];
     }
     if (isset($result['error'])) {
         $data['error'] = $result['error'];
     }
     if ($state) {
         $data['state'] = $state;
     }
     if ($data) {
         return $transaction_model->updateById($wa_transaction_id, $data);
     }
     return false;
 }
 /**
  * Saves formatted data and raw data to DB
  *
  * @param $wa_transaction_data
  * @param array $transaction_raw_data
  * @return array
  *
  * @tutorial $transaction_data array format:
  * type – one of: 'AUTH+CAPTURE', 'AUTH ONLY', 'CAPTURE', 'REFUND', 'CANCEL', 'CHARGEBACK'
  * amount
  * currency_id – 3-letter ISO-code
  * date_time
  * order_id
  * customer_id
  * transaction_OK — true/false flag
  * error_description – string
  * view_data – string
  * comment - string (optional)
  * native_id - original transaction id from payment gateway
  * parent_id - primary transaction id (optional)
  */
 protected final function saveTransaction($wa_transaction_data, $transaction_raw_data = null)
 {
     $transaction_model = new waTransactionModel();
     $wa_transaction_data['plugin'] = $this->id;
     $wa_transaction_data['app_id'] = $this->app_id;
     $wa_transaction_data['merchant_id'] = $this->key;
     $wa_transaction_data['id'] = $transaction_model->insert($wa_transaction_data);
     if (!empty($wa_transaction_data['parent_id']) && !empty($wa_transaction_data['parent_state'])) {
         $transaction_model->updateById($wa_transaction_data['parent_id'], array('state' => $wa_transaction_data['parent_state'], 'update_datetime' => date('Y-m-d H:i:s')));
     }
     if ($transaction_raw_data && is_array($transaction_raw_data)) {
         $transaction_data_model = new waTransactionDataModel();
         $transaction_data_model->addGroup($wa_transaction_data['id'], $transaction_raw_data);
     }
     return $wa_transaction_data;
 }