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 unique id of the paid subscription transaction log entry
18 * @property-read integer|null $subscriptionUserID id of the paid subscription-user-association or `null` if no such association exists
19 * @property-read integer|null $userID id of the user who caused the paid subscription transaction log entry or `null` if the user does not exist anymore
20 * @property-read integer $subscriptionID id of the paid subscription
21 * @property-read integer $paymentMethodObjectTypeID id of the `com.woltlab.wcf.payment.method` object type
22 * @property-read integer $logTime timestamp at which the log has been created
23 * @property-read string $transactionID identifier of the paid subscription transaction
24 * @property-read string $transactionDetails serialized defailts of the paid subscription transaction
25 * @property-read string $logMessage log message describing the status of the paid subscription transaction
27 class PaidSubscriptionTransactionLog extends DatabaseObject {
30 * @var \wcf\data\user\User
32 protected $user = null;
35 * paid subscription object
36 * @var \wcf\data\paid\subscription\PaidSubscription
38 protected $subscription = null;
41 * Returns the payment method of this transaction.
45 public function getPaymentMethodName() {
46 $objectType = ObjectTypeCache::getInstance()->getObjectType($this->paymentMethodObjectTypeID);
47 return $objectType->objectType;
51 * Returns transaction details.
55 public function getTransactionDetails() {
56 return unserialize($this->transactionDetails);
60 * Returns the user of this transaction.
62 * @return \wcf\data\user\User
64 public function getUser() {
65 if ($this->user === null) {
66 $this->user = new User($this->userID);
73 * Returns the paid subscription of this transaction.
75 * @return \wcf\data\paid\subscription\PaidSubscription
77 public function getSubscription() {
78 if ($this->subscription === null) {
79 $this->subscription = new PaidSubscription($this->subscriptionID);
82 return $this->subscription;
86 * Returns the transaction log entry by transaction id or `null` if no such entry exists.
88 * @param integer $paymentMethodObjectTypeID
89 * @param string $transactionID
90 * @return PaidSubscriptionTransactionLog|null
92 public static function getLogByTransactionID($paymentMethodObjectTypeID, $transactionID) {
94 FROM wcf".WCF_N."_paid_subscription_transaction_log
95 WHERE paymentMethodObjectTypeID = ?
96 AND transactionID = ?";
97 $statement = WCF::getDB()->prepareStatement($sql);
98 $statement->execute([$paymentMethodObjectTypeID, $transactionID]);
99 $row = $statement->fetchArray();
100 if ($row !== false) {
101 return new PaidSubscriptionTransactionLog(null, $row);