2 declare(strict_types=1);
3 namespace wcf\data\paid\subscription\transaction\log;
4 use wcf\data\object\type\ObjectTypeCache;
5 use wcf\data\paid\subscription\PaidSubscription;
6 use wcf\data\user\User;
7 use wcf\data\DatabaseObject;
11 * Represents a paid subscription transaction log entry.
14 * @copyright 2001-2018 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\Data\Paid\Subscription\Transaction\Log
18 * @property-read integer $logID unique id of the paid subscription transaction log entry
19 * @property-read integer|null $subscriptionUserID id of the paid subscription-user-association or `null` if no such association exists
20 * @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
21 * @property-read integer $subscriptionID id of the paid subscription
22 * @property-read integer $paymentMethodObjectTypeID id of the `com.woltlab.wcf.payment.method` object type
23 * @property-read integer $logTime timestamp at which the log has been created
24 * @property-read string $transactionID identifier of the paid subscription transaction
25 * @property-read string $transactionDetails serialized details of the paid subscription transaction
26 * @property-read string $logMessage log message describing the status of the paid subscription transaction
28 class PaidSubscriptionTransactionLog extends DatabaseObject {
33 protected $user = null;
36 * paid subscription object
37 * @var PaidSubscription
39 protected $subscription = null;
42 * Returns the payment method of this transaction.
46 public function getPaymentMethodName() {
47 $objectType = ObjectTypeCache::getInstance()->getObjectType($this->paymentMethodObjectTypeID);
48 return $objectType->objectType;
52 * Returns transaction details.
56 public function getTransactionDetails() {
57 return unserialize($this->transactionDetails);
61 * Returns the user of this transaction.
65 public function getUser() {
66 if ($this->user === null) {
67 $this->user = new User($this->userID);
74 * Returns the paid subscription of this transaction.
76 * @return PaidSubscription
78 public function getSubscription() {
79 if ($this->subscription === null) {
80 $this->subscription = new PaidSubscription($this->subscriptionID);
83 return $this->subscription;
87 * Returns the transaction log entry by transaction id or `null` if no such entry exists.
89 * @param integer $paymentMethodObjectTypeID
90 * @param string $transactionID
91 * @return PaidSubscriptionTransactionLog|null
93 public static function getLogByTransactionID($paymentMethodObjectTypeID, $transactionID) {
95 FROM wcf".WCF_N."_paid_subscription_transaction_log
96 WHERE paymentMethodObjectTypeID = ?
97 AND transactionID = ?";
98 $statement = WCF::getDB()->prepareStatement($sql);
99 $statement->execute([$paymentMethodObjectTypeID, $transactionID]);
100 $row = $statement->fetchArray();
101 if ($row !== false) {
102 return new PaidSubscriptionTransactionLog(null, $row);