<?php

namespace App\Http\Controllers;

use App\Http\Helpers\StripeClient;
use Illuminate\Http\Request;

class StripeController extends Controller
{

    public function form()
    {
        return view('form');
    }
    /**
     * payment view
     */
    public function handleGet()
    {
        return view('stripe');
    }

    /**
     * handling payment with POST
     */
    public function handlePost(Request $request)
    {
//        Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
//        $charge = Stripe\Charge::create ([
//            "amount" => 100 * 150,
//            "currency" => "sar",
//            "source" => $request->stripeToken,
//            "description" => "Making test payment."
//        ]);
//        $charge =StripeClient::charge([
//            'amount' => 100*1000,
//            'currency'=>'sar',
//            'source' => $request->stripeToken,
//            'description' => 'Testing'
//        ]);
//        $account = StripeClient::stripe()->accounts->create(
//        [
//            'country' => 'EG',
//            'type' => 'custom',
//            'capabilities' => [
//                'transfers' => ['requested' => true],
//
//            ],
//            'tos_acceptance' => ['service_agreement' => 'recipient'],
//        ]
//    );
//        dd($account);
//        $card = StripeClient::stripe(true)->accounts->createExternalAccount(
//            'acct_1JZLWXKquuW94KlB',
//            ['external_account' => $request->stripeToken],
//        );
//        dd($card);
//        dd($charge, StripeClient::stripe()->charges->all(),StripeClient::stripe()->balance->retrieve());
//        $account = StripeClient::setAccountInterival((string)env('CONNECTED_STRIPE_ACCOUNT'),'manual');
//        dd($account);
//        $payout = StripeClient::charge([
//            "amount" => 100 * 150,
//            "currency" => "sar",
//            //"source" => $request->stripeToken,
//            "description" => "Making test payment.",
//            ]);
//        dd($payout);
//        $account = StripeClient::createAccount([
//            'country' => 'US',
//            'email' => auth()->user()->email,
//        ]);
//        $bank = StripeClient::addBankAccount((string)env('CONNECTED_STRIPE_ACCOUNT'), [
//            'external_account' => $request->stripeToken,
//        ]);
//        dd($account, $bank);

        return back(303)->with(['success => success']);
    }
}
