当前位置: 首页>>代码示例>>PHP>>正文


PHP Transaction::getTransaction方法代码示例

本文整理汇总了PHP中Transaction::getTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP Transaction::getTransaction方法的具体用法?PHP Transaction::getTransaction怎么用?PHP Transaction::getTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Transaction的用法示例。


在下文中一共展示了Transaction::getTransaction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processResponse

 /**
  * Process the response from Paytrail payment service.
  *
  * @param array $params Response variables
  *
  * @return string error message (not translated)
  *   or associative array with keys:
  *     'markFeesAsPaid' (boolean) true if payment was successful and fees
  *     should be registered as paid.
  *     'transactionId' (string) Transaction ID.
  *     'amount' (int) Amount to be registered (does not include transaction fee).
  * @access public
  */
 public function processResponse($params)
 {
     $status = $params['payment'];
     $orderNum = $params['ORDER_NUMBER'];
     $timestamp = $params['TIMESTAMP'];
     $tr = new Transaction();
     if (!$tr->isTransactionInProgress($orderNum)) {
         return 'online_payment_transaction_already_processed_or_unknown';
     }
     if (($t = $tr->getTransaction($orderNum)) === false) {
         error_log("Paytrail: error processing transaction {$orderNum}: transaction not found");
         return 'online_payment_failed';
     }
     $amount = $t->amount;
     $paid = false;
     if ($status == self::PAYMENT_SUCCESS || $status == self::PAYMENT_NOTIFY) {
         if (!($module = $this->initPaytrail())) {
             return 'online_payment_failed';
         }
         if (!$module->confirmPayment($params["ORDER_NUMBER"], $params["TIMESTAMP"], $params["PAID"], $params["METHOD"], $params["RETURN_AUTHCODE"])) {
             error_log("Paytrail: error processing response: invalid checksum");
             error_log("   " . var_export($params, true));
             return 'online_payment_failed';
         }
         if (!$t->setTransactionPaid($orderNum, $timestamp)) {
             error_log("Paytrail: error updating transaction {$orderNum} to paid");
         }
         $paid = true;
     } else {
         if ($status == self::PAYMENT_FAILURE) {
             if (!$t->setTransactionCancelled($orderNum)) {
                 error_log("Paytrail: error updating transaction {$orderNum} to cancelled");
             }
             return 'online_payment_canceled';
         } else {
             $t->setTransactionUnknownPaymentResponse($orderNum, $status);
             return 'online_payment_failed';
         }
     }
     return array('markFeesAsPaid' => $paid, 'transactionId' => $orderNum, 'amount' => $amount);
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:54,代码来源:Paytrail.php

示例2: processPayment

 /**
  * Register payment provided in the request.
  * This is called by JSON_Transaction.
  *
  * @param array   $params       Key-value list of request variables.
  * @param boolean $userLoggedIn Is user logged in at the time of method call.
  *
  * @return array array with keys
  *   - 'success' (boolean)
  *   - 'msg' (string) error message if payment could not be processed.
  * @access public
  */
 public function processPayment($params, $userLoggedIn = true)
 {
     global $interface;
     global $user;
     $error = false;
     $msg = null;
     $transactionId = $params['transaction'];
     $tr = new Transaction();
     if (!($t = $tr->getTransaction($transactionId))) {
         error_log("Error processing payment: transaction {$transactionId} not found");
         $error = true;
     }
     if (!$tr->isTransactionInProgress($transactionId)) {
         error_log("Error processing payment: transaction {$transactionId} already processed.");
         $error = true;
     }
     if (!$error) {
         $patron = null;
         $patronId = $t->cat_username;
         if (!$userLoggedIn) {
             // MultiBackend::getConfig expects global user object and user->cat_username to be defined.
             $user = new User();
             $user->cat_username = $patronId;
             $account = new User_account();
             $account->user_id = $t->user_id;
             $account->cat_username = $t->cat_username;
             if ($account->find(true)) {
                 $patron = $this->catalog->patronLogin($t->cat_username, $account->cat_password);
             }
             if (!$patron) {
                 error_log("Error processing payment: could not perform patron login (transaction {$transactionId})");
                 $error = true;
             }
         } else {
             $patron = UserAccount::catalogLogin();
         }
         $config = $this->catalog->getConfig('OnlinePayment');
         if ($config && $config['enabled']) {
             $paymentHandler = CatalogConnection::getOnlinePaymentHandler($patronId);
             $res = $paymentHandler->processResponse($params);
             if (is_array($res) && isset($res['markFeesAsPaid']) && $res['markFeesAsPaid']) {
                 $finesAmount = $this->catalog->getOnlinePayableAmount($patron);
                 // Check that payable sum has not been updated
                 if ($finesAmount == $res['amount']) {
                     $paidRes = $this->catalog->markFeesAsPaid($patron, $res['amount']);
                     if ($paidRes === true) {
                         $t = new Transaction();
                         if (!$t->setTransactionRegistered($res['transactionId'])) {
                             error_log("Error updating transaction {$transactionId} status: registered");
                         }
                         $_SESSION['payment_ok'] = true;
                     } else {
                         $t = new Transaction();
                         if (!$t->setTransactionRegistrationFailed($res['transactionId'], $paidRes)) {
                             error_log("Error updating transaction {$transactionId} status: registering failed");
                         }
                         $error = true;
                         $msg = translate($paidRes);
                     }
                 } else {
                     // Payable sum updated. Skip registration and inform user that payment processing has been delayed..
                     $t = new Transaction();
                     if (!$t->setTransactionFinesUpdated($res['transactionId'])) {
                         error_log("Error updating transaction {$transactionId} status: payable sum updated");
                     }
                     $error = true;
                     $msg = translate('online_payment_registration_failed');
                 }
             } else {
                 $error = true;
                 $msg = translate($res);
             }
         }
     }
     $res = array('success' => !$error);
     if ($msg) {
         $res['msg'] = $msg;
     }
     return $res;
 }
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:92,代码来源:Fines.php

示例3: deleteTransaction

 public static function deleteTransaction($transactionId)
 {
     $transaction = Transaction::$instance->getTransaction($transactionId);
     //        Transaction::$instance->modelTransaction->deleteTransaction($transactionId);
     Transaction::$instance->addTransaction($transaction['invoice_id'], $transaction['customer_id'], -$transaction['amount'], $transaction['currency_code'], 'Cancellation of transaction #' . (int) $transactionId);
 }
开发者ID:ralfeus,项目名称:moomi-daeri.com,代码行数:6,代码来源:Transaction.php


注:本文中的Transaction::getTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。