����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 3.133.122.83 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/www/common/Billing/Gateways/Paypal/ |
Upload File : |
<?php namespace Common\Billing\Gateways\Paypal; use Common\Billing\BillingPlan; use Common\Billing\GatewayException; use Common\Billing\Subscription; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Common\Core\BaseController; class PaypalController extends BaseController { /** * @var Request */ private $request; /** * @var BillingPlan */ private $billingPlan; /** * @var Subscription */ private $subscription; /** * @var PaypalGateway */ private $paypal; /** * @param Request $request * @param BillingPlan $billingPlan * @param Subscription $subscription * @param PaypalGateway $paypal */ public function __construct( Request $request, BillingPlan $billingPlan, Subscription $subscription, PaypalGateway $paypal ) { $this->paypal = $paypal; $this->request = $request; $this->billingPlan = $billingPlan; $this->subscription = $subscription; $this->middleware('auth', ['except' => [ 'approvedCallback', 'canceledCallback', 'loadingPopup'] ]); } /** * Create subscription agreement on paypal. * * @return JsonResponse * @throws GatewayException */ public function createSubscriptionAgreement() { $this->validate($this->request, [ 'plan_id' => 'required|integer|exists:billing_plans,id', 'start_date' => 'string' ]); $urls = $this->paypal->subscriptions()->create( $this->billingPlan->findOrFail($this->request->get('plan_id')), $this->request->user(), $this->request->get('start_date') ); return $this->success(['urls' => $urls]); } /** * Execute subscription agreement on paypal. * * @return JsonResponse * @throws GatewayException */ public function executeSubscriptionAgreement() { $this->validate($this->request, [ 'agreement_id' => 'required|string|min:1', 'plan_id' => 'required|integer|exists:billing_plans,id', ]); $subscriptionId = $this->paypal->subscriptions()->executeAgreement( $this->request->get('agreement_id') ); $plan = $this->billingPlan->findOrFail($this->request->get('plan_id')); $this->request->user()->subscribe('paypal', $subscriptionId, $plan); return $this->success(['user' => $this->request->user()->loadPermissions(true)->load('subscriptions.plan')]); } /** * Called after user approves paypal payment. */ public function approvedCallback() { return view('common::billing/paypal-popup')->with([ 'token' => $this->request->get('token'), 'status' => 'success', ]); } /** * Called after user cancels paypal payment. */ public function canceledCallback() { return view('common::billing/paypal-popup')->with([ 'token' => $this->request->get('token'), 'status' => 'cancelled', ]); } /** * Show loading view for paypal. */ public function loadingPopup() { return view('common::billing/loading-popup'); } }