|
- <?php
-
- namespace App\Http\Controllers\Web\RobotPayment\CreditCard;
-
- use App\Http\Controllers\Web\WebController;
- use App\Kintone\Models\CreditcardAutoPaymentInfo;
- use App\Kintone\Models\CreditcardAutoPaymentResult;
- use App\Kintone\Models\Customer;
- use App\Util\DateUtil;
- use Exception;
- use Illuminate\Database\Eloquent\ModelNotFoundException;
- use Illuminate\Http\Request;
- use Illuminate\Http\Response;
- use Illuminate\Support\Facades\Log;
- use LogicException;
-
- class PaymentInfoController extends WebController
- {
-
- public function name(): string
- {
- return "クレジットカード 自動課金情報登録";
- }
-
- public function description(): string
- {
- return "クレジットカード 自動課金情報登録";
- }
-
- public function __construct(protected PaymentInfoParam $param)
- {
- parent::__construct();
- }
-
- protected function run(Request $request): Response
- {
- $param = $this->param;
- logger("リクエスト受信 creditcard", ["param" => $request->all()]);
-
- // 認証チェック
- // 初回の決済結果はトークン付で送信されるのでチェックする
- if ($param->token !== config('custom.creditcard.token')) {
- abort(403);
- }
-
- $customer = Customer::findByCustomerCode($param->customerCode);
-
- $customer->paymentMethod = "クレジットカード";
-
- $model = new CreditcardAutoPaymentInfo();
-
- $model->customerCode = $param->customerCode;
- $model->autoPaymentNo = $param->acid;
- $model->shopOrderNo = $param->cod;
-
- // 機密な情報をリクエストデータから除外して登録する
- $requestArr = request()->toArray();
- unset($requestArr["token"]);
- unset($requestArr["id"]);
- unset($requestArr["pa"]);
- $model->dataResult = json_encode(
- $requestArr,
- JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT
- );
-
- $model->save();
- $customer->save();
-
- return response()->view('robot-payment.creditcard.ok');
- }
- }
|