クラス
Log
Represents a log to insert into usces_log
table
ソース ソース
ファイル: src/Models/Log.php
class Log implements JsonSerializable { const LOG_TYPE = 'amazonpay_transaction_history'; const RESPONSE_OK = 'OK'; const ACTION_DEFERRED_AUTHORIZE = 'deferred-authorize'; const ACTION_AUTHORIZE = 'authorize'; const ACTION_ASYNC_AUTHORIZE = 'async-authorize'; const ACTION_CAPTURE_PAYMENTS = 'capture'; const ACTION_AUTHORIZE_AND_CAPTURE = 'authorize-and-capture'; const ACTION_ASYNC_CAPTURE_PAYMENTS = 'async-capture'; const ACTION_CANCEL_TRANS = 'cancel'; const ACTION_ASYNC_REFUND = 'async-refund'; const ACTION_REFUND = 'refund'; /** * 取引ID * * @var string */ private $chargePermissionId; /** * Current local timestamp * * @var string */ private $timestamp; /** * 処理区分 * * @var string */ private $actionType; /** * Only set if an error occured. * * @var GenericError|null */ private $error; /** * 処理結果 * * @var string */ private $responseCode; /** * Authorize, capture, or refund amount * * @var null|int */ private $amount; /** * Creates a `Log` instance for passing to `Logger` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $chargePermissionId * @param string $actionType * @param string $responseCode * @param int $amount * @param GenericError|null $error * @param string $timestamp * @return void */ public function __construct( $chargePermissionId, $actionType, $responseCode, $amount = null, $error = null, $timestamp = null ) { $this->chargePermissionId = $chargePermissionId; $this->actionType = $actionType; $this->responseCode = $responseCode; $this->amount = $amount; $this->error = $error; $this->timestamp = !empty($timestamp) ? $timestamp : current_time('mysql'); } /** * Returns action type text translation for a given action key * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $key * @return string */ public static function getActionTypeText($key) { $actionType = ''; switch ($key) { case self::ACTION_DEFERRED_AUTHORIZE: $actionType = __('Back-order', 'wcexaap'); break; case self::ACTION_AUTHORIZE: // 与信 $actionType = __('Authorize Payment', 'wcexaap'); break; case self::ACTION_ASYNC_AUTHORIZE: // 与信(非同期) $actionType = __('Async Authorize Payment', 'wcexaap'); break; case self::ACTION_CAPTURE_PAYMENTS: // 売上計上 $actionType = __('Capture', 'wcexaap'); break; case self::ACTION_AUTHORIZE_AND_CAPTURE: // 与信売上計上 $actionType = __('Authorize and Capture', 'wcexaap'); break; case self::ACTION_ASYNC_CAPTURE_PAYMENTS: // 売上計上(非同期) $actionType = __('Async Capture Payment', 'wcexaap'); break; case self::ACTION_CANCEL_TRANS: // 取消 $actionType = __('Cancel', 'wcexaap'); break; case self::ACTION_ASYNC_REFUND: // 返金(非同期) $actionType = __('Async Refund', 'wcexaap'); break; case self::ACTION_REFUND: // 返金 $actionType = __('Refund', 'wcexaap'); break; } return $actionType; } /** * Object shape for `json_encode` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return array */ public function jsonSerialize() { return [ 'chargePermissionId' => $this->chargePermissionId, 'actionType' => $this->actionType, 'responseCode' => $this->responseCode, 'amount' => $this->amount, 'error' => $this->error, 'timestamp' => $this->timestamp, ]; } /** * Overrides amount value * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param int|string $amount * @return void */ public function setAmount($amount) { $this->amount = $amount; } /** * Getter for `$chargePermissionId` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return string */ public function getChargePermissionId() { return $this->chargePermissionId; } /** * Getter for `$timestamp` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return string */ public function getTimestamp() { return $this->timestamp; } /** * Getter for `$actionType` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return string */ public function getActionType() { return $this->actionType; } /** * Getter for `$error` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return GenericError|null */ public function getError() { return $this->error; } /** * Getter for `$responseCode` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return string */ public function getResponseCode() { return $this->responseCode; } /** * Getter for `$amount` * * @author Evan D Shaw <evandanielshaw@gmail.com> * @return int|null */ public function getAmount() { return $this->amount; } }
- __construct — Creates a Log instance for passing to Logger
- getActionType — Getter for $actionType
- getActionTypeText — Returns action type text translation for a given action key
- getAmount — Getter for $amount
- getChargePermissionId — Getter for $chargePermissionId
- getError — Getter for $error
- getResponseCode — Getter for $responseCode
- getTimestamp — Getter for $timestamp
- jsonSerialize — Object shape for json_encode
- setAmount — Overrides amount value