2021-04-12 12:11:08 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2021-04-12 12:11:08 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2021-04-12 12:11:08 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\PaymentDrivers\Stripe\Connect;
|
|
|
|
|
|
|
|
class Account
|
|
|
|
{
|
2021-04-20 16:08:33 +02:00
|
|
|
/**
|
|
|
|
* @throws \Stripe\Exception\ApiErrorException
|
|
|
|
*/
|
|
|
|
public static function create(array $payload): \Stripe\Account
|
|
|
|
{
|
|
|
|
$stripe = new \Stripe\StripeClient(
|
2021-04-21 00:38:50 +02:00
|
|
|
config('ninja.ninja_stripe_key')
|
2021-04-20 16:08:33 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return $stripe->accounts->create([
|
|
|
|
'type' => 'standard',
|
|
|
|
'country' => $payload['country'],
|
|
|
|
'email' => $payload['email'],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws \Stripe\Exception\ApiErrorException
|
|
|
|
*/
|
2021-04-21 16:36:08 +02:00
|
|
|
public static function link(string $account_id, string $token): \Stripe\AccountLink
|
2021-04-20 16:08:33 +02:00
|
|
|
{
|
|
|
|
$stripe = new \Stripe\StripeClient(
|
2021-04-21 00:38:50 +02:00
|
|
|
config('ninja.ninja_stripe_key')
|
2021-04-20 16:08:33 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
return $stripe->accountLinks->create([
|
|
|
|
'account' => $account_id,
|
2021-04-21 16:36:08 +02:00
|
|
|
'refresh_url' => route('stripe_connect.initialization', $token),
|
|
|
|
'return_url' => route('stripe_connect.return'),
|
2021-04-20 16:08:33 +02:00
|
|
|
'type' => 'account_onboarding',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|