PATH:
home
/
lab2454c
/
sothebry.softkinesis.com
/
backups
/
core
/
app
/
Http
/
Controllers
/
NftGateway
/
Stripe
<?php namespace App\Http\Controllers\NftGateway\Stripe; use App\Models\Deposit; use App\Models\NftOrder; use App\Models\Bid; use App\Models\GeneralSetting; use App\Http\Controllers\Gateway\PaymentController; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Stripe\Charge; use Stripe\Stripe; use Stripe\Token; use Illuminate\Support\Facades\Session; use App\Models\GatewayCurrency; use App\Models\AdminNotification; class ProcessController extends Controller { /* * Stripe Gateway */ public static function process($gatewayCurrency) { $send['view'] = 'user.fashionNft.payment.'.$gatewayCurrency->gateway_alias; $send['method'] = 'post'; $send['url'] = route('nft-ipn.'.$gatewayCurrency->gateway_alias, $gatewayCurrency); return json_encode($send); } public function ipn(Request $request, GatewayCurrency $gatewayCurrency) { // $track = Session::get('Track'); // $deposit = Deposit::where('trx', $track)->orderBy('id', 'DESC')->first(); // if ($deposit->status == 1) { // $notify[] = ['error', 'Invalid request.']; // return redirect()->route(gatewayRedirectUrl())->withNotify($notify); // } //dd($gatewayCurrency); $this->validate($request, [ 'cardNumber' => 'required', 'cardExpiry' => 'required', 'cardCVC' => 'required', ]); $finalPrice = session()->get('finalPrice'); $cc = $request->cardNumber; $exp = $request->cardExpiry; $cvc = $request->cardCVC; $exp = $pieces = explode("/", $_POST['cardExpiry']); $emo = trim($exp[0]); $eyr = trim($exp[1]); $cnts = round($finalPrice, 2) * 100; $stripeAcc = json_decode($gatewayCurrency->gateway_parameter); Stripe::setApiKey($stripeAcc->secret_key); Stripe::setApiVersion("2020-03-02"); try { $token = Token::create(array( "card" => array( "number" => "$cc", "exp_month" => $emo, "exp_year" => $eyr, "cvc" => "$cvc" ) )); try { $charge = Charge::create(array( 'card' => $token['id'], 'currency' => $gatewayCurrency->currency, 'amount' => $cnts, 'description' => 'item', )); if ($charge['status'] == 'succeeded') { $bid_id = session()->get('bid_id'); $bid = Bid::findOrFail($bid_id); //$finalPrice = $bid->price + ($bid->price * (4/100)); $orderNumber = getTrx(); $order = new NftOrder(); $order->price = $finalPrice; $order->order_number = $orderNumber; $order->bid()->associate($bid); $order->user()->associate($bid->user); $order->fashionNft()->associate($bid->fashionNft); $order->gateway_alias = $gatewayCurrency->gateway_alias; $order->method_currency = $gatewayCurrency->currency; $order->status = 1; $order->save(); $adminNotification = new AdminNotification(); $adminNotification->user_id = $bid->user->id; $adminNotification->title = 'Payment successful for ' .$bid->fashionNft->name . ' with Order No ' .$orderNumber; $adminNotification->click_url = urlPath('admin.nftOrderList'); $adminNotification->save(); $nftName = $bid->fashionNft->name; $seller = $bid->fashionNft->user; $buyer = $bid->user->fullname; sendEmail($seller, 'BID_PAYMENT_COMPLETE', [ 'fashionNft' => $nftName, 'buyer' => $buyer ]); $notify[] = ['success', 'Payment captured successfully.']; //Forget Session Variable session()->forget(['finalPrice']); return redirect()->route(nftgatewayRedirectUrl())->withNotify($notify); } } catch (\Exception $e) { $notify[] = ['error', $e->getMessage()]; } } catch (\Exception $e) { $notify[] = ['error', $e->getMessage()]; } return redirect()->route(nftgatewayRedirectUrl())->withNotify($notify); } }
[+]
..
[-] ProcessController.php
[edit]