クラス
Confirm
ソース ソース
ファイル: src/Api/Confirm.php
class Confirm extends CheckoutHooks { /** * Settlement module * * @var LinePay */ protected $module; /** * Error object * * @var null|GenericError */ private $error = null; /** * Abort fulfillment if transaction data does not exist in DB * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array $get $_GET with $transactionId generated by LINE * @return void */ public function middleware($get) { if (get_option($get['transactionId']) === false) { exit(); } } /** * Fulfill a reserved payment * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \usc_e_shop $usces * @param array $get $_GET with $transactionId generated by LINE * @return void */ public function fulfillOrder($get) { global $usces; $transactionId = $get['transactionId']; $order_data = get_option($transactionId); $_SESSION['usces_entry'] = $order_data['usces_entry']; $_SESSION['usces_member'] = $order_data['usces_member']; $_SESSION['usces_cart'] = []; // reserialize cart for usces' cart class foreach ($order_data['usces_cart'] as $obj) { $_SESSION['usces_cart'][$obj['serial']] = [ 'quant' => $obj['quantity'], 'price' => $obj['price'], ]; } $payload = [ 'amount' => $order_data['total'], 'currency' => $order_data['currency'], ]; $confirmres = $this->module->api->confirm($payload, $transactionId); if ($confirmres instanceof GenericError) { // remove tracking delete_option($transactionId); $this->error = $confirmres; $this->errorPageRedirect(); return; } $results = []; $usces_entries = $usces->cart->get_entry(); $payments = $usces->getPayments($usces_entries['order']['payment_name']); /** * Welcart filter * * @ignore */ $nonacting_settlements = apply_filters('usces_filter_nonacting_settlements', $usces->nonacting_settlements); $res = usces_check_acting_return_duplicate($results); if ($res != null && !in_array($payments['settlement'], $nonacting_settlements)) { usces_log('order processing duplicate : acting=' . $order_data['acting'] . ', order_id=' . $res, 'acting_transaction.log'); } $order_id = usces_reg_orderdata($results); if (empty($order_id)) { // remove tracking delete_option($transactionId); $this->error = $this->module->clientErrorStore->getErrorCodeMap()[ErrorStore::INTERNAL_SERVER_ERROR]; $this->errorPageRedirect(); return; } $state = $order_data['capture_now'] ? TransactionState::CAPTURED : TransactionState::AUTHORIZED; $line_order_data = [ 'transactionId' => $transactionId, 'total' => $order_data['total'], 'currency' => $order_data['currency'], 'line_request_res' => $order_data['line_request_res'], 'line_confirm_res' => $confirmres, ]; OrderMeta::registerOrderMeta(new TransactionState($transactionId, $state), $line_order_data, $order_id); $mail_res = usces_send_ordermail($order_id); // remove tracking delete_option($transactionId); $this->completionPageRedirect(); } /** * Creates error message for error page * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param array $html * @return string */ protected function errorPageMessage($html) { if ($this->error === null) { return $html; } $html = (new Views\CartErrorPage\CartErrorPage())->getErrorPageHtml( $html, $this->error->errorcode, $this->error->message ); return $html; } /** * Redirects to error page * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \usc_e_shop $usces * @return void */ public function errorPageRedirect() { 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']); } /** * Redirects to order completion page * * @author Evan D Shaw <evandanielshaw@gmail.com> * @global \usc_e_shop $usces * @return void */ public function completionPageRedirect() { 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']); } }
- completionPageRedirect — Redirects to order completion page
- errorPageMessage — Creates error message for error page
- errorPageRedirect — Redirects to error page
- fulfillOrder — Fulfill a reserved payment
- middleware — Abort fulfillment if transaction data does not exist in DB