クラス
State
DeferredAuthorize object stateソース ソース
ファイル: src/Models/DeferredAuthorize/State.php
class State implements JsonSerializable, TransactionState
{
const DEFERRED_AUTHORIZE = 'DeferredAuthorize';
/**
* Map of constant names and their corresponding values
*
* @var string[]
*/
public static $stateMap = [
'DEFERRED_AUTHORIZE' => self::DEFERRED_AUTHORIZE,
];
/**
* State to CSS class map
*
* @var string[]
*/
private $cssClassMap = [
self::DEFERRED_AUTHORIZE => 'card-back-ordered',
];
/**
* `statusDetails`'s `state` key value
*
* @var string
*/
private $state;
/**
* `statusDetails`'s `reasonCode` key value
*
* @var string|null
*/
private $reasonCode;
/**
* `statusDetails`'s `reasonDescription` key value
*
* @var string|null
*/
private $reasonDescription;
/**
* Charge Permission ID
*
* @var string|null
*/
private $chargePermissionId;
/**
* Initializes a DeferredAuthorize `State` object
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @param string $state
* @param string|null $reasonCode
* @param string|null $reasonDescription
* @return void
*/
public function __construct($state, $reasonCode = null, $reasonDescription = null) {
$this->state = $state;
$this->reasonCode = $reasonCode;
$this->reasonDescription = $reasonDescription;
}
/**
* Setter for `chargePermissionId`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @param string $chargePermissionId
* @return void
*/
public function setChargePermissionId($chargePermissionId) {
$this->chargePermissionId = $chargePermissionId;
}
/**
* Getter for `chargePermissionId`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string|null
*/
public function getTransactionId() {
return $this->chargePermissionId;
}
/**
* Returns human-readable text representation of current state
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string
*/
public function getDisplayText() {
$text = '';
switch ($this->state) {
case self::DEFERRED_AUTHORIZE:
$text = __('Back-ordered', 'wcexaap');
break;
}
return $text;
}
/**
* Returns CSS class for the current state
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string
*/
public function getCssClass() {
return isset($this->cssClassMap[$this->state]) ? $this->cssClassMap[$this->state] : '';
}
/**
* Returns `false`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return bool
*/
public function isUnmodifiable() {
return false;
}
/**
* Getter for `state`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string
*/
public function getState() {
return $this->state;
}
/**
* Getter for `reasonCode`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string|null
*/
public function getReasonCode() {
return $this->reasonCode;
}
/**
* Getter for `reasonDescription`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string|null
*/
public function getReasonDescription() {
return $this->reasonDescription;
}
/**
* Getter for `cssClassMap`
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return string[]
*/
public function getCssClassMap() {
return $this->cssClassMap;
}
/**
* Returns JSON object when `json_encode` is invoked on an instance of this class
*
* @author Evan D Shaw <evandanielshaw@gmail.com>
* @return array
*/
public function jsonSerialize() {
return [
'state' => $this->state,
'reasonCode' => $this->reasonCode,
'reasonDescription' => $this->reasonDescription,
];
}
}
- __construct — Initializes a DeferredAuthorize `State` object
- getCssClass — Returns CSS class for the current state
- getCssClassMap — Getter for `cssClassMap`
- getDisplayText — Returns human-readable text representation of current state
- getReasonCode — Getter for `reasonCode`
- getReasonDescription — Getter for `reasonDescription`
- getState — Getter for `state`
- getTransactionId — Getter for `chargePermissionId`
- isUnmodifiable — Returns `false`
- jsonSerialize — Returns JSON object when `json_encode` is invoked on an instance of this class
- setChargePermissionId — Setter for `chargePermissionId`