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

    ソース #ソース

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

    class State extends ErrorStore implements JsonSerializable
    {
    
        const CHARGEABLE = 'Chargeable';
        const NON_CHARGEABLE = 'NonChargeable';
        const CLOSED = 'Closed';
    
        /**
         * Map of constant names and their corresponding values
         *
         * @var string[]
         */
        public static $stateMap = [
            'CHARGEABLE' => self::CHARGEABLE,
            'NON_CHARGEABLE' => self::NON_CHARGEABLE,
            'CLOSED' => self::CLOSED,
        ];
    
        /**
         * `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 ChargePermission `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;
            parent::__construct();
            $this->populate();
        }
    
        /**
         * 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::CHARGEABLE:
                    $text = __('Chargeable', 'wcexaap');
                    break;
                case self::NON_CHARGEABLE:
                    $text = __('Non-Chargeable', 'wcexaap');
                    break;
                case self::CLOSED:
                    $text = __('Closed', 'wcexaap');
                    break;
            }
    
            return $text;
        }
    
        /**
         * Returns `GenericError` instance created from a `NonChargeable` state.
         *
         * This method returns an `UNKNOWN_ERROR` `GenericError` instance if the state
         * is not `NonChargeable`.
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return GenericError
         */
        public function getErrorResponseFromNonChargeableState() {
            $error = $this->getErrorResponse(self::UNKNOWN_ERROR);
    
            if ($this->state !== self::NON_CHARGEABLE) {
                return $error;
            }
    
            return $this->getErrorResponse($this->reasonCode, [$this->reasonDescription]);
        }
    
        /**
         * Returns `GenericError` instance created from a `Closed` state.
         *
         * This method returns an `UNKNOWN_ERROR` `GenericError` instance if the state
         * is not `Closed`.
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return GenericError
         */
        public function getErrorResponseFromClosedState() {
            $error = $this->getErrorResponse(self::UNKNOWN_ERROR);
    
            if ($this->state !== self::CLOSED) {
                return $error;
            }
    
            return $this->getErrorResponse($this->reasonCode, [$this->reasonDescription]);
        }
    
        /**
         * Returns `true` if state is 'Chargeable', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isChargeable() {
            return $this->state === self::CHARGEABLE;
        }
    
        /**
         * Returns `true` if state is 'NonChargeable', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isNonChargeable() {
            return $this->state === self::NON_CHARGEABLE;
        }
    
        /**
         * Returns `true` if state is 'Closed', `false` otherwise
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return bool
         */
        public function isClosed() {
            return $this->state === self::CLOSED;
        }
    
        /**
         * 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;
        }
    
        /**
         * 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,
            ];
        }
    
        /**
         * `ChargePermission` specific errors for a `NonChargeable` or `Closed` state
         *
         * Note that there are certain `reasonCodes` that do not necessarily indicate that
         * an error occured (ie. `MerchantCanceled`, `ChargeInProgress`, etc.).
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return void
         * @throws InvalidArgumentException Thrown if the `errorcode` is already added.
         */
        public function populate() {
            // NonChargeable
            $this->addError(new GenericError(
                NonChargeableReasonCodes::PAYMENT_METHOD_INVALID,
                'PAYMENT_METHOD_INVALID',
                422,
                function ($message) {
                    return $message;
                },
                __('The previous charge was declined. Ask the buyer to update the payment method', 'wcexaap')
            ));
            $this->addError(new GenericError(
                NonChargeableReasonCodes::PAYMENT_METHOD_DELETED,
                'PAYMENT_METHOD_DELETED',
                404,
                function ($message) {
                    return $message;
                },
                __('The buyer has deleted the selected payment method', 'wcexaap')
            ));
            $this->addError(new GenericError(
                NonChargeableReasonCodes::BILLING_ADDRESS_DELETED,
                'BILLING_ADDRESS_DELETED',
                404,
                function ($message) {
                    return $message;
                },
                __('The buyer has deleted the billing address of the selected payment method', 'wcexaap')
            ));
            $this->addError(new GenericError(
                NonChargeableReasonCodes::PAYMENT_METHOD_EXPIRED,
                'PAYMENT_METHOD_EXPIRED',
                422,
                function ($message) {
                    return $message;
                },
                __('The selected payment method has expired', 'wcexaap')
            ));
            $this->addError(new GenericError(
                NonChargeableReasonCodes::PAYMENT_METHOD_NOT_ALLOWED,
                'PAYMENT_METHOD_NOT_ALLOWED',
                403,
                function ($message) {
                    return $message;
                },
                __('The payment method selected by the buyer is not allowed for this Charge Permission', 'wcexaap')
            ));
            $this->addError(new GenericError(
                NonChargeableReasonCodes::PAYMENT_METHOD_NOT_SET,
                'PAYMENT_METHOD_NOT_SET',
                403,
                function ($message) {
                    return $message;
                },
                __('There is no payment method associated with this charge permission', 'wcexaap')
            ));
            $this->addError(new GenericError(
                NonChargeableReasonCodes::CHARGE_IN_PROGRESS,
                'CHARGE_IN_PROGRESS',
                409,
                function ($message) {
                    return $message;
                },
                __('A charge is already in progress. You cannot initiate a new charge unless previous charge is canceled', 'wcexaap')
            ));
            $this->addError(new GenericError(
                NonChargeableReasonCodes::MFA_FAILED,
                'MFA_FAILED',
                422,
                function ($message) {
                    return $message;
                },
                __('Buyer did not verify the transaction. Charge cannot be initiated unless buyer verifies the amount on the transaction', 'wcexaap')
            ));
    
            // Declined
            $this->addError(new GenericError(
                ClosedReasonCodes::MERCHANT_CLOSED,
                'MERCHANT_CLOSED',
                400,
                function ($message) {
                    return $message;
                },
                __('You closed the Charge Permission by calling Close Charge Permission operation', 'wcexaap')
            ));
            $this->addError(new GenericError(
                ClosedReasonCodes::BUYER_CANCELED,
                'BUYER_CANCELED',
                422,
                function ($message) {
                    return $message;
                },
                __('The buyer closed the Charge Permission', 'wcexaap')
            ));
            $this->addError(new GenericError(
                ClosedReasonCodes::AMAZON_CANCELED,
                'AMAZON_CANCELED',
                422,
                function ($message) {
                    return $message;
                },
                __('Amazon closed the Charge Permission', 'wcexaap')
            ));
            $this->addError(new GenericError(
                ClosedReasonCodes::AMAZON_CLOSED,
                'AMAZON_CLOSED',
                422,
                function ($message) {
                    return $message;
                },
                __('Amazon closed the Charge Permission since the Charge was Completed', 'wcexaap')
            ));
            $this->addError(new GenericError(
                ClosedReasonCodes::EXPIRED,
                'EXPIRED',
                422,
                function ($message) {
                    return $message;
                },
                __('The Charge Permission expired after 180 days', 'wcexaap')
            ));
        }
    }
    

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


    関数 #関数

    Top ↑

    • __construct — Initializes a ChargePermission `State` object
    • getDisplayText — Returns human-readable text representation of current state
    • getErrorResponseFromClosedState — Returns `GenericError` instance created from a `Closed` state.
    • getErrorResponseFromNonChargeableState — Returns `GenericError` instance created from a `NonChargeable` state.
    • getReasonCode — Getter for `reasonCode`
    • getReasonDescription — Getter for `reasonDescription`
    • getState — Getter for `state`
    • isChargeable — Returns `true` if state is 'Chargeable', `false` otherwise
    • isClosed — Returns `true` if state is 'Closed', `false` otherwise
    • isNonChargeable — Returns `true` if state is 'NonChargeable', `false` otherwise
    • jsonSerialize — Returns JSON object when `json_encode` is invoked on an instance of this class
    • populate — `ChargePermission` specific errors for a `NonChargeable` or `Closed` state

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

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

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

    © 2025 Aivec llc All Rights Reserved.