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-2016 WoltLab GmbH
14 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15 * @package WoltLabSuite\Core\Data\Paid\Subscription\Transaction\Log
17 * @property-read integer $logID
18 * @property-read integer|null $subscriptionUserID
19 * @property-read integer|null $userID
20 * @property-read integer $subscriptionID
21 * @property-read integer $paymentMethodObjectTypeID
22 * @property-read integer $logTime
23 * @property-read string $transactionID
24 * @property-read string $transactionDetails
25 * @property-read string $logMessage
27 class PaidSubscriptionTransactionLog extends DatabaseObject {
31 protected static $databaseTableName = 'paid_subscription_transaction_log';
36 protected static $databaseTableIndexName = 'logID';
40 * @var \wcf\data\user\User
42 protected $user = null;
45 * paid subscription object
46 * @var \wcf\data\paid\subscription\PaidSubscription
48 protected $subscription = null;
51 * Returns the payment method of this transaction.
55 public function getPaymentMethodName() {
56 $objectType = ObjectTypeCache::getInstance()->getObjectType($this->paymentMethodObjectTypeID);
57 return $objectType->objectType;
61 * Returns transaction details.
65 public function getTransactionDetails() {
66 return unserialize($this->transactionDetails);
70 * Returns the user of this transaction.
72 * @return \wcf\data\user\User
74 public function getUser() {
75 if ($this->user === null) {
76 $this->user = new User($this->userID);
83 * Returns the paid subscription of this transaction.
85 * @return \wcf\data\paid\subscription\PaidSubscription
87 public function getSubscription() {
88 if ($this->subscription === null) {
89 $this->subscription = new PaidSubscription($this->subscriptionID);
92 return $this->subscription;
96 * Gets a transaction log entry by transaction id.
98 * @param integer $paymentMethodObjectTypeID
99 * @param string $transactionID
100 * @return \wcf\data\paid\subscription\transaction\log\PaidSubscriptionTransactionLog
102 public static function getLogByTransactionID($paymentMethodObjectTypeID, $transactionID) {
104 FROM wcf".WCF_N."_paid_subscription_transaction_log
105 WHERE paymentMethodObjectTypeID = ?
106 AND transactionID = ?";
107 $statement = WCF::getDB()->prepareStatement($sql);
108 $statement->execute([$paymentMethodObjectTypeID, $transactionID]);
109 $row = $statement->fetchArray();
110 if ($row !== false) {
111 return new PaidSubscriptionTransactionLog(null, $row);