<?php

namespace Modules\Payments\app\Http\Controllers\Api\v1;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\Payments\app\Models\Payment;
use App\Enums\PaymentStatus;
use Illuminate\Support\Facades\Http;
use Appp\Helpers\ResponseHelper;

class PaymentApiController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request)
    {
        //$data = $request->all();
        $response = Http::withHeaders([


            'Accept' => 'application/json',
            'Content-Type' => 'application/json',

        ])->withBasicAuth('279197', 'fef9e5efa8c5865975f3d057ba13a9d3')->post("https://sandbox.przelewy24.pl/api/v1/card/pay",[
            'transactionToken' => $request->token,
            'cardNumber' => $request->card_number,
            'cardDate' => $request->card_date,
            'cvv' => $request->cvv,
            'clientName' => $request->client_name
            ]);                             

        $result = json_decode($response -> getBody()->getContents());
        return sendResponse($result,'Payment created successfully.');
    }

}
