app/Plugin/VeriTrans4G2/Service/Payment/BaseService.php line 993

Open in your IDE?
  1. <?php
  2. /*
  3.  * Copyright (c) 2018 VeriTrans Inc., a Digital Garage company. All rights reserved.
  4.  * http://www.veritrans.co.jp/
  5.  */
  6. namespace Plugin\VeriTrans4G2\Service\Payment;
  7. use Doctrine\DBAL\Exception\DriverException;
  8. use Doctrine\DBAL\Exception\LockWaitTimeoutException;
  9. use Doctrine\DBAL\LockMode;
  10. use Plugin\VeriTrans4G2\Entity\Vt4gPaymentMethod;
  11. use Plugin\VeriTrans4G2\Entity\Vt4gOrderPayment;
  12. use Plugin\VeriTrans4G2\Entity\Vt4gOrderLog;
  13. use Eccube\Entity\Order;
  14. use Eccube\Entity\Master\OrderStatus;
  15. use Eccube\Service\MailService;
  16. use Eccube\Service\PurchaseFlow\PurchaseContext;
  17. use Eccube\Service\PurchaseFlow\PurchaseFlow;
  18. use Eccube\Security\Core\Encoder\PasswordEncoder;
  19. use Eccube\Service\CartService;
  20. use Psr\Container\ContainerInterface;
  21. use Symfony\Component\HttpFoundation\Response;
  22. use Symfony\Component\Mailer\MailerInterface;
  23. use tgMdk\TGMDK_Transaction;
  24. use tgMdk\dto\BankAuthorizeRequestDto;
  25. use tgMdk\dto\CvsAuthorizeRequestDto;
  26. use tgMdk\dto\CardCancelRequestDto;
  27. use tgMdk\dto\CvsCancelRequestDto;
  28. use tgMdk\dto\UpopCancelRequestDto;
  29. use tgMdk\dto\RakutenCancelRequestDto;
  30. use tgMdk\dto\RecruitCancelRequestDto;
  31. use tgMdk\dto\LinepayCancelRequestDto;
  32. use tgMdk\dto\AlipayRefundRequestDto;
  33. use tgMdk\dto\PaypalCancelRequestDto;
  34. use tgMdk\dto\PaypayCancelRequestDto;
  35. use tgMdk\dto\UpopCaptureRequestDto;
  36. use tgMdk\dto\RakutenCaptureRequestDto;
  37. use tgMdk\dto\RecruitCaptureRequestDto;
  38. use tgMdk\dto\LinepayCaptureRequestDto;
  39. use tgMdk\dto\PaypalCaptureRequestDto;
  40. use tgMdk\dto\UpopRefundRequestDto;
  41. use tgMdk\dto\PaypalRefundRequestDto;
  42. use tgMdk\dto\PaypayCaptureRequestDto;
  43. use tgMdk\dto\PaypayRefundRequestDto;
  44. use tgMdk\dto\RakutenUpdateAuthorizeRequestDto;
  45. use Twig\Environment;
  46. /**
  47.  * 決済処理 基底クラス
  48.  */
  49. class BaseService
  50. {
  51.     public $mailData = [];
  52.     public $logData  = [];
  53.     public $timeKey '';
  54.     public $isPaymentRecv false;
  55.     /**
  56.      * コンテナ
  57.      */
  58.     protected $container;
  59.     /**
  60.      * エンティティーマネージャー
  61.      */
  62.     protected $em;
  63.     /**
  64.      * 汎用処理用サービス
  65.      */
  66.     protected $util;
  67.     /**
  68.      * VT用固定値配列
  69.      */
  70.     protected $vt4gConst;
  71.     /**
  72.      * MDK Logger
  73.      */
  74.     protected $mdkLogger;
  75.     /**
  76.      * パスワードエンコーダ
  77.      */
  78.     protected $passwordEncoder;
  79.     /**
  80.      * カートサービス
  81.      */
  82.     protected $cartService;
  83.     /**
  84.      * メールサービス
  85.      */
  86.     protected $mailService;
  87.     /**
  88.      * 決済結果
  89.      */
  90.     protected $paymentResult;
  91.     /**
  92.      * 決済エラー時デフォルトメッセージ
  93.      */
  94.     protected $defaultErrorMessage;
  95.     /**
  96.      * @var PurchaseFlow
  97.      */
  98.     protected $purchaseFlow;
  99.     /**
  100.      * メーラー
  101.      */
  102.     protected $mailer;
  103.     /**
  104.      * @var Environment twigオブジェクト
  105.      */
  106.     protected $twig;
  107.     /**
  108.      * コンストラクタ
  109.      *
  110.      * @param ContainerInterface $container
  111.      * @param PurchaseFlow $shoppingPurchaseFlow
  112.      * @param PasswordEncoder $passwordEncoder
  113.      * @param CartService $cartService
  114.      * @param MailService $mailService
  115.      * @param MailerInterface $mailer
  116.      *
  117.      * @return void
  118.      */
  119.     public function __construct(
  120.         ContainerInterface $container,
  121.         PurchaseFlow $shoppingPurchaseFlow,
  122.         PasswordEncoder $passwordEncoder,
  123.         CartService $cartService,
  124.         MailService $mailService,
  125.         MailerInterface $mailer
  126.     ){
  127.         $this->container $container;
  128.         $mdkService $this->container->get('vt4g_plugin.service.vt4g_mdk');
  129.         $mdkService->checkMdk();
  130.         $this->mdkLogger $mdkService->getMdkLogger();
  131.         $this->util $container->get('vt4g_plugin.service.util');
  132.         $this->passwordEncoder $passwordEncoder;
  133.         $this->cartService $cartService;
  134.         $this->mailService $mailService;
  135.         $this->mailer $mailer;
  136.         $this->em $container->get('doctrine.orm.entity_manager');
  137.         $this->vt4gConst $this->container->get(\Eccube\Common\EccubeConfig::class)->get('vt4g_plugin.const');
  138.         $this->purchaseFlow $shoppingPurchaseFlow;
  139.         $this->defaultErrorMessage trans('vt4g_plugin.payment.shopping.error');
  140.     }
  141.     /**
  142.      * 各決済方法の共通チェック処理
  143.      *
  144.      * @param  Order|null     $order 注文データ
  145.      * @return boolean|object        チェック結果|ビューレスポンス
  146.      */
  147.     public function checkPaymentData($order)
  148.     {
  149.         // 注文データが存在しない場合
  150.         if (empty($order)) {
  151.             return $this->makeErrorResponse();
  152.         }
  153.         // 注文ステータスを取得
  154.         $orderStatus $order->getOrderStatus()->getId();
  155.         // 新規受付
  156.         $isNew $orderStatus == OrderStatus::NEW;
  157.         // 入金済み
  158.         $isPaid $orderStatus == OrderStatus::PAID;
  159.         // 決済処理中
  160.         $isPending $orderStatus == OrderStatus::PENDING;
  161.         // 新規受付 or 入金済み or 決済処理中以外の場合はエラー画面を表示
  162.         return !($isNew || $isPaid || $isPending)
  163.             ? $this->makeErrorResponse()
  164.             : true;
  165.     }
  166.     /**
  167.      * 管理画面からの決済操作時の更新処理
  168.      *
  169.      * @param  object $orderPayment    決済データ
  170.      * @param  object $operationResult MDKリクエスト結果データ
  171.      * @param  string $orderStatus     注文ステータス
  172.      * @return void
  173.      */
  174.     public function updateByAdmin($orderPayment$operationResult$orderStatus '')
  175.     {
  176.         $payStatus $operationResult['payStatus'];
  177.         $hasCaptureTotal = isset($operationResult['captureTotal']);
  178.         $hasCardAmout = isset($operationResult['card_amount']);
  179.         $memo10 = [];
  180.         if ($hasCaptureTotal) {
  181.             $memo10 unserialize($orderPayment->getMemo10());
  182.             $memo10['captureTotal'] = $operationResult['captureTotal'];
  183.             // 返金操作 かつ 残りの金額がある場合は「売上」・ない場合は「取消」
  184.             if ($payStatus == $this->vt4gConst['VT4G_PAY_STATUS']['REFUND']['VALUE']) {
  185.                 $payStatus $operationResult['captureTotal'] == 0
  186.                     $this->vt4gConst['VT4G_PAY_STATUS']['CANCEL']['VALUE']
  187.                     : $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE']['VALUE'];
  188.             }
  189.             // 取消の場合 売上時金額を0にする
  190.             if ($payStatus == $this->vt4gConst['VT4G_PAY_STATUS']['CANCEL']['VALUE']) {
  191.                 $memo10['captureTotal'] = 0;
  192.             }
  193.         } else if ($hasCardAmout) {
  194.             $memo10 unserialize($orderPayment->getMemo10());
  195.             $memo10['card_amount'] = $operationResult['card_amount'];
  196.         }
  197.         if ($operationResult['isNewly'] ?? false) {
  198.             $orderPayment->setMemo01($operationResult['orderId']);
  199.             if (isset($operationResult['customerId'])) {
  200.                 $orderPayment->setMemo02($operationResult['customerId']);
  201.             }
  202.             $orderPayment->setMemo06(serialize($this->mailData));
  203.             if($hasCardAmout) {
  204.                 $memo10['card_type'] = $operationResult['card_type'];
  205.                 $orderPayment->setMemo07($operationResult['cardNumber']);
  206.             }
  207.             if(isset($operationResult['rollbackDate'])) {
  208.                 $orderPayment->setRollbackDate($operationResult['rollbackDate']);
  209.             }
  210.         }
  211.         $orderPayment->setMemo04($payStatus);
  212.         $orderPayment->setMemo05(serialize($operationResult));
  213.         if ($hasCaptureTotal || $hasCardAmout) {
  214.             $orderPayment->setMemo10(serialize($memo10));
  215.         }
  216.         $this->em->persist($orderPayment);
  217.         //決済ステータスが売上に更新し、注文ステータスが新規受付の場合は注文ステータスを入金済に変更する。
  218.         if($orderStatus === OrderStatus::NEW && $payStatus === $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE']['VALUE']){
  219.             $orderStatus $this->em->getRepository(OrderStatus::class)->find(OrderStatus::PAID);
  220.             if(!empty($orderStatus)){
  221.                 $this->em->getRepository(Order::class)->changeStatus($orderPayment->getOrderId(), $orderStatus);
  222.             }
  223.         }
  224.         // ログ情報
  225.         $orderLog = new Vt4gOrderLog;
  226.         $orderLog->setOrderId($orderPayment->getOrderId());
  227.         $orderLog->setVt4gLog(serialize($this->logData));
  228.         $this->em->persist($orderLog);
  229.     }
  230.     /**
  231.      * MDK仕様の受注番号を返す
  232.      *
  233.      * @param  integer $orderId 受注番号
  234.      * @return string         MDK仕様の受注番号
  235.      */
  236.     protected function getMdkOrderId($orderId)
  237.     {
  238.         $pluginSetting $this->util->getPluginSetting();
  239.         $orderIdPrefix $pluginSetting['vt4g_order_id_prefix'];
  240.         // ランダム文字列を生成
  241.         $random bin2hex($this->passwordEncoder->createSalt(4));
  242.         // プレフィックス + ランダム文字列 + 0埋めされた受注番号
  243.         return $orderIdPrefix.$random.$this->util->zeroPadding($orderId11);
  244.     }
  245.     /**
  246.      * 注文ステータスの変更
  247.      *
  248.      * @param  object  $order       注文データ
  249.      * @param  integer $withCapture 処理区分
  250.      * @return boolean              変更したかどうか
  251.      */
  252.     protected function setNewOrderStatus($order$withCapture)
  253.     {
  254.         $paymentMethod $this->util->getPaymentMethod($order->getPayment()->getId());
  255.         // 各決済の新規注文時の決済ステータスを判定
  256.         $status $this->getNewOrderStatus($paymentMethod$withCapture);
  257.         // ステータスの設定が存在しなければエラー
  258.         if (empty($status)) {
  259.             return false;
  260.         }
  261.         // ステータスの登録
  262.         $orderStatus $this->em->getRepository(OrderStatus::class)->find($status);
  263.         if (empty($orderStatus)) {
  264.             return false;
  265.         }
  266.         $nowOrderStatusId $order->getOrderStatus()->getId();
  267.         if ($nowOrderStatusId === OrderStatus::NEW || $nowOrderStatusId === OrderStatus::PENDING) {
  268.             $this->em->getRepository(Order::class)->changeStatus($order->getId(), $orderStatus);
  269.         }
  270.         return true;
  271.     }
  272.     /**
  273.      * レスポンスの初期化
  274.      *
  275.      * @return array 初期化されたレスポンス
  276.      */
  277.     protected function initPaymentResult()
  278.     {
  279.         $this->paymentResult = [
  280.             'isOK'        => false,
  281.             'vResultCode' => 'error',
  282.             'mErrMsg'     => trans('vt4g_plugin.payment.shopping.system.error')
  283.         ];
  284.         return $this->paymentResult;
  285.     }
  286.     /**
  287.      * 受注完了処理
  288.      *
  289.      * @param  Order  $order    注文データ
  290.      * @param  Vt4gOrderPayment $orderPayment 注文に紐づく決済データ
  291.      * @param  array  $payment  処理中の決済データ
  292.      * @param  array  $logData  ログ情報
  293.      * @param  array  $mailData メール情報
  294.      * @param  string $token    MDKトークン
  295.      * @return void
  296.      */
  297.     protected function completeOrder($order$orderPayment$payment$logData = [], $mailData = [], $token '')
  298.     {
  299.         // メッセージ追加(結果通知のときは画面を出さないので追加しない)
  300.         if (!$this->isPaymentRecv) {
  301.             $payment['orderCompleteFlg'] = true;
  302.             $this->addOrderCompleteMessage($order);
  303.         }
  304.         try {
  305.             // 受注更新
  306.             $this->updateOrder($order$orderPayment$payment$logData$mailData$token);
  307.         } catch (\Doctrine\DBAL\Exception $e) {
  308.             $msg $e->getMessage();
  309.             if(strpos($msg,'deadlock') !== false || strpos($msg,'Deadlock') !== false) {
  310.                 $this->isPaymentRecv
  311.                     $this->mdkLogger->info(sprintf(trans('vt4g_plugin.db.deadlock'),'結果通知'))
  312.                     : $this->mdkLogger->info(sprintf(trans('vt4g_plugin.db.deadlock'),'決済センター戻り'));
  313.             } else {
  314.                 $this->mdkLogger->error($e->getMessage());
  315.                 throw $e;
  316.             }
  317.         }
  318.         // カートを削除
  319.         $cartService $this->cartService;
  320.         $cartService->clear();
  321.         // メール送信
  322.         if ($this->shouldSendMail($order$orderPayment)) {
  323.             $this->sendOrderMail($order);
  324.             $this->updateSentOrderMailToSent($orderPayment);
  325.         }
  326.         if (!$this->isPaymentRecv) {
  327.             $this->em->commit();
  328.         }
  329.     }
  330.     /**
  331.      * 決済情報への追加処理
  332.      *
  333.      * @param  Order            $order    注文データ
  334.      * @param  Vt4gOrderPayment $orderPayment 注文に紐づく決済データ
  335.      * @param  array            $payment  処理中の決済データ
  336.      * @param  array            $logData  ログ情報
  337.      * @param  array            $mailData メール情報
  338.      * @param  string           $token    MDKトークン
  339.      * @return Vt4gOrderPayment           決済情報
  340.      */
  341.     protected function setOrderPayment($order$orderPayment$payment$logData = [], $mailData = [], $token '')
  342.     {
  343.         $paymentMethod $this->em->getRepository(Vt4gPaymentMethod::class)->find($order->getPayment()->getId());
  344.         $customer $order->getCustomer();
  345.         if (empty($payment)) {
  346.             return $orderPayment;
  347.         }
  348.         // 各カラムに値を設定
  349.         $orderPayment->setOrderId($order->getId());
  350.         $orderPayment->setMemo01($payment['orderId']);
  351.         if (!empty($customer)) {
  352.             $orderPayment->setMemo02($customer->getId());
  353.         }
  354.         $orderPayment->setMemo03($paymentMethod->getMemo03());
  355.         if (isset($payment['payStatus']) && empty($orderPayment->getMemo04())) {
  356.             $orderPayment->setMemo04($payment['payStatus']);
  357.         }
  358.         $orderPayment->setMemo05(serialize($payment));
  359.         if (!empty($mailData)) {
  360.             $orderPayment->setMemo06(serialize($mailData));
  361.         }
  362.         if (isset($payment['cardNumber'])) {
  363.             $orderPayment->setMemo07($payment['cardNumber']);
  364.         }
  365.         if (!empty($token)) {
  366.             $orderPayment->setMemo08($token);
  367.         }
  368.         if (isset($payment['captureTotal'])) {
  369.             $memo10 unserialize($orderPayment->getMemo10());
  370.             $memo10['captureTotal'] = $payment['captureTotal'];
  371.             $orderPayment->setMemo10(serialize($memo10));
  372.         }
  373.         if (isset($payment['refundFlg'])) {
  374.             $memo10 unserialize($orderPayment->getMemo10());
  375.             $memo10['refundFlg'] = $payment['refundFlg'];
  376.             $orderPayment->setMemo10(serialize($memo10));
  377.         }
  378.         if (isset($payment['lastPayStatus'])) {
  379.             $memo10 unserialize($orderPayment->getMemo10());
  380.             $memo10['lastPayStatus'] = $payment['lastPayStatus'];
  381.             $orderPayment->setMemo10(serialize($memo10));
  382.         }
  383.         if (isset($payment['cardType'])) {
  384.             $memo10 = [];
  385.             if (unserialize($orderPayment->getMemo10()) === false) {
  386.                 $memo10['card_amount'] = '';
  387.             } else {
  388.                 $memo10 unserialize($orderPayment->getMemo10());
  389.             }
  390.             $memo10['card_type'] = $payment['cardType'];
  391.             $orderPayment->setMemo10(serialize($memo10));
  392.         }
  393.         if (isset($payment['cardAmount'])) {
  394.             $memo10 unserialize($orderPayment->getMemo10());
  395.             $memo10['card_amount'] = $payment['cardAmount'];
  396.             $orderPayment->setMemo10(serialize($memo10));
  397.         }
  398.         if (isset($payment['orderCompleteFlg'])) {
  399.             $memo10 unserialize($orderPayment->getMemo10());
  400.             $memo10['orderCompleteFlg'] = $payment['orderCompleteFlg'];
  401.             $orderPayment->setMemo10(serialize($memo10));
  402.         }
  403.         if (isset($payment['sentOrderMail'])) {
  404.             $memo10 unserialize($orderPayment->getMemo10());
  405.             $memo10['sentOrderMail'] = $payment['sentOrderMail'];
  406.             $orderPayment->setMemo10(serialize($memo10));
  407.         }
  408.         // 少額与信の使用有無を記録
  409.         if (isset($payment['useFewCredit'])) {
  410.             $memo10 unserialize($orderPayment->getMemo10());
  411.             $memo10['useFewCredit'] = $payment['useFewCredit'];
  412.             $orderPayment->setMemo10(serialize($memo10));
  413.         }
  414.         // かんたん決済の利用有無を記録
  415.         if (isset($payment['doRegistReTradeCardinfo'])) {
  416.             $memo10 unserialize($orderPayment->getMemo10());
  417.             $memo10['doRegistReTradeCardinfo'] = $payment['doRegistReTradeCardinfo'];
  418.             $orderPayment->setMemo10(serialize($memo10));
  419.         }
  420.         // カード名義を記録
  421.         if (isset($payment['cardName'])) {
  422.             $memo10 unserialize($orderPayment->getMemo10());
  423.             $memo10['cardName'] = $payment['cardName'];
  424.             $orderPayment->setMemo10(serialize($memo10));
  425.         }
  426.         // ロールバック日時
  427.         if (isset($payment['rollbackDate'])) {
  428.             $orderPayment->setRollbackDate($payment['rollbackDate']);
  429.         }
  430.         $this->em->persist($orderPayment);
  431.         $this->em->flush();
  432.         return $orderPayment;
  433.     }
  434.     /**
  435.      * 決済ログテーブルにログを追加
  436.      *
  437.      * @param  Order $order    注文データ
  438.      */
  439.     protected function setOrderLog($order)
  440.     {
  441.         if (empty($this->logData)) {
  442.             return false;
  443.         }
  444.         $orderLogMethod = new Vt4gOrderLog;
  445.         $orderLogMethod->setOrderId($order->getId());
  446.         $orderLogMethod->setVt4gLog(serialize($this->logData));
  447.         $this->em->persist($orderLogMethod);
  448.         $this->em->flush();
  449.         return $orderLogMethod;
  450.     }
  451.     /**
  452.      * 注文データの更新
  453.      *
  454.      * @param  Order  $order    注文データ
  455.      * @param  Vt4gOrderPayment $orderPayment 注文に紐づく決済データ
  456.      * @param  array  $payment  処理中の決済データ
  457.      * @param  array  $logData  ログ情報
  458.      * @param  array  $mailData メール情報
  459.      * @param  string $token    MDKトークン
  460.      * @return void
  461.      */
  462.     protected function updateOrder($order$orderPayment$payment$logData = [], $mailData = [], $token '')
  463.     {
  464.         // 注文情報の確定(決済ステータスが値なしの場合のみ実行)
  465.         if (empty($orderPayment) || empty($orderPayment->getMemo04())) {
  466.             $this->purchaseFlow->commit($order, new PurchaseContext());
  467.         }
  468.         // 決済情報の更新
  469.         $this->setOrderPayment($order$orderPayment$payment$logData$mailData$token);
  470.         // 決済ログテーブルにログを追加
  471.         $this->setOrderLog($order);
  472.         // ステータスの更新
  473.         $withCapture = isset($payment['withCapture']) ? $payment['withCapture'] : 0;
  474.         $this->setNewOrderStatus($order$withCapture);
  475.         $this->em->flush();
  476.     }
  477.     /**
  478.      * メールタイトルの設定
  479.      *
  480.      * @param  string $title タイトル
  481.      * @return void
  482.      */
  483.     protected function setMailTitle($title)
  484.     {
  485.         $this->mailData['title'] = $title;
  486.     }
  487.     /**
  488.      * メールの説明
  489.      *
  490.      * @param string $explan 説明文
  491.      * @return void
  492.      */
  493.     public function setMailExplan($explan)
  494.     {
  495.         $this->mailData['explan'] = $explan;
  496.     }
  497.     /**
  498.      * メール情報の追加
  499.      *
  500.      * @param  string $title   タイトル
  501.      * @param  string $content 本文
  502.      * @return void
  503.      */
  504.     protected function setMailInfo($title$content)
  505.     {
  506.         $this->mailData['message'][] = compact('title''content');
  507.     }
  508.     /**
  509.      * メール情報の追加(広告)
  510.      *
  511.      * @param string $vResultCode 処理結果コード
  512.      * @param string $tradUrl     広告URL
  513.      * @return void
  514.      */
  515.     public function setMailAd($vResultCode$tradUrl)
  516.     {
  517.         $this->mailData['message'][] = array(
  518.                 'vResultCode'=>$vResultCode,
  519.                 'tradUrl'=>$tradUrl,
  520.         );
  521.     }
  522.     /**
  523.      * 決済方法ごとのメール設定を反映
  524.      *
  525.      * @param  object|null $paymentMethod PaymentMethodクラスインスタンス
  526.      * @return void
  527.      */
  528.     protected function setMailAdminSetting($paymentMethod)
  529.     {
  530.         if (empty($paymentMethod)) {
  531.             return;
  532.         }
  533.         $memo05 unserialize($paymentMethod->getMemo05());
  534.         $title  $memo05['order_mail_title1'] ?? null;
  535.         $body   $memo05['order_mail_body1'] ?? null;
  536.         // タイトル・本文が両方設定されている場合のみ追加
  537.         if (isset($title$body)) {
  538.             $this->setMailInfo($title$body);
  539.         }
  540.     }
  541.     /**
  542.      * ログ情報の先頭部分
  543.      *
  544.      * @param  integer $payId         決済方法の内部ID
  545.      * @param  string  $timeKey       ログキー(現在時間)
  546.      * @param  array   $paymentResult 決済リクエスト結果データ
  547.      * @param  string  $payName       決済方法の名称
  548.      * @return void
  549.      */
  550.     public function setLogHead($payId$timeKey ''$paymentResult null$payName null)
  551.     {
  552.         if (is_null($paymentResult)) {
  553.             $paymentResult $this->paymentResult;
  554.         }
  555.         $this->timeKey $timeKey;
  556.         $this->logData = array();
  557.         $payStatusName $this->util->getPaymentStatusName($paymentResult['payStatus']);
  558.         if ($paymentResult['mStatus'] == $this->vt4gConst['VT4G_RESPONSE']['MSTATUS']['OK']) {
  559.             $msg '成功';
  560.         } elseif ($paymentResult['mStatus'] == $this->vt4gConst['VT4G_RESPONSE']['MSTATUS']['PENDING']) {
  561.             $msg '保留';
  562.         } else {
  563.             $msg '失敗';
  564.         }
  565.         $this->setLogInfo('決済取引ID'$paymentResult['orderId']);
  566.         $this->setLogInfo($payName ?? $this->util->getPayName($payId), "[$payStatusName]" $msg);
  567.     }
  568.     /**
  569.      * ログ情報の追加
  570.      *
  571.      * @param  string $title   タイトル
  572.      * @param  string $content 出力内容
  573.      * @return void
  574.      */
  575.     protected function setLogInfo($title$content)
  576.     {
  577.         if (empty($this->timeKey)) {
  578.             $this->timeKey date('Y-m-d H:i:s');
  579.         }
  580.         $this->logData[$this->timeKey][] = compact('title''content');
  581.     }
  582.     /**
  583.      * ロールバック
  584.      *
  585.      * @param  Order $order 注文データ
  586.      * @return void
  587.      */
  588.     public function rollback($order$useTransaction true)
  589.     {
  590.         // 購入処理中の場合は何も行わない
  591.         if ($order->getOrderStatus()->getId() === OrderStatus::PROCESSING) {
  592.             return;
  593.         }
  594.         if ($useTransaction) {
  595.             $this->em->beginTransaction();
  596.         }
  597.         // 決済データの削除
  598.         $orderPayment $this->em->getRepository(Vt4gOrderPayment::class)->find($order->getId());
  599.         if (!empty($orderPayment)) {
  600.             $this->em->remove($orderPayment);
  601.         }
  602.         // EC-CUBE側 購入処理のロールバック
  603.         // 同一ユーザーで複数の注文を並行して操作している場合、カート情報と注文情報が紐づかない可能性があるため、
  604.         // カート情報でチェックを行うPreOrderIdValidatorを使わずにロールバックする。
  605.         // [想定パターン]
  606.         // ・カート情報がクリアされていた場合
  607.         // ・最後にカート投入した注文とは異なる注文の場合
  608.         if (empty($this->cartService) || $this->cartService->getPreOrderId() !== $order->getPreOrderId()){
  609.             $this->purchaseFlow->setPurchaseProcessors($this->container->get('vt4g_plugin.purchase.flow.shopping.purchase.rollback'));
  610.         }
  611.         // EC-CUBE側 購入処理のロールバック
  612.         $this->purchaseFlow->rollback($order, new PurchaseContext());
  613.         // 購入処理中へ更新
  614.         $order->setOrderStatus($this->em->getRepository(OrderStatus::class)->find(OrderStatus::PROCESSING));
  615.         $this->em->flush();
  616.         if ($useTransaction) {
  617.             $this->em->commit();
  618.         }
  619.     }
  620.     /**
  621.      * 各決済の新規の注文ステータスを取得
  622.      * ネットバンクはvt4g_shopping_payment_completeアクセス時に値を新規受付に更新する
  623.      *
  624.      * @param  object  $paymentMethod 決済方法データ
  625.      * @param  integer $withCapture   処理区分
  626.      * @return integer|string         注文ステータス
  627.      */
  628.     private function getNewOrderStatus($paymentMethod$withCapture)
  629.     {
  630.         switch ($paymentMethod->getMemo03()) {
  631.             case $this->vt4gConst['VT4G_PAYTYPEID_CREDIT']:  // クレジットカード決済
  632.             case $this->vt4gConst['VT4G_PAYTYPEID_UPOP']:    // 銀聯
  633.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN']: // 楽天
  634.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN_V2']: // 楽天V2
  635.             case $this->vt4gConst['VT4G_PAYTYPEID_RECRUIT']: // リクルート
  636.             case $this->vt4gConst['VT4G_PAYTYPEID_LINEPAY']: // ライン
  637.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAL']:  // PayPal
  638.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAY']:  // PayPay
  639.                 return $withCapture === 1
  640.                     OrderStatus::PAID // 入金済み
  641.                     OrderStatus::NEW; // 新規受付
  642.             case $this->vt4gConst['VT4G_PAYTYPEID_CVS']:    // コンビニ決済
  643.             case $this->vt4gConst['VT4G_PAYTYPEID_ATM']:    // ATM決済
  644.                 return OrderStatus::NEW; // 新規受付
  645.             case $this->vt4gConst['VT4G_PAYTYPEID_BANK']:   // ネットバンク決済
  646.                 return OrderStatus::PENDING// 決済処理中
  647.             case $this->vt4gConst['VT4G_PAYTYPEID_ALIPAY']:  // Alipay
  648.                 return OrderStatus::PAID// 入金済み
  649.         }
  650.         return '';
  651.     }
  652.     /**
  653.      * 各決済の新規の決済ステータスを取得
  654.      * ネットバンクはvt4g_shopping_payment_completeアクセス時に値を申込に更新する
  655.      *
  656.      * @param  object  $paymentMethod 決済方法データ
  657.      * @param  integer $withCapture   処理区分
  658.      * @return integer $status        決済ステータス
  659.      */
  660.     public function getNewPaymentStatus($paymentMethod$withCapture 0)
  661.     {
  662.         $status '';
  663.         switch ($paymentMethod->getMemo03()) {
  664.             case $this->vt4gConst['VT4G_PAYTYPEID_CREDIT']:  // クレジット
  665.             case $this->vt4gConst['VT4G_PAYTYPEID_UPOP']:    // 銀聯
  666.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN']: // 楽天
  667.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN_V2']: // 楽天V2
  668.             case $this->vt4gConst['VT4G_PAYTYPEID_RECRUIT']: // リクルート
  669.             case $this->vt4gConst['VT4G_PAYTYPEID_LINEPAY']: // ライン
  670.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAL']:  // PayPal
  671.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAY']:  // PayPay
  672.                 $status $withCapture === 1
  673.                     $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE']['VALUE']
  674.                     : $this->vt4gConst['VT4G_PAY_STATUS']['AUTH']['VALUE'];
  675.                 break;
  676.             case $this->vt4gConst['VT4G_PAYTYPEID_CVS']:  // コンビニ
  677.             case $this->vt4gConst['VT4G_PAYTYPEID_ATM']:  // ATM
  678.                 $status $this->vt4gConst['VT4G_PAY_STATUS']['REQUEST']['VALUE']; // 申込
  679.                 break;
  680.             case $this->vt4gConst['VT4G_PAYTYPEID_BANK']: // ネットバンク
  681.                 break;
  682.             case $this->vt4gConst['VT4G_PAYTYPEID_ALIPAY']: // アリペイ
  683.                 $status $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE']['VALUE']; // 売上
  684.                 break;
  685.             default:
  686.                 break;
  687.         }
  688.         return $status;
  689.     }
  690.     /**
  691.      * 決済時の処理区分を取得
  692.      * @param  object $order 注文データ
  693.      * @return integer|null 処理区分、取得できない場合はnull
  694.      */
  695.     public function getWithCapture($order)
  696.     {
  697.         $orderPayment $this->util->getOrderPayment($order);
  698.         $memo05 method_exists($orderPayment'getMemo05')
  699.                 ? unserialize($orderPayment->getMemo05())
  700.                 : null;
  701.         if (isset($memo05['withCapture'])) {
  702.             return $memo05['withCapture'];
  703.         } else {
  704.             return null;
  705.         }
  706.     }
  707.     /**
  708.      * 決済エラー用レスポンスを生成
  709.      *
  710.      * @param  string   $errorMessage エラーメッセージ
  711.      * @return Response               ビューレスポンス
  712.      */
  713.     public function makeErrorResponse($errorMessage null)
  714.     {
  715.         $content $this->container->get('twig')->render('error.twig', [
  716.             'error_title'   => '決済エラー',
  717.             'error_message' => $errorMessage ?? trans('vt4g_plugin.payment.shopping.not.order'),
  718.         ]);
  719.         return new Response($content);
  720.     }
  721.     /**
  722.      * 決済完了メッセージを取得
  723.      *
  724.      * @param  array   $mailData メール情報
  725.      * @param  boolean $forMail  メール用テンプレートを使用するかどうか
  726.      * @return string            決済完了メッセージ
  727.      */
  728.     public function getCompleteMessage($mailData = [], $forMail false)
  729.     {
  730.         if (empty($mailData)) {
  731.             $mailData $this->mailData;
  732.         }
  733.         // メール情報が未設定 もしくは メッセージが未設定の場合は何もしない
  734.         if (empty($mailData) || !array_key_exists('message'$mailData)) {
  735.             return '';
  736.         }
  737.         $engine $this->container->get('twig');
  738.         $param = ['arrOther' => $mailData];
  739.         $dir $this->vt4gConst['VT4G_CODE'].'/Resource/template/default/';
  740.         $path $forMail
  741.             'Mail/'
  742.             'Shopping/';
  743.         $filename $forMail
  744.             'vt4g_order_complete.twig'
  745.             'vt4g_payment_complete.twig';
  746.         $template $dir.$path.$filename;
  747.         return $engine->render($template$paramnull);
  748.     }
  749.     /**
  750.      * 完了メッセージを追加
  751.      *
  752.      * @param  Order &$order Orderクラスインスタンス
  753.      * @return void
  754.      */
  755.     protected function addOrderCompleteMessage(&$order)
  756.     {
  757.         $paymentId $order->getPayment()->getId();
  758.         $paymentMethod $this->util->getPaymentMethod($paymentId);
  759.         $paymentMethodId $paymentMethod->getMemo03();
  760.         // ネットバンクのみ完了画面メッセージ固定
  761.         $bankMailData = [];
  762.         if ($paymentMethodId == $this->vt4gConst['VT4G_PAYTYPEID_BANK']) {
  763.             $bankMailData['title'] = $this->mailData['title'];
  764.             $memo05 unserialize($paymentMethod->getMemo05());
  765.             $title $memo05['order_mail_title1'] ?? null;
  766.             $content $memo05['order_mail_body1'] ?? null;
  767.             // タイトル・本文が両方設定されている場合のみ追加
  768.             if (isset($title$content)) {
  769.                 $bankMailData['message'][] = compact('title''content');
  770.             }
  771.         }
  772.         $message = !empty($bankMailData)
  773.             ? $this->getCompleteMessage($bankMailData)
  774.             : $this->getCompleteMessage();
  775.         if (!empty($message)) {
  776.             // 注文完了画面にメッセージを追加
  777.             $order->appendCompleteMessage($message);
  778.         }
  779.     }
  780.     /**
  781.      * メール送信
  782.      *
  783.      * @param  Order &$order Orderクラスインスタンス
  784.      * @return void
  785.      */
  786.     public function sendOrderMail(&$order)
  787.     {
  788.         $this->mdkLogger->info(trans('vt4g_plugin.payment.mail.start'));
  789.         $this->mailService->sendOrderMail($order);
  790.         // NOTE: 独自で追加した処理 ========
  791.         // LINE通知 
  792.         $this->mailService->sendLineOrderMsg($order);
  793.         // レシピ帖のデザインデータのメール送付
  794.         foreach ($order->getOrderItems() as $key => $value) {
  795.             if($value->getProduct() && $value->getProduct()->getIsRecipeBook()){
  796.                 log_info('[注文処理] レシピ帖のデザインデータを送信します.', [$order->getId()]);
  797.                 $this->mailService->sendRecipeMail(
  798.                     $order->getCustomer(),
  799.                     $value->getProduct()
  800.                 );
  801.             }
  802.         }
  803.         // NOTE: 独自で追加した処理 ========
  804.         $this->mdkLogger->info(trans('vt4g_plugin.payment.mail.complete'));
  805.         // 本体側の処理でflushが実行されないためここで実行
  806.         $this->em->flush();
  807.     }
  808.     /**
  809.      * メールを送信するか判定
  810.      *
  811.      * @param  Order            $order        注文データ
  812.      * @param  Vt4gOrderPayment $orderPayment 決済データ
  813.      * @return boolean                        ture:送信する、false:送信しない
  814.      */
  815.     protected function shouldSendMail($order$orderPayment)
  816.     {
  817.         $paymentId $order->getPayment()->getId();
  818.         $paymentInfo $this->util->getPaymentMethodInfo($paymentId);
  819.         $paymentId $this->util->getPaymentMethod($paymentId)->getMemo03();
  820.         // 決済の判定
  821.         $isCredit $paymentId == $this->vt4gConst['VT4G_PAYTYPEID_CREDIT'];
  822.         $isATM    $paymentId == $this->vt4gConst['VT4G_PAYTYPEID_ATM'];
  823.         $isCVS    $paymentId == $this->vt4gConst['VT4G_PAYTYPEID_CVS'];
  824.         $isBank   $paymentId == $this->vt4gConst['VT4G_PAYTYPEID_BANK'];
  825.         // クレジットカード決済 かつ 本人認証なしの場合
  826.         // ATM決済の場合
  827.         // コンビニ決済の場合
  828.         if ($isCredit && !$paymentInfo['mpi_flg']
  829.             || $isATM
  830.             || $isCVS
  831.         ) {
  832.             return true;
  833.         }
  834.         // ネットバンク決済の場合
  835.         // 注文完了メール送信タイミングが決済申込完了時ではない場合
  836.         if ($isBank) {
  837.             return $paymentInfo['mailTiming'] != $this->vt4gConst['VT4G_MAIL_TIMING']['BANK']['ON_PAYMENT'] ? false true;
  838.         }
  839.         // 注文完了メール送信状況が送信済みの場合(注文完了メール送信状況の登録がない注文の場合も送信しない)
  840.         $memo10 unserialize($orderPayment->getMemo10());
  841.         if (!array_key_exists('sentOrderMail'$memo10) || $memo10['sentOrderMail']) {
  842.             return false;
  843.         }
  844.         // 結果(入金)通知の場合は結果通知プログラムで判定するのでfalse
  845.         if ($this->isPaymentRecv) {
  846.             return false;
  847.         }
  848.         return true;
  849.     }
  850.     /**
  851.      * 注文完了メール送信状況を送信済みに更新
  852.      *
  853.      * @param Vt4gOrderPayment $orderPayment 決済データ
  854.      * @return void
  855.      */
  856.     public function updateSentOrderMailToSent($orderPayment)
  857.     {
  858.         $memo10 unserialize($orderPayment->getMemo10());
  859.         $memo10['sentOrderMail'] = true;
  860.         $orderPayment->setMemo10(serialize($memo10));
  861.         $this->em->persist($orderPayment);
  862.         $this->em->flush();
  863.     }
  864.     /**
  865.      * レコードロックした注文情報と決済情報を取得
  866.      * @param  int   $orderId 注文ID
  867.      * @return array [Order, Vt4gOrderPayment] OrderとVt4gOrderPaymentのオブジェクトを格納した配列
  868.      * @throws LockWaitTimeoutException MySQLのロック解除待ちのタイムアウト発生時
  869.      * @throws DriverException PostgreSQLのロック解除待ちのタイムアウト発生時 (MySQLとPostgreSQLのSQL実行時間のタイムアウトも含む)
  870.      */
  871.     public function getLockedOrder($orderId)
  872.     {
  873.         $isMySQL 'mysql' == $this->em->getConnection()->getDatabasePlatform()->getName();
  874.         $isPostgreSQL 'postgresql' == $this->em->getConnection()->getDatabasePlatform()->getName();
  875.         $timeout $this->vt4gConst['VT4G_LOCK_TIMEOUT'] ?? ini_get('max_execution_time');
  876.         $sql '';
  877.         if ($isPostgreSQL) {
  878.             $sql sprintf("SET lock_timeout = %s;"$timeout 1000);
  879.             $this->em->getConnection()->executeQuery($sql);
  880.         } elseif ($isMySQL) {
  881.             $sql sprintf("SET innodb_lock_wait_timeout = %s;"$timeout);
  882.             $this->em->getConnection()->executeQuery($sql);
  883.         }
  884.         try {
  885.             $this->mdkLogger->info($sql);
  886.             $orderPayment $this->em->find(Vt4gOrderPayment::class, $orderIdLockMode::PESSIMISTIC_WRITE);
  887.             $order $this->em->find(Order::class, $orderIdLockMode::PESSIMISTIC_WRITE);
  888.         } catch (LockWaitTimeoutException $e) {
  889.             $this->mdkLogger->error('LockWaitTimeoutException');
  890.             $this->mdkLogger->error($e->getMessage());
  891.             $this->mdkLogger->error($e->getTraceAsString());
  892.             $this->em->rollback();
  893.             throw $e;
  894.         } catch (DriverException $e) {
  895.             $this->mdkLogger->error('DriverException');
  896.             $this->mdkLogger->error($e->getMessage());
  897.             $this->mdkLogger->error($e->getTraceAsString());
  898.             $this->em->rollback();
  899.             throw $e;
  900.         }
  901.         return [$order$orderPayment];
  902.     }
  903.     /**
  904.      * 決済処理の実行
  905.      *
  906.      * @param  array $payload 決済処理に使用するデータ
  907.      * @return array          決済処理結果データ
  908.      */
  909.     protected function operateNewly($payload)
  910.     {
  911.         $paymentId     $payload['order']->getPayment()->getId();
  912.         $payId         $payload['orderPayment']->getMemo03();
  913.         $paymentInfo   $this->util->getPaymentMethodInfo($paymentId);
  914.         $paymentMethod $this->util->getPaymentMethod($paymentId);
  915.         $payName       $payId == $this->vt4gConst['VT4G_PAYTYPEID_ATM']
  916.             ? $paymentMethod->getPaymentMethod()
  917.             : $this->util->getPayName($payId);
  918.         $serviceOptionType = ($payId == $this->vt4gConst['VT4G_PAYTYPEID_CVS'])
  919.             ? $payload['inputs']->get('conveni')
  920.             : null;
  921.         $this->mdkLogger->info(
  922.             sprintf(
  923.                 trans('vt4g_plugin.admin.order.credit.newly.start'),
  924.                 $payName
  925.             )
  926.         );
  927.         // レスポンス初期化
  928.         $operationResult $this->initPaymentResult();
  929.         switch ($payId) {
  930.             case $this->vt4gConst['VT4G_PAYTYPEID_CVS']:
  931.                 if (is_null($serviceOptionType)) {
  932.                     return $operationResult;
  933.                 }
  934.                 $mdkRequest = new CvsAuthorizeRequestDto();
  935.                 $this->setRequestParam($mdkRequest$payload['order'], $paymentInfo$serviceOptionType);
  936.                 break;
  937.             case $this->vt4gConst['VT4G_PAYTYPEID_ATM']:
  938.                 $mdkRequest = new BankAuthorizeRequestDto();
  939.                 $this->setRequestParam($mdkRequest$payload['order'], $paymentInfo);
  940.                 break;
  941.             default:
  942.                 return $operationResult;
  943.         }
  944.         $mdkTransaction = new TGMDK_Transaction();
  945.         $mdkResponse $mdkTransaction->execute($mdkRequest);
  946.         // レスポンス検証
  947.         if (!isset($mdkResponse)) {
  948.             $this->mdkLogger->fatal(trans('vt4g_plugin.payment.shopping.mdk.error'));
  949.             $operationResult['message'] = trans('vt4g_plugin.payment.shopping.error');
  950.             return $operationResult;
  951.         }
  952.         // 結果コード
  953.         $operationResult['mStatus'] = $mdkResponse->getMStatus();
  954.         // 詳細コード
  955.         $operationResult['vResultCode'] = $mdkResponse->getVResultCode();
  956.         // エラーメッセージ
  957.         $operationResult['mErrMsg'] = $mdkResponse->getMErrMsg();
  958.         // 異常終了レスポンスの場合
  959.         if ($operationResult['mStatus'] !== $this->vt4gConst['VT4G_RESPONSE']['MSTATUS']['OK']) {
  960.             $operationResult['message']  = $operationResult['vResultCode'].':';
  961.             $operationResult['message'] .= $operationResult['mErrMsg'];
  962.             return $operationResult;
  963.         }
  964.         $operationResult['isOK']      = true;
  965.         // 有効期限
  966.         $operationResult['limitDate'] = $mdkRequest->getPayLimit();
  967.         // 取引ID
  968.         $operationResult['orderId']   = $mdkResponse->getOrderId();
  969.         // trAd URL
  970.         $operationResult['tradUrl']   = '';
  971.         // 決済ステータス
  972.         $operationResult['payStatus'] = $this->getNewPaymentStatus($paymentMethod);
  973.         // 決済金額
  974.         $operationResult['captureTotal'] = floor($payload['order']->getPaymentTotal());
  975.         switch ($payId) {
  976.             case $this->vt4gConst['VT4G_PAYTYPEID_CVS']: // コンビニ決済
  977.                 // 電話番号
  978.                 $operationResult['telNo']        = $mdkRequest->getTelNo();
  979.                 // 受付番号
  980.                 $operationResult['receiptNo']    = $mdkResponse->getReceiptNo();
  981.                 // 払込URL(一部店舗のみ)
  982.                 $operationResult['haraikomiUrl'] = $mdkResponse->getHaraikomiUrl();
  983.                 // 決済サービスオプション
  984.                 $operationResult['serviceOptionType'] = $serviceOptionType;
  985.                 $rollbackDate $this->util->getRollbackDate($operationResult['limitDate'], $this->vt4gConst['VT4G_PAYTYPEID_CVS']);
  986.                 $operationResult['rollbackDate'] = $rollbackDate;
  987.                 $cvsName $this->util->getConveniNameByCode($serviceOptionType);
  988.                 $cvsData $this->translateRecpNo($serviceOptionType$operationResult['receiptNo'], $operationResult['telNo'], true);
  989.                 // ログの生成
  990.                 $this->setLogHead($payId''$operationResult);
  991.                 $this->setLogInfo('店舗'$cvsName);
  992.                 // コンビニ受付番号等
  993.                 foreach ($cvsData as $key => $val) {
  994.                     $this->setLogInfo($key$val);
  995.                 }
  996.                 $this->setLogInfo('支払期限'$operationResult['limitDate']);
  997.                 break;
  998.             case $this->vt4gConst['VT4G_PAYTYPEID_ATM']: // ATM決済
  999.                 // 収納期間番号
  1000.                 $operationResult['shunoKikanNo'] = $mdkResponse->getShunoKikanNo();
  1001.                 // お客様番号
  1002.                 $operationResult['customerNo']   = $mdkResponse->getCustomerNo();
  1003.                 // 確認番号
  1004.                 $operationResult['confirmNo']    = $mdkResponse->getConfirmNo();
  1005.                 $rollbackDate $this->util->getRollbackDate($operationResult['limitDate'], $this->vt4gConst['VT4G_PAYTYPEID_ATM']);
  1006.                 $operationResult['rollbackDate'] = $rollbackDate;
  1007.                 // ログ情報の設定
  1008.                 $this->setLog($payload['order'], $operationResult);
  1009.                 break;
  1010.             default:
  1011.                 break;
  1012.         }
  1013.         return $operationResult;
  1014.     }
  1015.     /**
  1016.      * キャンセル処理の実行
  1017.      *
  1018.      * @param  array $payload キャンセル処理に使用するデータ
  1019.      * @return array          キャンセル処理結果データ
  1020.      */
  1021.     public function operateCancel($payload)
  1022.     {
  1023.         $payId   $payload['orderPayment']->getMemo03();
  1024.         $payName $this->util->getPayName($payId);
  1025.         $isRakuten $payId == $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN'];
  1026.         $payStatusName $isRakuten
  1027.             $this->vt4gConst['VT4G_PAY_STATUS']['CANCEL_REQUEST']['LABEL']
  1028.             : $this->vt4gConst['VT4G_PAY_STATUS']['CANCEL']['LABEL'];
  1029.         $this->mdkLogger->info("管理者{$payName}[{$payStatusName}]通信実行");
  1030.         // 決済申込時の結果データ
  1031.         $prevPaymentResult unserialize($payload['orderPayment']->getMemo05());
  1032.         // レスポンス初期化
  1033.         $operationResult $this->initPaymentResult();
  1034.         // キャンセル対象の取引ID
  1035.         $paymentOrderId $payload['orderPayment']->getMemo01();
  1036.         // memo01から取得できない場合
  1037.         if (empty($paymentOrderId)) {
  1038.             // 決済申込時のレスポンスから取得できない場合
  1039.             if (empty($prevPaymentResult['orderId'])) {
  1040.                 $this->mdkLogger->fatal(trans('vt4g_plugin.payment.shopping.mdk.error'));
  1041.                 $operationResult['message'] = trans('vt4g_plugin.payment.shopping.error');
  1042.                 return [$operationResult, []];
  1043.             }
  1044.             // 決済申込時の結果から取得
  1045.             $paymentOrderId $prevPaymentResult['orderId'];
  1046.         }
  1047.         switch ($payId) {
  1048.             case $this->vt4gConst['VT4G_PAYTYPEID_CREDIT']: // クレジットカード決済
  1049.                 $mdkRequest = new CardCancelRequestDto();
  1050.                 break;
  1051.             case $this->vt4gConst['VT4G_PAYTYPEID_CVS']: // コンビニ決済
  1052.                 $mdkRequest = new CvsCancelRequestDto();
  1053.                 // 決済サービスオプションを設定
  1054.                 $mdkRequest->setServiceOptionType($prevPaymentResult['serviceOptionType']);
  1055.                 break;
  1056.             case $this->vt4gConst['VT4G_PAYTYPEID_UPOP']: // 銀聯
  1057.                 $mdkRequest = new UpopCancelRequestDto();
  1058.                 break;
  1059.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN']: // 楽天
  1060.                 $mdkRequest = new RakutenCancelRequestDto();
  1061.                 $arrMemo10 unserialize($payload['orderPayment']->getMemo10());
  1062.                 $arrMemo10['lastPayStatus'] = $payload['orderPayment']->getMemo04();
  1063.                 $payload['orderPayment']->setMemo10(serialize($arrMemo10));
  1064.                 break;
  1065.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN_V2']: // 楽天v2
  1066.                 $mdkRequest = new RakutenCancelRequestDto();
  1067.                 break;
  1068.             case $this->vt4gConst['VT4G_PAYTYPEID_RECRUIT']: // リクルート
  1069.                 $mdkRequest = new RecruitCancelRequestDto();
  1070.                 break;
  1071.             case $this->vt4gConst['VT4G_PAYTYPEID_LINEPAY']: // ライン
  1072.                 $mdkRequest = new LinepayCancelRequestDto();
  1073.                 break;
  1074.             case $this->vt4gConst['VT4G_PAYTYPEID_ALIPAY']: // アリペイ
  1075.                 $paymentId   $payload['order']->getPayment()->getId();
  1076.                 $paymentInfo $this->util->getPaymentMethodInfo($paymentId);
  1077.                 $arrMemo10   unserialize($payload['orderPayment']->getMemo10());
  1078.                 $mdkRequest = new AlipayRefundRequestDto();
  1079.                 $mdkRequest->setAmount($arrMemo10['captureTotal']);
  1080.                 $mdkRequest->setReason($paymentInfo['refund_reason']);
  1081.                 $operationResult['amount']        = $arrMemo10['captureTotal'];
  1082.                 $operationResult['refund_reason'] = $paymentInfo["refund_reason"];
  1083.                 break;
  1084.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAL']: // paypal
  1085.                 $mdkRequest = new PaypalCancelRequestDto();
  1086.                 break;
  1087.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAY']: // paypay
  1088.                 $mdkRequest = new PaypayCancelRequestDto();
  1089.                 $mdkRequest->setServiceOptionType($this->vt4gConst['VT4G_PAYPAY_SERVICE_OPTION_TYPE']);
  1090.                 break;
  1091.             default:
  1092.                 return [$operationResult, []];
  1093.         }
  1094.         // キャンセル対象の取引IDを設定
  1095.         $mdkRequest->setOrderId($paymentOrderId);
  1096.         $mdkTransaction = new TGMDK_Transaction();
  1097.         $mdkResponse $mdkTransaction->execute($mdkRequest);
  1098.         // レスポンス検証
  1099.         if (!isset($mdkResponse)) {
  1100.             $this->mdkLogger->fatal(trans('vt4g_plugin.payment.shopping.mdk.error'));
  1101.             $operationResult['message'] = trans('vt4g_plugin.payment.shopping.error');
  1102.             return [$operationResult, []];
  1103.         }
  1104.         // 結果コード
  1105.         $operationResult['mStatus'] = $mdkResponse->getMStatus();
  1106.         // 詳細コード
  1107.         $operationResult['vResultCode'] = $mdkResponse->getVResultCode();
  1108.         // エラーメッセージ
  1109.         $operationResult['mErrMsg'] = $mdkResponse->getMErrMsg();
  1110.         // 正常終了レスポンス以外の場合
  1111.         if ($operationResult['mStatus'] !== $this->vt4gConst['VT4G_RESPONSE']['MSTATUS']['OK']) {
  1112.             $operationResult['message']  = $operationResult['vResultCode'].':';
  1113.             $operationResult['message'] .= $operationResult['mErrMsg'];
  1114.             return [$operationResult$mdkResponse];
  1115.         }
  1116.         $operationResult['isOK']         = true;
  1117.         // 取引ID
  1118.         $operationResult['orderId']      = $mdkResponse->getOrderId();
  1119.         // 決済サービスタイプ
  1120.         $operationResult['serviceType']  = $mdkResponse->getServiceType();
  1121.         // 決済ステータス
  1122.         $operationResult['payStatus']    = $isRakuten
  1123.             $this->vt4gConst['VT4G_PAY_STATUS']['CANCEL_REQUEST']['VALUE']
  1124.             : $this->vt4gConst['VT4G_PAY_STATUS']['CANCEL']['VALUE'];
  1125.         // 売上金額
  1126.         $operationResult['captureTotal'] = floor($payload['order']->getPaymentTotal());
  1127.         // ログの生成
  1128.         $this->setLogHead($payload['orderPayment']->getMemo03(), ''$operationResult);
  1129.         return [$operationResult$mdkResponse];
  1130.     }
  1131.     /**
  1132.      * 売上処理
  1133.      *
  1134.      * @param  array $payload 売上処理に使用するデータ
  1135.      * @return array          売上処理結果データ
  1136.      */
  1137.     public function operateCapture($payload)
  1138.     {
  1139.         $payId   $payload['orderPayment']->getMemo03();
  1140.         $payName $this->util->getPayName($payId);
  1141.         $isRakuten $payId == $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN'];
  1142.         $payStatusName $isRakuten
  1143.             $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE_REQUEST']['LABEL']
  1144.             : $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE']['LABEL'];
  1145.         $this->mdkLogger->info("管理者{$payName}[{$payStatusName}]通信実行");
  1146.         // 決済申込時の結果データ
  1147.         $prevPaymentResult unserialize($payload['orderPayment']->getMemo05());
  1148.         // レスポンス初期化
  1149.         $operationResult $this->initPaymentResult();
  1150.         // リクエストの取得
  1151.         switch ($payId) {
  1152.             case $this->vt4gConst['VT4G_PAYTYPEID_UPOP']: // 銀聯
  1153.                 $mdkRequest = new UpopCaptureRequestDto();
  1154.                 break;
  1155.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN']: // 楽天
  1156.                 $mdkRequest = new RakutenCaptureRequestDto();
  1157.                 $arrMemo10 unserialize($payload['orderPayment']->getMemo10());
  1158.                 $arrMemo10['lastPayStatus'] = $payload['orderPayment']->getMemo04();
  1159.                 $payload['orderPayment']->setMemo10(serialize($arrMemo10));
  1160.                 break;
  1161.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN_V2']: // 楽天V2
  1162.                 $mdkRequest = new RakutenCaptureRequestDto();
  1163.                 break;
  1164.             case $this->vt4gConst['VT4G_PAYTYPEID_RECRUIT']: // リクルート
  1165.                 $mdkRequest = new RecruitCaptureRequestDto();
  1166.                 break;
  1167.             case $this->vt4gConst['VT4G_PAYTYPEID_LINEPAY']: // ライン
  1168.                 $mdkRequest = new LinepayCaptureRequestDto();
  1169.                 break;
  1170.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAL']: // paypal
  1171.                 $mdkRequest = new PaypalCaptureRequestDto();
  1172.                 $mdkRequest->setAction('capture');
  1173.                 break;
  1174.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAY']: // paypay
  1175.                 $mdkRequest = new PaypayCaptureRequestDto();
  1176.                 $mdkRequest->setServiceOptionType($this->vt4gConst['VT4G_PAYPAY_SERVICE_OPTION_TYPE']);
  1177.                 break;
  1178.             default:
  1179.                 return [$operationResult, []];
  1180.         }
  1181.         $mdkRequest->setAmount(floor($payload['order']->getPaymentTotal()));
  1182.         $mdkRequest->setOrderId($prevPaymentResult['orderId']);
  1183.         $objTransaction = new TGMDK_Transaction();
  1184.         $mdkResponse $objTransaction->execute($mdkRequest);
  1185.         if (!isset($mdkResponse)) {
  1186.             $this->mdkLogger->fatal(trans('vt4g_plugin.payment.shopping.mdk.error'));
  1187.             $operationResult['message'] = trans('vt4g_plugin.payment.shopping.error');
  1188.             return [$operationResult, []];
  1189.         }
  1190.         // 結果コード
  1191.         $operationResult['mStatus']     = $mdkResponse->getMStatus();
  1192.         // 詳細コード
  1193.         $operationResult['vResultCode'] = $mdkResponse->getVResultCode();
  1194.         // エラーメッセージ
  1195.         $operationResult['mErrMsg']     = $mdkResponse->getMErrMsg();
  1196.         // 正常終了レスポンス以外の場合
  1197.         if ($operationResult['mStatus'] !== $this->vt4gConst['VT4G_RESPONSE']['MSTATUS']['OK']) {
  1198.             $operationResult['message']  = $operationResult['vResultCode'].':';
  1199.             $operationResult['message'] .= $operationResult['mErrMsg'];
  1200.             return [$operationResult$mdkResponse];
  1201.         }
  1202.         $operationResult['isOK']         = true;
  1203.         // 取引ID
  1204.         $operationResult['orderId']      = $mdkResponse->getOrderId();
  1205.         // 決済サービスタイプ
  1206.         $operationResult['serviceType']  = $mdkResponse->getServiceType();
  1207.         // 決済ステータス
  1208.         $operationResult['payStatus']    = $isRakuten
  1209.             $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE_REQUEST']['VALUE']
  1210.             : $this->vt4gConst['VT4G_PAY_STATUS']['CAPTURE']['VALUE'];
  1211.         // 売上金額
  1212.         $operationResult['captureTotal'] = floor($payload['order']->getPaymentTotal());
  1213.         // ログの生成
  1214.         $this->setLogHead($payId''$operationResult);
  1215.         return [$operationResult$mdkResponse];
  1216.     }
  1217.     /**
  1218.      * 返金処理
  1219.      *
  1220.      * @param  array $payload 返金処理に使用するデータ
  1221.      * @return array          返金処理結果データ
  1222.      */
  1223.     public function operateRefund($payload)
  1224.     {
  1225.         $payId   $payload['orderPayment']->getMemo03();
  1226.         $payName $this->util->getPayName($payId);
  1227.         $isRakuten $payId == $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN'];
  1228.         if ($isRakuten) {
  1229.             $payStatusName $this->vt4gConst['VT4G_PAY_STATUS']['REDUCTION_REQUEST']['LABEL'];
  1230.         } else if (isset($payload['refundAll']) && $payload['refundAll']) {
  1231.             $payStatusName $this->vt4gConst['VT4G_OPERATION_NAME']['REFUND_ALL'];
  1232.         } else {
  1233.             $payStatusName $this->vt4gConst['VT4G_OPERATION_NAME']['REFUND'];
  1234.         }
  1235.         $this->mdkLogger->info("管理者{$payName}[{$payStatusName}]通信実行");
  1236.         // 決済申込時のレスポンス
  1237.         $prevPaymentResult unserialize($payload['orderPayment']->getMemo05());
  1238.         // 減額
  1239.         $amount    0;
  1240.         $arrMemo10 unserialize($payload['orderPayment']->getMemo10());
  1241.         if (isset($arrMemo10['captureTotal'])) {
  1242.             if (isset($payload['refundAll']) && $payload['refundAll']) {
  1243.                 $amount $arrMemo10['captureTotal'];
  1244.             } else {
  1245.                 $amount $arrMemo10['captureTotal'] - $payload['order']->getPaymentTotal();
  1246.             }
  1247.         }
  1248.         // レスポンス初期化
  1249.         $operationResult $this->initPaymentResult();
  1250.         // リクエストの取得
  1251.         switch ($payId) {
  1252.             case $this->vt4gConst['VT4G_PAYTYPEID_UPOP']: // 銀聯
  1253.                 $mdkRequest = new UpopRefundRequestDto();
  1254.                 $arrMemo10['refundFlg'] = true;
  1255.                 $payload['orderPayment']->setMemo10(serialize($arrMemo10));
  1256.                 break;
  1257.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN']: // 楽天
  1258.                 $mdkRequest = new RakutenCancelRequestDto();
  1259.                 $arrMemo10['lastPayStatus'] = $payload['orderPayment']->getMemo04();
  1260.                 $payload['orderPayment']->setMemo10(serialize($arrMemo10));
  1261.                 break;
  1262.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN_V2']: // 楽天V2
  1263.                 $mdkRequest = new RakutenCancelRequestDto();
  1264.                 break;
  1265.             case $this->vt4gConst['VT4G_PAYTYPEID_RECRUIT']: // リクルート
  1266.                 $mdkRequest = new RecruitCancelRequestDto();
  1267.                 break;
  1268.             case $this->vt4gConst['VT4G_PAYTYPEID_LINEPAY']: // ライン
  1269.                 $mdkRequest = new LinepayCancelRequestDto();
  1270.                 break;
  1271.             case $this->vt4gConst['VT4G_PAYTYPEID_ALIPAY']:
  1272.                 $paymentId   $payload['order']->getPayment()->getId();
  1273.                 $paymentInfo $this->util->getPaymentMethodInfo($paymentId);
  1274.                 $mdkRequest  = new AlipayRefundRequestDto();
  1275.                 $mdkRequest->setReason($paymentInfo['refund_reason']);
  1276.                 $operationResult['refund_reason'] = $paymentInfo['refund_reason'];
  1277.                 break;
  1278.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAL']: // paypal
  1279.                 $mdkRequest = new PaypalRefundRequestDto();
  1280.                 $arrMemo10['refundFlg'] = true;
  1281.                 $payload['orderPayment']->setMemo10(serialize($arrMemo10));
  1282.                 break;
  1283.             case $this->vt4gConst['VT4G_PAYTYPEID_PAYPAY']: // paypay
  1284.                 $mdkRequest = new PaypayRefundRequestDto();
  1285.                 $mdkRequest->setServiceOptionType($this->vt4gConst['VT4G_PAYPAY_SERVICE_OPTION_TYPE']);
  1286.                 break;
  1287.             default:
  1288.                 return [$operationResult, []];
  1289.         }
  1290.         $mdkRequest->setAmount($amount);
  1291.         $mdkRequest->setOrderId($prevPaymentResult['orderId']);
  1292.         $objTransaction = new TGMDK_Transaction();
  1293.         $mdkResponse $objTransaction->execute($mdkRequest);
  1294.         if (!isset($mdkResponse)) {
  1295.             $this->mdkLogger->fatal(trans('vt4g_plugin.payment.shopping.mdk.error'));
  1296.             $operationResult['message'] = trans('vt4g_plugin.payment.shopping.error');
  1297.             return [$operationResult, []];
  1298.         }
  1299.         // 結果コード
  1300.         $operationResult['mStatus']     = $mdkResponse->getMStatus();
  1301.         // 詳細コード
  1302.         $operationResult['vResultCode'] = $mdkResponse->getVResultCode();
  1303.         // エラーメッセージ
  1304.         $operationResult['mErrMsg']     = $mdkResponse->getMErrMsg();
  1305.         // 正常終了レスポンス以外の場合
  1306.         if ($operationResult['mStatus'] !== $this->vt4gConst['VT4G_RESPONSE']['MSTATUS']['OK']) {
  1307.             $operationResult['message']  = $operationResult['vResultCode'].':';
  1308.             $operationResult['message'] .= $operationResult['mErrMsg'];
  1309.             return [$operationResult$mdkResponse];
  1310.         }
  1311.         $operationResult['isOK']         = true;
  1312.         // 取引ID
  1313.         $operationResult['orderId']      = $mdkResponse->getOrderId();
  1314.         // 決済サービスタイプ
  1315.         $operationResult['serviceType']  = $mdkResponse->getServiceType();
  1316.         // 決済ステータス
  1317.         $operationResult['payStatus']    = $isRakuten
  1318.             $this->vt4gConst['VT4G_PAY_STATUS']['REDUCTION_REQUEST']['VALUE']
  1319.             : $this->vt4gConst['VT4G_PAY_STATUS']['REFUND']['VALUE'];
  1320.         // 売上金額
  1321.         $operationResult['captureTotal'] = (isset($payload['refundAll']) && $payload['refundAll']) ? floor($payload['order']->getPaymentTotal());
  1322.         // 減額
  1323.         $operationResult['amount']       = $amount;
  1324.         // ログの生成
  1325.         $this->setLogHead($payId''$operationResult);
  1326.         return [$operationResult$mdkResponse];
  1327.     }
  1328.     /**
  1329.      * 与信変更
  1330.      *
  1331.      * @param  array $payload 与信変更に使用するデータ
  1332.      * @return array          与信変更処理結果データ
  1333.      */
  1334.     public function operateUpdateauth($payload)
  1335.     {
  1336.         $payId   $payload['orderPayment']->getMemo03();
  1337.         $payName $this->util->getPayName($payId);
  1338.         $payStatusName $this->vt4gConst['VT4G_PAY_STATUS'][$payload['mode']]['LABEL'];
  1339.         $this->mdkLogger->info("管理者{$payName}[{$payStatusName}]通信実行");
  1340.         // 決済申込時の結果データ
  1341.         $prevPaymentResult unserialize($payload['orderPayment']->getMemo05());
  1342.         // 与信変更対象の取引ID
  1343.         $paymentOrderId $payload['orderPayment']->getMemo01();
  1344.         // レスポンス初期化
  1345.         $operationResult $this->initPaymentResult();
  1346.         // memo01から取得できない場合
  1347.         if (empty($paymentOrderId)) {
  1348.             // 決済申込時のレスポンスから取得できない場合
  1349.             if (empty($prevPaymentResult['orderId'])) {
  1350.                 $this->mdkLogger->fatal(trans('vt4g_plugin.payment.shopping.mdk.error'));
  1351.                 $operationResult['message'] = trans('vt4g_plugin.payment.shopping.error');
  1352.                 return [$operationResult, []];
  1353.             }
  1354.             // 決済申込時の結果から取得
  1355.             $paymentOrderId $prevPaymentResult['orderId'];
  1356.         }
  1357.         // リクエストの取得
  1358.         switch ($payId) {
  1359.             case $this->vt4gConst['VT4G_PAYTYPEID_RAKUTEN_V2']: // 楽天V2
  1360.                 $mdkRequest = new RakutenUpdateAuthorizeRequestDto();
  1361.                 break;
  1362.             default:
  1363.                 return [$operationResult, []];
  1364.         }
  1365.         $mdkRequest->setOrderId($paymentOrderId);
  1366.         switch ($payload['mode']) {
  1367.             case $this->vt4gConst['VT4G_OPERATION_UPDATEAUTH_EXTENSION']:
  1368.                 // 与信変更 (与信延長)
  1369.                 $mdkRequest->setAuthExtensionFlag(true);
  1370.                 break;
  1371.             case $this->vt4gConst['VT4G_OPERATION_UPDATEAUTH_AMOUNT']:
  1372.                 // 与信変更 (金額変更)
  1373.                 $mdkRequest->setAmount(floor($payload['order']->getPaymentTotal()));
  1374.                 break;
  1375.             case $this->vt4gConst['VT4G_OPERATION_UPDATEAUTH_AMOUNT_AND_EXTENSION']:
  1376.                 // 与信変更 (与信延長 + 金額変更)
  1377.                 $mdkRequest->setAuthExtensionFlag(true);
  1378.                 $mdkRequest->setAmount(floor($payload['order']->getPaymentTotal()));
  1379.                 break;
  1380.             default:
  1381.                 break;
  1382.         }
  1383.         $objTransaction = new TGMDK_Transaction();
  1384.         $mdkResponse $objTransaction->execute($mdkRequest);
  1385.         if (!isset($mdkResponse)) {
  1386.             $this->mdkLogger->fatal(trans('vt4g_plugin.payment.shopping.mdk.error'));
  1387.             $operationResult['message'] = trans('vt4g_plugin.payment.shopping.error');
  1388.             return [$operationResult, []];
  1389.         }
  1390.         // 結果コード
  1391.         $operationResult['mStatus']     = $mdkResponse->getMStatus();
  1392.         // 詳細コード
  1393.         $operationResult['vResultCode'] = $mdkResponse->getVResultCode();
  1394.         // エラーメッセージ
  1395.         $operationResult['mErrMsg']     = $mdkResponse->getMErrMsg();
  1396.         // 正常終了レスポンス以外の場合
  1397.         if ($operationResult['mStatus'] !== $this->vt4gConst['VT4G_RESPONSE']['MSTATUS']['OK']) {
  1398.             $operationResult['message']  = $operationResult['vResultCode'].':';
  1399.             $operationResult['message'] .= $operationResult['mErrMsg'];
  1400.             return [$operationResult$mdkResponse];
  1401.         }
  1402.         $operationResult['isOK']         = true;
  1403.         // 取引ID
  1404.         $operationResult['orderId']      = $mdkResponse->getOrderId();
  1405.         // 決済サービスタイプ
  1406.         $operationResult['serviceType']  = $mdkResponse->getServiceType();
  1407.         // 決済ステータス
  1408.         $operationResult['payStatus']    = $this->vt4gConst['VT4G_PAY_STATUS'][$payload['mode']]['VALUE'];
  1409.         // 売上金額
  1410.         $operationResult['captureTotal'] = floor($payload['order']->getPaymentTotal());
  1411.         // ログの生成
  1412.         $this->setLogHead($payId''$operationResult);
  1413.         // ログは与信変更を表示するが、payStatusは与信で更新を行う。
  1414.         $operationResult['payStatus']    = $this->vt4gConst['VT4G_PAY_STATUS']['AUTH']['VALUE'];
  1415.         return [$operationResult$mdkResponse];
  1416.     }
  1417.     /**
  1418.      * ログのマージ
  1419.      *
  1420.      * @param  array $storedLogMap データベースに保存済みのログ
  1421.      * @param  array $newLogMap    新規追加のログ
  1422.      * @return array               マージされたログ
  1423.      */
  1424.     private function getMergeLog($storedLogMap$newLogMap)
  1425.     {
  1426.         // 保存済みのログリスト
  1427.         if (empty($storedLogMap)) {
  1428.             return $newLogMap;
  1429.         }
  1430.         $keys array_keys($newLogMap);
  1431.         $changes = [];
  1432.         foreach ($keys as $index => $key) {
  1433.             if (array_key_exists($key$storedLogMap)) {
  1434.                 $changes["{$key} {$index}"] = $newLogMap[$key];
  1435.             } else {
  1436.                 $changes[$key] = $newLogMap[$key];
  1437.             }
  1438.         }
  1439.         return array_merge($storedLogMap$changes);
  1440.     }
  1441.     /**
  1442.      * 支払方法の説明を取得
  1443.      *
  1444.      * @param string $optionType サービスオプションタイプ
  1445.      * @return string 結果
  1446.      */
  1447.     public function getExplain($optionType)
  1448.     {
  1449.         // サービスオプションタイプからファイル名生成
  1450.         $path $this->container->get(\Eccube\Common\EccubeConfig::class)->get('plugin_realdir'). '/' $this->vt4gConst['VT4G_CODE'] . $this->vt4gConst['VT4G_DOC_PATH'];
  1451.         $path .= sprintf($this->vt4gConst['VT4G_EXPLAIN_FILE_NAME_FMT'], $optionType);
  1452.         // あれば取得
  1453.         if (file_exists($path) == true) {
  1454.             $rtnExplain file_get_contents($path);
  1455.         }
  1456.         return $rtnExplain ?? '';
  1457.     }
  1458.     /**
  1459.      * 入金(結果)通知先URLを取得
  1460.      *
  1461.      * @return string $pushUrl 入金(結果)通知先URL
  1462.      */
  1463.     public function getPushUrl()
  1464.     {
  1465.         $pushUrl '';
  1466.         $pluginSetting $this->util->getPluginSetting();
  1467.         if(!empty($pluginSetting['push_url_auto_setting'])){
  1468.             if ($pluginSetting['push_url_auto_setting'] === $this->vt4gConst['VT4G_PUSH_URL_AUTO_SETTING']['AUTO']) {
  1469.                 $pushUrl $this->util->generateUrl('vt4g_plugin_shopping_payment_recv');
  1470.             } elseif ($pluginSetting['push_url_auto_setting'] === $this->vt4gConst['VT4G_PUSH_URL_AUTO_SETTING']['MANUAL']) {
  1471.                 $pushUrl $pluginSetting['manual_push_url'];
  1472.             }
  1473.         }
  1474.         return $pushUrl;
  1475.     }
  1476. }