Minor fixes for Square

This commit is contained in:
David Bomba 2021-10-03 13:36:43 +11:00
parent a7c4548a1c
commit 6c1ba6d40b
3 changed files with 50 additions and 29 deletions

View File

@ -15,6 +15,7 @@ namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Http\Requests\ClientPortal\Uploads\StoreUploadRequest;
use App\Libraries\MultiDB;
use App\Models\Account;
use App\Models\ClientContact;
use App\Models\Company;
use App\Utils\Ninja;
@ -26,14 +27,21 @@ use Illuminate\Support\Facades\Auth;
class NinjaPlanController extends Controller
{
public function index(string $contact_key, string $company_key)
public function index(string $contact_key, string $account_or_company_key)
{
MultiDB::findAndSetDbByCompanyKey($company_key);
$company = Company::where('company_key', $company_key)->first();
MultiDB::findAndSetDbByCompanyKey($account_or_company_key);
$company = Company::where('company_key', $account_or_company_key)->first();
if(!$company){
MultiDB::findAndSetDbByAccountKey($account_or_company_key);
$account = Account::where('key', $account_or_company_key)->first();
}
else
$account = $company->account;
nlog("Ninja Plan Controller Company key found {$company->company_key}");
$account = $company->account;
if (MultiDB::findAndSetDbByContactKey($contact_key) && $client_contact = ClientContact::where('contact_key', $contact_key)->first())
{

View File

@ -270,6 +270,10 @@ class CreditCard
if ($api_response->isSuccess()) {
$customers = $api_response->getBody();
$customers = json_decode($customers);
if(count(array($api_response->getBody(),1)) == 0)
$customers = false;
} else {
$errors = $api_response->getErrors();
}

View File

@ -60,12 +60,16 @@ class ACH
'method' => '1',
*/
try{
$response = $this->wepay_payment_driver->wepay->request('payment_bank/persist', [
'client_id' => config('ninja.wepay.client_id'),
'client_secret' => config('ninja.wepay.client_secret'),
'payment_bank_id' => (int)$data['bank_account_id'],
]);
}
catch(\Exception $e){
throw new PaymentFailed($e->getMessage(), 400);
}
// display the response
// nlog($response);
@ -202,6 +206,7 @@ class ACH
$app_fee = (config('ninja.wepay.fee_ach_multiplier') * $this->wepay_payment_driver->payment_hash->data->amount_with_fee) + config('ninja.wepay.fee_fixed');
try{
$response = $this->wepay_payment_driver->wepay->request('checkout/create', array(
// 'callback_uri' => route('payment_webhook', ['company_key' => $this->wepay_payment_driver->company_gateway->company->company_key, 'company_gateway_id' => $this->wepay_payment_driver->company_gateway->hashed_id]),
'unique_id' => Str::random(40),
@ -221,6 +226,10 @@ class ACH
)
)
));
}
catch(\Exception $e){
throw new PaymentFailed($e->getMessage(), 500);
}
/* Merge all data and store in the payment hash*/
$state = [