private function saveOrder($result) { $payment = new Payments(); $payment['payment_id'] = $result->id; $payment['state'] = $result->state; $payment['intent'] = $result->intent; $payment['cart'] = $result->cart; $payment['user_id'] = Auth::user()->id; $payment->save(); $payer = new Payers(); $payer['payer_id'] = $result->payer->payer_info->payer_id; $payer['payment_id'] = $result->id; $payer['email'] = $result->payer->payer_info->email; $payer['first_name'] = $result->payer->payer_info->first_name; $payer['last_name'] = $result->payer->payer_info->last_name; $payer['recipient_name'] = $result->payer->payer_info->shipping_address->recipient_name; $payer['line1'] = $result->payer->payer_info->shipping_address->line1; $payer['city'] = $result->payer->payer_info->shipping_address->city; $payer['state'] = $result->payer->payer_info->shipping_address->state; $payer['postal_code'] = $result->payer->payer_info->shipping_address->postal_code; $payer['phone'] = $result->payer->payer_info->phone; $payer->save(); foreach ($result->transactions[0]->item_list->items as $item) { $transaction = new Transactions(); $transaction['payment_id'] = $result->id; $transaction['book_id'] = $item->sku; $transaction['price'] = $item->price; $transaction['currency'] = $item->currency; $transaction['quantity'] = $item->quantity; $transaction['description'] = $item->description; $transaction->save(); $book = Book::find($item->sku); $book['active'] = 0; $book->save(); } }
/** * @return bank_accounts */ public function addAccountProcess() { $input = Request::all(); var_dump($input); //return($input); if (isset($input['radio'])) { $uri = 'https://tartan.plaid.com/connect/step'; $access_token = '{"send_method":{"mask":"' . $input["radio"] . '"}}'; $parameters = ['json' => ['client_id' => env('PLAID_CLIENT_ID'), 'secret' => env('PLAID_SECRET'), 'access_token' => $input['access_token'], 'options' => $options]]; } else { if (isset($input['access_token'])) { $uri = 'https://tartan.plaid.com/connect/step'; $parameters = ['json' => ['client_id' => env('PLAID_CLIENT_ID'), 'secret' => env('PLAID_SECRET'), 'access_token' => $input['access_token'], 'mfa' => $input['ans']]]; } else { $uri = 'https://tartan.plaid.com/connect'; $parameters = ['json' => ['client_id' => env('PLAID_CLIENT_ID'), 'secret' => env('PLAID_SECRET'), 'username' => $input['username'], 'password' => $input['password'], 'type' => $input['bank'], 'options' => '{"list":true}']]; } } //curl.cainfo ="{filepath}\cacert.pem" add this line to php.ini & cacert.pem file to location $client = new Client(); $response = $client->post($uri, $parameters); $array = json_decode($response->getBody(), true); //return ($response); if (isset($array['type'])) { if ($array['type'] == "questions") { $mfa = $array['mfa'][0]; $pass = $mfa['question']; return view('user.addAccountStep')->with('pass', $pass)->with('access_token', $array['access_token']); } else { if ($array['type'] == "device") { $mfa = $array['mfa']; $pass = $mfa['message']; return view('user.addAccountStep')->with('pass', $pass)->with('access_token', $array['access_token']); } else { if ($array['type'] == "list") { $mfa = $array['mfa'][0]; $pass = $array['mfa']; return view('user.addAccountStep')->with('pass', $pass)->with('access_token', $array['access_token']); } } } } $accounts = $array['accounts']; //return (dump($accounts)); foreach ($accounts as $account_key => $account_value) { $bank_account = new bank_accounts(); $bank_account['id'] = $account_value['_id']; $bank_account['user_id'] = Auth::user()->id; $bank_account['access_token'] = $array['access_token']; //if(isset($account_value['balance']['current'])) $bank_account['current_balance'] = $account_value['balance']['current']; //if(isset($account_value['balance']['available'])) $bank_account['available_balance'] = $account_value['balance']['available']; $bank_account['bank_name'] = $account_value['institution_type']; if (isset($account_value['meta']['acc_limit'])) { $bank_account['acc_limit'] = $account_value['meta']['acc_limit']; } if (isset($account_value['subtype'])) { $bank_account['account_subtype'] = $account_value['subtype']; } $bank_account['name'] = $account_value['meta']['name']; $bank_account['number'] = $account_value['meta']['number']; $bank_account['account_type'] = $account_value['type']; $bank_account['plaid_core'] = serialize($account_value); $bank_account->save(); } $transactions = $array['transactions']; //return $transactions; foreach ($transactions as $transaction_key => $transaction_value) { $transaction = new transaction(); $transaction['bank_accounts_id'] = $transaction_value['_account']; $transaction['amount'] = $transaction_value['amount']; $transaction['date'] = $transaction_value['date']; $transaction['name'] = $transaction_value['name']; if (isset($transaction_value['meta']['location']['city'])) { $transaction['location_city'] = $transaction_value['meta']['location']['city']; } if (isset($transaction_value['meta']['location']['state'])) { $transaction['location_state'] = $transaction_value['meta']['location']['state']; } $transaction['pending'] = $transaction_value['pending']; $transaction['type_primary'] = $transaction_value['type']['primary']; if (isset($transaction_value['category'])) { $transaction['category'] = serialize($transaction_value['category']); } if (isset($transaction_value['category_id'])) { $transaction['category_id'] = $transaction_value['category_id']; } $transaction['score'] = serialize($transaction_value['score']); $transaction['plaid_core'] = serialize($transaction_value); $transaction->save(); } //return $transaction; return redirect::to('user/dashboard'); }