1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Http/Controllers/StripeController.php

78 lines
1.7 KiB
PHP
Raw Normal View History

2021-05-17 06:02:43 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
2021-06-16 08:58:16 +02:00
* @license https://www.elastic.co/licensing/elastic-license
2021-05-17 06:02:43 +02:00
*/
namespace App\Http\Controllers;
use App\Jobs\Util\ImportStripeCustomers;
2021-05-17 06:02:43 +02:00
use App\Jobs\Util\StripeUpdatePaymentMethods;
2021-09-02 04:08:16 +02:00
use App\Libraries\MultiDB;
2021-08-15 07:49:36 +02:00
use App\Models\Client;
2021-08-15 07:13:20 +02:00
use App\Models\CompanyGateway;
2021-05-17 06:02:43 +02:00
class StripeController extends BaseController
{
2021-08-15 07:13:20 +02:00
private $stripe_keys = ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'];
2021-05-17 06:02:43 +02:00
public function update()
{
if(auth()->user()->isAdmin())
{
StripeUpdatePaymentMethods::dispatch(auth()->user()->company());
2021-05-17 06:02:43 +02:00
2021-05-19 05:32:20 +02:00
return response()->json(['message' => 'Processing'], 200);
2021-05-17 06:02:43 +02:00
}
return response()->json(['message' => 'Unauthorized'], 403);
}
public function import()
{
2021-07-18 09:30:29 +02:00
// return response()->json(['message' => 'Processing'], 200);
2021-07-09 02:44:34 +02:00
if(auth()->user()->isAdmin())
{
ImportStripeCustomers::dispatch(auth()->user()->company());
2021-05-19 05:32:20 +02:00
return response()->json(['message' => 'Processing'], 200);
}
2021-05-17 06:02:43 +02:00
return response()->json(['message' => 'Unauthorized'], 403);
}
2021-08-15 07:13:20 +02:00
public function verify()
{
if(auth()->user()->isAdmin())
{
2021-09-02 04:08:16 +02:00
MultiDB::findAndSetDbByCompanyKey(auth()->user()->company()->company_key);
2021-08-15 07:13:20 +02:00
$company_gateway = CompanyGateway::where('company_id', auth()->user()->company()->id)
->where('is_deleted',0)
->whereIn('gateway_key', $this->stripe_keys)
->first();
return $company_gateway->driver(new Client)->verifyConnect();
}
return response()->json(['message' => 'Unauthorized'], 403);
}
2021-05-17 06:02:43 +02:00
}