• プラグイン一覧
    - WCEX Item Combo Set
    - WCEX Amazon Pay
    - WCEX Wishlist お気に入りリスト
  • リリース情報
  • お役立ちコラム
  • お問い合わせ
  • サポート
    • よくある質問
      • WCEX Amazon Pay
      • WCEX Wishlist お気に入りリスト
      • wcex-item-combo-set
    • リファレンス
      • WCEX Amazon Pay
      • WCEX Wishlist お気に入りリスト
      • wcex-item-combo-set
新規会員登録
ログイン
新規会員登録
ログイン
カート
  • プラグイン一覧
    • - WCEX Item Combo Set
    • - WCEX Amazon Pay
    • - WCEX Wishlist お気に入りリスト
  • リリース情報
  • お役立ちコラム
  • サポート
    • - よくある質問
      • - WCEX Amazon Pay
      • - WCEX Wishlist お気に入りリスト
      • - wcex-item-combo-set
    • - リファレンス
      • - WCEX Amazon Pay
      • - WCEX Wishlist お気に入りリスト
      • - wcex-item-combo-set
  • お問い合わせ
Aivec APPs > WCEX Amazon Pay > クラス > State
レファレンス
バージョン
2.6.4
絞り込み:

目次

  • ソース
  • 関数

フック

  • アクション
  • フィルター

ファンクション

    クラス

    State

    Model representing an Amazon Refund object state

    ソース #ソース

    ファイル: src/Models/Refund/State.php

    class State extends ErrorStore implements JsonSerializable, TransactionState
    {
    
        const REFUND_INITIATED = 'RefundInitiated';
        const REFUNDED = 'Refunded';
        const DECLINED = 'Declined';
    
        const STATE_TO_LOG_ACTION = [
            self::REFUND_INITIATED => Log::ACTION_ASYNC_REFUND,
            self::REFUNDED => Log::ACTION_REFUND,
        ];
    
        /**
         * Map of constant names and their corresponding values
         *
         * @var string[]
         */
        public static $stateMap = [
            'REFUND_INITIATED' => self::REFUND_INITIATED,
            'REFUNDED' => self::REFUNDED,
            'DECLINED' => self::DECLINED,
        ];
    
        /**
         * State to CSS class map
         *
         * @var string[]
         */
        private $cssClassMap = [
            self::REFUND_INITIATED => 'card-refund-init',
            self::REFUNDED => 'card-refunded',
            self::DECLINED => 'card-refund-declined',
        ];
    
        /**
         * `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 Refund `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;
            $this->populate();
        }
    
        /**
         * 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::REFUND_INITIATED:
                    $text = __('Refund Initiated', 'wcexaap');
                    break;
                case self::REFUNDED:
                    $text = __('Refunded', 'wcexaap');
                    break;
                case self::DECLINED:
                    $text = __('Refund Declined', '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 `GenericError` instance created from a `Declined` state.
         *
         * This method returns an `UNKNOWN_ERROR` `GenericError` instance if the state
         * is not declined.
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return GenericError
         */
        public function getErrorResponseFromDeclinedState() {
            $error = $this->getErrorResponse(self::UNKNOWN_ERROR);
    
            if ($this->state !== self::DECLINED) {
                return $error;
            }
    
            return $this->getErrorResponse($this->reasonCode, [$this->reasonDescription]);
        }
    
        /**
         * Returns `true` if state is 'RefundInitiated', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isRefundInitiated() {
            return $this->state === self::REFUND_INITIATED;
        }
    
        /**
         * Returns `true` if state is 'Refunded', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isRefunded() {
            return $this->state === self::REFUNDED;
        }
    
        /**
         * Returns `true` if state is 'Declined', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isDeclined() {
            return $this->state === self::DECLINED;
        }
    
        /**
         * Returns `true` if the state cannot be modified, `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isUnmodifiable() {
            return $this->state === self::REFUND_INITIATED;
        }
    
        /**
         * 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,
            ];
        }
    
        /**
         * `Refund` specific errors for a `Declined` state
         *
         * From the docs:
         *
         * **AmazonRejected** - Amazon rejected the refund. You should issue a refund to the buyer
         * in an alternate manner (for example, a gift card or store credit)
         *
         * **ProcessingFailure** - Amazon could not process the transaction because of an internal
         * processing error, or because the buyer has already received a refund from an A-to-z
         * claim, or a chargeback. You should only retry the refund if the Capture object is in
         * the Completed state. Otherwise, you should refund the buyer in an alternative way (for
         * example, a store credit or a check)
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return void
         * @throws InvalidArgumentException Thrown if the `errorcode` is already added.
         */
        public function populate() {
            // Declined
            $this->addError(new GenericError(
                DeclinedReasonCodes::AMAZON_REJECTED,
                'AMAZON_REJECTED',
                403,
                function ($message) {
                    return $message;
                },
                __('Amazon rejected the refund. You should issue a refund to the buyer in an alternate manner (for example, a gift card or store credit)', 'wcexaap')
            ));
            $this->addError(new GenericError(
                DeclinedReasonCodes::PROCESSING_FAILURE,
                'PROCESSING_FAILURE',
                500,
                function ($message) {
                    return $message;
                },
                __('Amazon could not process the transaction because of an internal processing error, or because the buyer has already received a refund from an A-to-z claim, or a chargeback', 'wcexaap')
            ));
        }
    }
    

    ソースを伸ばす ソースを縮める


    関数 #関数

    Top ↑

    • __construct — Initializes a Refund `State` object
    • getCssClass — Returns CSS class for the current state
    • getCssClassMap — Getter for `cssClassMap`
    • getDisplayText — Returns human-readable text representation of current state
    • getErrorResponseFromDeclinedState — Returns `GenericError` instance created from a `Declined` state.
    • getReasonCode — Getter for `reasonCode`
    • getReasonDescription — Getter for `reasonDescription`
    • getState — Getter for `state`
    • getTransactionId — Getter for `chargePermissionId`
    • isDeclined — Returns `true` if state is 'Declined', `false` otherwise
    • isRefunded — Returns `true` if state is 'Refunded', `false` otherwise
    • isRefundInitiated — Returns `true` if state is 'RefundInitiated', `false` otherwise
    • isUnmodifiable — Returns `true` if the state cannot be modified, `false` otherwise
    • jsonSerialize — Returns JSON object when `json_encode` is invoked on an instance of this class
    • populate — `Refund` specific errors for a `Declined` state
    • setChargePermissionId — Setter for `chargePermissionId`

    • 新規会員登録
    • ログイン
      • プラグイン一覧
      • 会社概要
      • リリース情報
      • よくある質問
      • お役立ちコラム
      • お問い合わせ
      • 個人情報保護方針
      • 特定商取引法に基づく表記
      • 情報セキュリティ基本方針
      • 利用規約

    アイベック合同会社は「Welcart」「Amazon Pay」の公式パートナーです。

    ※Amazon、Amazon.co.jp、Amazon Payおよびそれらのロゴは、Amazon.com,inc.またはその関連会社の商標です。
    ※LINE Pay、およびLINE Pay 提携サービスのロゴは、法律上保護を受ける商標です。

    © 2025 Aivec llc All Rights Reserved.