Skip to content

Commit

Permalink
STRIPE CONNECT
Browse files Browse the repository at this point in the history
  • Loading branch information
TMuthulakshmi committed Jan 21, 2023
1 parent 1665f57 commit ec9dfae
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/Controllers/Api/Myaccount/AccountInfo/Index.php
Expand Up @@ -4,13 +4,15 @@

use App\Controllers\BaseController;
use App\Models\Users;
use App\Models\Stripe;

class Index extends BaseController
{

public function __construct()
{
$this->users = new Users();
$this->stripe = new Stripe();
}

public function index()
Expand Down Expand Up @@ -105,4 +107,34 @@ public function action(){
die;

}

public function stripeconnect()
{
$post = $this->request->getPost();
$url = base_url().'/myaccount/account';
$userdetail = getUserDetails($post['user_id']);

$stripeconnect = $this->stripe->createAccount();
if($stripeconnect){
$this->users->action(['actionid' => $userdetail['id'], 'userid' => $userdetail['id'], 'stripe_account_id' => $stripeconnect['id']]);

$accountlink = $this->stripe->createAccountLink($stripeconnect['id'], $url, $url);
if($accountlink){
$json = ['1','Connected Stripe.', $accountlink['url']];
//return redirect()->to($accountlink['url']);
}else{
$json = ['0', 'Try again Later.', []];
}
}else{
$json = ['0', 'Try again Later.', []];
}

echo json_encode([
'status' => $json[0],
'message' => $json[1],
'result' => $json[2],
]);

die;
}
}

0 comments on commit ec9dfae

Please sign in to comment.