2 namespace wcf\data\paid\subscription\transaction\log;
3 use wcf\data\object\type\ObjectTypeCache;
4 use wcf\data\paid\subscription\PaidSubscription;
5 use wcf\data\user\User;
6 use wcf\data\DatabaseObject;
10 * Represents a paid subscription transaction log entry.
13 * @copyright 2001-2015 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package com.woltlab.wcf
16 * @subpackage data.paid.subscription.transaction.log
17 * @category Community Framework
19 * @property-read integer $logID
20 * @property-read integer|null $subscriptionUserID
21 * @property-read integer|null $userID
22 * @property-read integer $subscriptionID
23 * @property-read integer $paymentMethodObjectTypeID
24 * @property-read integer $logTime
25 * @property-read string $transactionID
26 * @property-read string $transactionDetails
27 * @property-read string $logMessage
29 class PaidSubscriptionTransactionLog extends DatabaseObject {
31 * @see \wcf\data\DatabaseObject::$databaseTableName
33 protected static $databaseTableName = 'paid_subscription_transaction_log';
36 * @see \wcf\data\DatabaseObject::$databaseIndexName
38 protected static $databaseTableIndexName = 'logID';
42 * @var \wcf\data\user\User
44 protected $user = null;
47 * paid subscription object
48 * @var \wcf\data\paid\subscription\PaidSubscription
50 protected $subscription = null;
53 * Returns the payment method of this transaction.
57 public function getPaymentMethodName() {
58 $objectType = ObjectTypeCache::getInstance()->getObjectType($this->paymentMethodObjectTypeID);
59 return $objectType->objectType;
63 * Returns transaction details.
67 public function getTransactionDetails() {
68 return unserialize($this->transactionDetails);
72 * Returns the user of this transaction.
74 * @return \wcf\data\user\User
76 public function getUser() {
77 if ($this->user === null) {
78 $this->user = new User($this->userID);
85 * Returns the paid subscription of this transaction.
87 * @return \wcf\data\paid\subscription\PaidSubscription
89 public function getSubscription() {
90 if ($this->subscription === null) {
91 $this->subscription = new PaidSubscription($this->subscriptionID);
94 return $this->subscription;
98 * Gets a transaction log entry by transaction id.
100 * @param integer $paymentMethodObjectTypeID
101 * @param string $transactionID
102 * @return \wcf\data\paid\subscription\transaction\log\PaidSubscriptionTransactionLog
104 public static function getLogByTransactionID($paymentMethodObjectTypeID, $transactionID) {
106 FROM wcf".WCF_N."_paid_subscription_transaction_log
107 WHERE paymentMethodObjectTypeID = ?
108 AND transactionID = ?";
109 $statement = WCF::getDB()->prepareStatement($sql);
110 $statement->execute(array($paymentMethodObjectTypeID, $transactionID));
111 $row = $statement->fetchArray();
112 if ($row !== false) {
113 return new PaidSubscriptionTransactionLog(null, $row);