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

目次

  • ソース
  • 関数

フック

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

ファンクション

    クラス

    Checkout

    Welcart checkout hooks

    ソース #ソース

    ファイル: src/Checkout.php

    class Checkout extends CheckoutHooks
    {
        /**
         * `GenericError` instance if checkout failed, `null` otherwise
         *
         * @var GenericError|null
         */
        private $error = null;
    
        /**
         * `Get Checkout Session` JSON decoded response object
         *
         * @var array|null
         */
        private $checkoutResponse = null;
    
        /**
         * `Get Charge` JSON decoded response object
         *
         * @var array|null
         */
        private $chargeResponse = null;
    
        /**
         * Handles a redirect from the `amazonPayRedirectUrl` returned by Amazon
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @global \usc_e_shop $usces
         * @return void
         */
        public function handleCheckoutResult() {
            global $usces;
    
            $sessionId = $_REQUEST['amazonCheckoutSessionId'];
            $result = (new API\CheckoutSession\Complete($this->module))->post($sessionId);
            if ($result instanceof GenericError) {
                $this->error = $result;
                $this->setToErrorPage();
                return;
            }
    
            $this->checkoutResponse = json_decode($result['response'], true);
            $details = $this->checkoutResponse['statusDetails'];
            $checkoutSessionState = new Models\CheckoutSession\State(
                $details['state'],
                $details['reasonCode'],
                $details['reasonDescription']
            );
    
            if ($checkoutSessionState->isCanceled()) {
                $this->error = $checkoutSessionState->getErrorResponseFromCanceledState();
                $this->setToErrorPage();
                return;
            }
    
            // deferred authorization
            if ($checkoutSessionState->isOpen()) {
                $res = $usces->order_processing();
                if (strtolower($res) === 'ordercompletion') {
                    $this->setToCompletionPage();
                } else {
                    $this->setToErrorPage();
                }
                return;
            }
    
            if ($checkoutSessionState->isCompleted()) {
                $getChargeRes = (new API\Charge\Get($this->module))->get($this->checkoutResponse['chargeId']);
                if ($getChargeRes instanceof GenericError) {
                    $this->error = $getChargeRes;
                    $this->setToErrorPage();
                    return;
                }
                $this->chargeResponse = json_decode($getChargeRes['response'], true);
    
                $res = $usces->order_processing();
                if (strtolower($res) === 'ordercompletion') {
                    $this->setToCompletionPage();
                } else {
                    $this->setToErrorPage();
                }
                return;
            }
    
            $this->error = $this->module->errors->getErrorResponse(Errors\GenericErrorStore::UNKNOWN_ERROR);
            $this->setToErrorPage();
        }
    
        /**
         * Sets `$usces->page` to 'error' and adds redirect action
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @global \usc_e_shop $usces
         * @return void
         */
        public function setToErrorPage() {
            global $usces;
    
            $usces->page = 'error';
            add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_error');
            add_action('the_post', [$usces, 'action_cartFilter']);
            add_action('template_redirect', [$usces, 'template_redirect']);
        }
    
        /**
         * Sets `$usces->page` to 'ordercompletion' and adds redirect action
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @global \usc_e_shop $usces
         * @return void
         */
        public function setToCompletionPage() {
            global $usces;
    
            $usces->page = 'ordercompletion';
            add_filter('yoast-ga-push-after-pageview', 'usces_trackPageview_ordercompletion');
            add_action('the_post', [$usces, 'action_cartFilter']);
            add_action('template_redirect', [$usces, 'template_redirect']);
        }
    
        /**
         * Creates error HTML for error page
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param string $html
         * @return string
         */
        protected function errorPageMessage($html) {
            if ($this->error === null) {
                return $html;
            }
    
            return (new Views\CartErrorPage\CartErrorPage())->getErrorPageHtml($html, $this->error);
        }
    
        /**
         * Saves AmazonPay order meta data
         *
         * @author Evan D Shaw <evandanielshaw@gmail.com>
         * @param array $args {
         *     Welcart `$_SESSION` variables
         *
         *     @type array  $cart
         *     @type array  $entry
         *     @type int    $order_id
         *     @type int    $member_id
         *     @type array  $payments
         *     @type string $charging_type
         *     @type array  $results
         * }
         * @return void
         */
        protected function registerOrderData($args) {
            if ($this->error === null) {
                $order = (new API\WelcartEntries())->getOrder();
                $chargeState = null;
                if ($this->chargeResponse !== null) {
                    $chargeState = new Models\Charge\State(
                        $this->chargeResponse['statusDetails']['state'],
                        $this->chargeResponse['statusDetails']['reasonCode'],
                        $this->chargeResponse['statusDetails']['reasonDescription']
                    );
                }
                OrderMeta::saveOrderMetaDataFromCheckoutSession(
                    $this->checkoutResponse,
                    (int)$args['order_id'],
                    $order['total_full_price'],
                    usces_crcode('return'),
                    $chargeState
                );
            }
        }
    }
    

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


    関数 #関数

    Top ↑

    • errorPageMessage — Creates error HTML for error page
    • handleCheckoutResult — Handles a redirect from the `amazonPayRedirectUrl` returned by Amazon
    • registerOrderData — Saves AmazonPay order meta data
    • setToCompletionPage — Sets `$usces->page` to 'ordercompletion' and adds redirect action
    • setToErrorPage — Sets `$usces->page` to 'error' and adds redirect action

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

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

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

    © 2025 Aivec llc All Rights Reserved.