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

目次

  • ソース
  • 関数

フック

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

ファンクション

    クラス

    API

    Amazon Pay V1 API methods for backwards compatibility

    ソース #ソース

    ファイル: src/V1/API.php

    class API
    {
        /**
         * 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;
        }
    
        /**
         * Captures and closes an ORO
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param string $authid
         * @param string $orderid
         * @return array
         */
        public function capturePayments($authid, $orderid) {
            $client = $this->module->getAmazonV1Client();
    
            $return_obj = [];
            $return_obj['method'] = 'capture';
            if (!$authid) {
                $return_obj['status'] = 'error';
                $return_obj['code'] = __('Authorization ID Does Not Exist', 'wcexaap');
                $return_obj['message'] = __('The Authorization ID used to confirm the order amount did not match any existing Amazon orders.', 'wcexaap');
                return $return_obj;
            }
    
            $request_parameters = [];
            $request_parameters['amazon_authorization_id'] = $authid;
            $auth_details_res = $client->getAuthorizationDetails($request_parameters);
            if ($client->success) {
                $auth_details = json_decode($auth_details_res->toJson());
                $total_amount = $auth_details->GetAuthorizationDetailsResult->AuthorizationDetails->AuthorizationAmount->Amount;
                $request_parameters = [];
                $request_parameters['amazon_authorization_id'] = $authid;
                $request_parameters['capture_reference_id'] = uniqid();
                $request_parameters['capture_amount'] = $total_amount;
    
                $capture_res = $client->capture($request_parameters);
                $capture_res_json = json_decode($capture_res->toJson());
    
                if ($client->success) {
                    $request_parameters = [];
                    $request_parameters['amazon_order_reference_id'] = $orderid;
                    $request_parameters['closure_reason'] = __('Item(s) shipped. Funds captured.', 'wcexaap');
                    $close_res = $client->closeOrderReference($request_parameters);
                    $return_obj['status'] = 'success';
                    $return_obj['message'] = __('Payments were successfully captured.', 'wcexaap');
                } else {
                    if ($capture_res_json->Error) {
                        $return_obj['status'] = 'error';
                        $code = $capture_res_json->Error->Code;
                        $return_obj['code'] = $code;
                        if ($code === 'InvalidAuthorizationStatus') {
                            $return_obj['message'] = $capture_res_json->Error->Message . __('Either this order has already been canceled, or payments have already been captured, thus completing the order.', 'wcexaap');
                        } else {
                            $return_obj['message'] = __('An unknown error occured while capturing payments for this order. Either the Authorization ID is incorrect or the order is too old.', 'wcexaap');
                        }
                    }
                }
            } else {
                $return_obj['status'] = 'error';
                $return_obj['code'] = 'GetAuthorizationDetails Error';
                $return_obj['message'] = __('Failed getting Auth details. The Authorization ID used to confirm the order amount did not match any existing Amazon orders.', 'wcexaap');
            }
            return $return_obj;
        }
    
        /**
         * Cancels an ORO
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param int $orderid
         * @return array
         */
        public function cancelOrder($orderid) {
            $client = $this->module->getAmazonV1Client();
            $return_obj = [];
            $return_obj['method'] = 'cancel';
            $request_parameters = [];
            $request_parameters['amazon_order_reference_id'] = $orderid;
            $res = $client->cancelOrderReference($request_parameters);
            $res_json = json_decode($res->toJson());
            if ($client->success) {
                $return_obj['status'] = 'success';
                $return_obj['message'] = __('Amazon order cancellation successful.', 'wcexaap');
            } elseif ($res_json->Error) {
                $return_obj['status'] = 'error';
                $return_obj['code'] = $res_json->Error->Code;
                $return_obj['message'] = $res_json->Error->Message . __('Either this order has already been canceled, or payments have already been captured, thus completing the order.', 'wcexaap');
            }
    
            return $return_obj;
        }
    }
    

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


    関数 #関数

    Top ↑

    • __construct — Sets `$module` member var with dependency injection.
    • cancelOrder — Cancels an ORO
    • capturePayments — Captures and closes an ORO

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

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

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

    © 2025 Aivec llc All Rights Reserved.