本文整理汇总了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);
}
示例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;
}
示例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);
}