• プラグイン一覧
    - 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 > クラス > Close
レファレンス
バージョン
2.6.4
絞り込み:

目次

  • ソース
  • 関数

フック

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

ファンクション

    クラス

    Close

    Amazon Pay V2 SDK Close Charge Permission.

    ソース #ソース

    ファイル: src/API/ChargePermission/Close.php

    class Close extends ErrorStore
    {
        const INVALID_CHARGE_PERMISSION_STATUS = 'InvalidChargePermissionStatus';
    
        /**
         * AmazonPay module object
         *
         * @var AmazonPay
         */
        private $module;
    
        /**
         * Sets `$module` member var with dependency injection.
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param AmazonPay $module
         * @return void
         */
        public function __construct(AmazonPay $module) {
            $this->module = $module;
            parent::__construct();
            $this->populate();
        }
    
        /**
         * Closes a Charge Permission
         *
         * @see https://developer.amazon.com/docs/amazon-pay-api-v2/charge-permission.html#close-charge-permission
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param string $chargePermissionId Charge Permission ID
         * @param string $closureReason
         * @param bool   $cancelPendingCharges
         * @return array
         */
        public function delete($chargePermissionId, $closureReason, $cancelPendingCharges = false) {
            try {
                $client = $this->module->getAmazonClient();
                $result = $client->closeChargePermission($chargePermissionId, [
                    'closureReason' => $closureReason,
                    'cancelPendingCharges' => $cancelPendingCharges,
                ]);
                if ($this->module->errors->hasError($result)) {
                    return $this->module->errors->getAmzErrorResponse($result);
                }
            } catch (\Exception $e) {
                return $this->module->errors->getErrorResponse(
                    GenericErrorStore::AMAZON_PAY_SDK_CLIENT_EXCEPTION,
                    [$e->getMessage()]
                );
            }
    
            return $result;
        }
    
        /**
         * Populates error store
         *
         * @see https://developer.amazon.com/docs/amazon-pay-api-v2/charge-permission.html#error-codes-2
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @return void
         * @throws InvalidArgumentException Thrown if duplicate errorcodes exist.
         */
        public function populate() {
            $this->addError(new GenericError(
                self::INVALID_CHARGE_PERMISSION_STATUS,
                $this->getConstantNameByValue(self::INVALID_CHARGE_PERMISSION_STATUS),
                422,
                function ($message) {
                    return $message;
                },
                __('You tried to call an operation on a Charge Permission that is in a state where that operation cannot be called', 'wcexaap')
            ));
        }
    }
    

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


    関数 #関数

    Top ↑

    • __construct — Sets `$module` member var with dependency injection.
    • delete — Closes a Charge Permission
    • populate — Populates error store

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

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

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

    © 2025 Aivec llc All Rights Reserved.