• プラグイン一覧
    - 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 CheckoutSession state

    ソース #ソース

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

    class State extends ErrorStore
    {
    
        const OPEN = 'Open';
        const CANCELED = 'Canceled';
        const COMPLETED = 'Completed';
    
        /**
         * `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;
    
        /**
         * Initializes a `AmazonOrderState` 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;
            parent::__construct();
            $this->populate();
        }
    
        /**
         * Returns `GenericError` instance created from a `Canceled` state.
         *
         * This method returns an `UNKNOWN_ERROR` `GenericError` instance if the state
         * is not canceled.
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return GenericError
         */
        public function getErrorResponseFromCanceledState() {
            $error = $this->getErrorResponse(self::UNKNOWN_ERROR);
    
            if ($this->state !== self::CANCELED) {
                return $error;
            }
    
            return $this->getErrorResponse($this->reasonCode, [$this->reasonDescription]);
        }
    
        /**
         * Returns `true` if state is 'Open', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isOpen() {
            return $this->state === self::OPEN;
        }
    
        /**
         * Returns `true` if state is 'Completed', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isCompleted() {
            return $this->state === self::COMPLETED;
        }
    
        /**
         * Returns `true` if state is 'Canceled', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isCanceled() {
            return $this->state === self::CANCELED;
        }
    
        /**
         * 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;
        }
    
        /**
         * `CheckoutSession` specific errors for a `Canceled` state
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return void
         * @throws InvalidArgumentException Thrown if the `errorcode` is already added.
         */
        public function populate() {
            $this->addError(new GenericError(
                CanceledReasonCodes::BUYER_CANCELED,
                'BUYER_CANCELED',
                400,
                function ($message) {
                    return $message;
                },
                __('The purchase was canceled', 'wcexaap')
            ));
            $this->addError(new GenericError(
                CanceledReasonCodes::EXPIRED,
                'EXPIRED',
                400,
                function ($message) {
                    return $message;
                },
                __('The checkout session has expired. Please try again', 'wcexaap')
            ));
            $this->addError(new GenericError(
                CanceledReasonCodes::AMAZON_CANCELED,
                'AMAZON_CANCELED',
                503,
                function ($message) {
                    return $message;
                },
                __('Amazon canceled the purchase due to service unavailability.', 'wcexaap')
            ));
            $this->addError(new GenericError(
                CanceledReasonCodes::DECLINED,
                'DECLINED',
                403,
                function ($message) {
                    return $message;
                },
                __('The purchase was declined by Amazon.', 'wcexaap')
            ));
        }
    }
    

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


    関数 #関数

    Top ↑

    • __construct — Initializes a `AmazonOrderState` object
    • getErrorResponseFromCanceledState — Returns `GenericError` instance created from a `Canceled` state.
    • getReasonCode — Getter for `reasonCode`
    • getReasonDescription — Getter for `reasonDescription`
    • getState — Getter for `state`
    • isCanceled — Returns `true` if state is 'Canceled', `false` otherwise
    • isCompleted — Returns `true` if state is 'Completed', `false` otherwise
    • isOpen — Returns `true` if state is 'Open', `false` otherwise
    • populate — `CheckoutSession` specific errors for a `Canceled` state

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

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

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

    © 2025 Aivec llc All Rights Reserved.