mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Stripe Verify
This commit is contained in:
parent
674f7c8341
commit
383caa6439
@ -14,10 +14,13 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\Util\ImportStripeCustomers;
|
||||
use App\Jobs\Util\StripeUpdatePaymentMethods;
|
||||
use App\Models\CompanyGateway;
|
||||
|
||||
class StripeController extends BaseController
|
||||
{
|
||||
|
||||
private $stripe_keys = ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'];
|
||||
|
||||
public function update()
|
||||
{
|
||||
if(auth()->user()->isAdmin())
|
||||
@ -50,4 +53,22 @@ class StripeController extends BaseController
|
||||
return response()->json(['message' => 'Unauthorized'], 403);
|
||||
}
|
||||
|
||||
public function verify()
|
||||
{
|
||||
|
||||
if(auth()->user()->isAdmin())
|
||||
{
|
||||
|
||||
$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);
|
||||
|
||||
}
|
||||
}
|
@ -49,6 +49,7 @@ class ImportStripeCustomers implements ShouldQueue
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
$cgs = CompanyGateway::where('company_id', $this->company->id)
|
||||
->where('is_deleted',0)
|
||||
->whereIn('gateway_key', $this->stripe_keys)
|
||||
->get();
|
||||
|
||||
|
@ -37,6 +37,7 @@ class Verify
|
||||
use MakesHash;
|
||||
|
||||
/** @var StripePaymentDriver */
|
||||
|
||||
public $stripe;
|
||||
|
||||
public function __construct(StripePaymentDriver $stripe)
|
||||
@ -44,11 +45,16 @@ class Verify
|
||||
$this->stripe = $stripe;
|
||||
}
|
||||
|
||||
public function verifyAccountLinked()
|
||||
public function run()
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
$map = $this->stripe->company_gateway->client_gateway_tokens->map(function ($cgt){
|
||||
if($this->stripe->stripe_connect && strlen($this->company_gateway->getConfigField('account_id')) < 1))
|
||||
return response()->json("Stripe Connect not authenticated", 400);
|
||||
|
||||
$customers = Customer::all([], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$stripe_customers = $this->stripe->company_gateway->client_gateway_tokens->map(function ($cgt){
|
||||
|
||||
$customer = Customer::retrieve($cgt->gateway_customer_reference, $this->stripe->stripe_connect_auth);
|
||||
|
||||
@ -59,6 +65,11 @@ class Verify
|
||||
|
||||
});
|
||||
|
||||
return $map;
|
||||
$data = [
|
||||
'stripe_customer_count' => count($customers),
|
||||
'stripe_customers' => $stripe_customers,
|
||||
];
|
||||
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
}
|
@ -25,6 +25,7 @@ use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Stripe\ACH;
|
||||
use App\PaymentDrivers\Stripe\Alipay;
|
||||
use App\PaymentDrivers\Stripe\Charge;
|
||||
use App\PaymentDrivers\Stripe\Connect\Verify;
|
||||
use App\PaymentDrivers\Stripe\CreditCard;
|
||||
use App\PaymentDrivers\Stripe\ImportCustomers;
|
||||
use App\PaymentDrivers\Stripe\SOFORT;
|
||||
@ -536,4 +537,9 @@ class StripePaymentDriver extends BaseDriver
|
||||
//match clients based on the gateway_customer_reference column
|
||||
|
||||
}
|
||||
|
||||
public function verifyConnect()
|
||||
{
|
||||
return (new Verify($this))->run();
|
||||
}
|
||||
}
|
||||
|
@ -190,6 +190,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
||||
Route::post('stripe/update_payment_methods', 'StripeController@update')->middleware('password_protected')->name('stripe.update');
|
||||
Route::post('stripe/import_customers', 'StripeController@import')->middleware('password_protected')->name('stripe.import');
|
||||
|
||||
Route::post('stripe/verify', 'StripeController@verify')->middleware('password_protected')->name('stripe.verify');
|
||||
|
||||
Route::resource('subscriptions', 'SubscriptionController');
|
||||
Route::post('subscriptions/bulk', 'SubscriptionController@bulk')->name('subscriptions.bulk');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user