From 0cd3b6925e011bda8a9cf4f01504a0855abd850a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 08:28:19 +1000 Subject: [PATCH 1/8] fixes for autobill invoice --- app/Http/Middleware/QueryLogging.php | 2 +- app/Services/Invoice/AutoBillInvoice.php | 31 +++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/Http/Middleware/QueryLogging.php b/app/Http/Middleware/QueryLogging.php index 629f41a3ba30..659612e4d831 100644 --- a/app/Http/Middleware/QueryLogging.php +++ b/app/Http/Middleware/QueryLogging.php @@ -51,7 +51,7 @@ class QueryLogging // Log::info($request->method() . ' - ' . $request->url() . ": $count queries - " . $time); //if($count > 10) - Log::info($queries); + // Log::info($queries); } } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 578c8f8b4943..ee8f3baed3e6 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -44,8 +44,12 @@ class AutoBillInvoice extends AbstractService if($this->invoice->balance > 0) $gateway_token = $this->getGateway($this->invoice->balance); - else - return $this->invoice->service()->markPaid()->save(); + + // else + // return $this->invoice->service()->markPaid()->save(); + + if(!$gateway_token) + return $this->invoice; $fee = $gateway_token->gateway->calcGatewayFee($this->invoice->balance); @@ -60,13 +64,28 @@ class AutoBillInvoice extends AbstractService private function getGateway($amount) { - $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC'); + // $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC'); - return $gateway_tokens->filter(function ($token) use ($amount){ + // return $gateway_tokens->filter(function ($token) use ($amount){ - return $this->validGatewayLimits($token, $amount); + // return $this->validGatewayLimits($token, $amount); - })->all()->first(); + // })->all()->first(); + + + $gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC')->get(); + + foreach($gateway_tokens as $gateway_token) + { + if($this->validGatewayLimits($gateway_token, $amount)) + return $gateway_token; + } + + // return collect($gateway_tokens)->filter(function ($token) use ($amount){ + + // return $this->validGatewayLimits($token, $amount); + + // })->first(); } From b96e2aa78bc836226660fd5a9491c08023b5283f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 09:29:44 +1000 Subject: [PATCH 2/8] Bulk actions for tax rates --- .../Controllers/OpenAPI/TaxRateSchema.php | 1 + app/Http/Controllers/TaxRateController.php | 85 ++++++++++++++++++- app/Services/Invoice/AutoBillInvoice.php | 13 +-- app/Transformers/TaxRateTransformer.php | 1 + ..._065301_add_token_id_to_activity_table.php | 4 + routes/api.php | 1 + 6 files changed, 92 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/OpenAPI/TaxRateSchema.php b/app/Http/Controllers/OpenAPI/TaxRateSchema.php index 17ae45587f00..5e0b7f882896 100644 --- a/app/Http/Controllers/OpenAPI/TaxRateSchema.php +++ b/app/Http/Controllers/OpenAPI/TaxRateSchema.php @@ -6,5 +6,6 @@ * @OA\Property(property="id", type="string", example="Opnel5aKBz", description="______"), * @OA\Property(property="name", type="string", example="GST", description="______"), * @OA\Property(property="rate", type="number", example="10", description="______"), + * @OA\Property(property="is_deleted", type="boolean", example=true, description="______"), * ) */ diff --git a/app/Http/Controllers/TaxRateController.php b/app/Http/Controllers/TaxRateController.php index d007b15ff6fc..995c988f6576 100644 --- a/app/Http/Controllers/TaxRateController.php +++ b/app/Http/Controllers/TaxRateController.php @@ -12,13 +12,14 @@ namespace App\Http\Controllers; use App\Factory\TaxRateFactory; +use App\Http\Requests\TaxRate\CreateTaxRateRequest; use App\Http\Requests\TaxRate\DestroyTaxRateRequest; use App\Http\Requests\TaxRate\EditTaxRateRequest; use App\Http\Requests\TaxRate\ShowTaxRateRequest; use App\Http\Requests\TaxRate\StoreTaxRateRequest; use App\Http\Requests\TaxRate\UpdateTaxRateRequest; -use App\Http\Requests\TaxRate\CreateTaxRateRequest; use App\Models\TaxRate; +use App\Repositories\BaseRepository; use App\Transformers\TaxRateTransformer; use Illuminate\Http\Request; @@ -32,9 +33,13 @@ class TaxRateController extends BaseController protected $entity_transformer = TaxRateTransformer::class; - public function __construct() + protected $base_repo; + + public function __construct(BaseRepository $base_repo) { parent::__construct(); + + $this->base_repo = $base_repo; } /** @@ -354,8 +359,82 @@ class TaxRateController extends BaseController */ public function destroy(DestroyTaxRateRequest $request, TaxRate $tax_rate) { + $tax_rate->is_deleted = true; + $tax_rate->save(); $tax_rate->delete(); - return response()->json([], 200); + return $this->itemResponse($tax_rate); } + + + /** + * Perform bulk actions on the list view + * + * @param BulkTaxRateRequest $request + * @return \Illuminate\Http\Response + * + * + * @OA\Post( + * path="/api/v1/tax_rates/bulk", + * operationId="bulkTaxRates", + * tags={"tax_rates"}, + * summary="Performs bulk actions on an array of TaxRates", + * description="", + * @OA\Parameter(ref="#/components/parameters/X-Api-Secret"), + * @OA\Parameter(ref="#/components/parameters/X-Api-Token"), + * @OA\Parameter(ref="#/components/parameters/X-Requested-With"), + * @OA\Parameter(ref="#/components/parameters/index"), + * @OA\RequestBody( + * description="Tax Rates", + * required=true, + * @OA\MediaType( + * mediaType="application/json", + * @OA\Schema( + * type="array", + * @OA\Items( + * type="integer", + * description="Array of hashed IDs to be bulk 'actioned", + * example="[0,1,2,3]", + * ), + * ) + * ) + * ), + * @OA\Response( + * response=200, + * description="The TaxRate List response", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"), + * @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"), + * @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"), + * @OA\JsonContent(ref="#/components/schemas/Webhook"), + * ), + * @OA\Response( + * response=422, + * description="Validation error", + * @OA\JsonContent(ref="#/components/schemas/ValidationError"), + * ), + * @OA\Response( + * response="default", + * description="Unexpected Error", + * @OA\JsonContent(ref="#/components/schemas/Error"), + * ), + * ) + */ + public function bulk() + { + $action = request()->input('action'); + + $ids = request()->input('ids'); + + $tax_rate = TaxRate::withTrashed()->find($this->transformKeys($ids)); + + + $tax_rate->each(function ($tax_rat, $key) use ($action) { + if (auth()->user()->can('edit', $tax_rate)) { + $this->base_repo->{$action}($tax_rate); + } + }); + + return $this->listResponse(TaxRate::withTrashed()->whereIn('id', $this->transformKeys($ids))); + } + } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index ee8f3baed3e6..397336a1855d 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -43,10 +43,9 @@ class AutoBillInvoice extends AbstractService return $this->invoice; if($this->invoice->balance > 0) - $gateway_token = $this->getGateway($this->invoice->balance); - - // else - // return $this->invoice->service()->markPaid()->save(); + $gateway_token = $this->getGateway($this->invoice->balance); + else + return $this->invoice->service()->markPaid()->save(); if(!$gateway_token) return $this->invoice; @@ -81,12 +80,6 @@ class AutoBillInvoice extends AbstractService return $gateway_token; } - // return collect($gateway_tokens)->filter(function ($token) use ($amount){ - - // return $this->validGatewayLimits($token, $amount); - - // })->first(); - } /** diff --git a/app/Transformers/TaxRateTransformer.php b/app/Transformers/TaxRateTransformer.php index b408923a1548..771a0ede28c5 100644 --- a/app/Transformers/TaxRateTransformer.php +++ b/app/Transformers/TaxRateTransformer.php @@ -18,6 +18,7 @@ class TaxRateTransformer extends EntityTransformer 'id' => (string) $this->encodePrimaryKey($tax_rate->id), 'name' => (string) $tax_rate->name, 'rate' => (float) $tax_rate->rate, + 'is_deleted' => (bool) $tax_rate->is_deleted, 'updated_at' => (int)$tax_rate->updated_at, 'archived_at' => (int)$tax_rate->deleted_at, 'created_at' => (int)$tax_rate->created_at, diff --git a/database/migrations/2020_07_08_065301_add_token_id_to_activity_table.php b/database/migrations/2020_07_08_065301_add_token_id_to_activity_table.php index b2e87940799b..ed2ff8940e6e 100644 --- a/database/migrations/2020_07_08_065301_add_token_id_to_activity_table.php +++ b/database/migrations/2020_07_08_065301_add_token_id_to_activity_table.php @@ -16,6 +16,10 @@ class AddTokenIdToActivityTable extends Migration Schema::table('activities', function (Blueprint $table) { $table->unsignedInteger('token_id')->nullable(); }); + + Schema::table('tax_rates', function (Blueprint $table) { + $table->boolean('is_deleted')->default(0); + }); } /** diff --git a/routes/api.php b/routes/api.php index 650d953553d1..86573edd40e4 100644 --- a/routes/api.php +++ b/routes/api.php @@ -117,6 +117,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a Route::post('group_settings/bulk', 'GroupSettingController@bulk'); Route::resource('tax_rates', 'TaxRateController');// name = (tasks. index / create / show / update / destroy / edit + Route::post('tax_rates/bulk', 'TaxRateController@bulk')->name('tax_rates.bulk'); Route::post('refresh', 'Auth\LoginController@refresh'); From 2e165c11cab1b1d183e08ea317063feec35da1e3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 09:31:07 +1000 Subject: [PATCH 3/8] Bulk actions for tokens --- routes/api.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes/api.php b/routes/api.php index 86573edd40e4..e1feb2bdeea4 100644 --- a/routes/api.php +++ b/routes/api.php @@ -106,6 +106,8 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a Route::resource('companies', 'CompanyController');// name = (companies. index / create / show / update / destroy / edit Route::resource('tokens', 'TokenController')->middleware('password_protected');// name = (tokens. index / create / show / update / destroy / edit + Route::post('tokens/bulk', 'TokenController@bulk')->name('tokens.bulk')->middleware('password_protected'); + Route::resource('company_gateways', 'CompanyGatewayController'); From 708422dd9b0e67cdace1c110aa1bee63bd6e049b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 12:54:56 +1000 Subject: [PATCH 4/8] Add hashed transformer for company tokens --- app/Http/Controllers/BaseController.php | 2 + app/Models/Company.php | 5 ++ .../CompanyTokenHashedTransformer.php | 56 +++++++++++++++++++ app/Transformers/CompanyTransformer.php | 11 +++- 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 app/Transformers/CompanyTokenHashedTransformer.php diff --git a/app/Http/Controllers/BaseController.php b/app/Http/Controllers/BaseController.php index 9522eccb5ae5..8d80a3bb3fa5 100644 --- a/app/Http/Controllers/BaseController.php +++ b/app/Http/Controllers/BaseController.php @@ -321,6 +321,8 @@ class BaseController extends Controller 'company.tasks', 'company.projects', 'company.designs', + 'company.webhooks', + 'company.tokens_hashed' ]; $mini_load = [ diff --git a/app/Models/Company.php b/app/Models/Company.php index 761bcaefe305..39e084fdcd84 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -374,6 +374,11 @@ class Company extends BaseModel return $this->hasMany(CompanyToken::class); } + public function tokens_hashed() + { + return $this->hasMany(CompanyToken::class); + } + public function company_users() { //return $this->hasMany(CompanyUser::class)->withTimestamps(); diff --git a/app/Transformers/CompanyTokenHashedTransformer.php b/app/Transformers/CompanyTokenHashedTransformer.php new file mode 100644 index 000000000000..46b755c08d4c --- /dev/null +++ b/app/Transformers/CompanyTokenHashedTransformer.php @@ -0,0 +1,56 @@ + $this->encodePrimaryKey($company_token->id), + 'user_id' => $this->encodePrimaryKey($company_token->user_id), + 'token' => substr($company_token->token, 0 ,10)."xxxxxxxxxxx", + 'name' => $company_token->name ?: '', + 'is_system' =>(bool)$company_token->is_system, + 'updated_at' => (int)$company_token->updated_at, + 'archived_at' => (int)$company_token->deleted_at, + 'created_at' => (int)$company_token->created_at, + 'is_deleted' => (bool)$company_token->is_deleted, + ]; + } +} diff --git a/app/Transformers/CompanyTransformer.php b/app/Transformers/CompanyTransformer.php index cf883facedca..6a31e1d61697 100644 --- a/app/Transformers/CompanyTransformer.php +++ b/app/Transformers/CompanyTransformer.php @@ -33,6 +33,7 @@ use App\Models\TaxRate; use App\Models\User; use App\Models\Webhook; use App\Transformers\CompanyLedgerTransformer; +use App\Transformers\CompanyTokenHashedTransformer; use App\Transformers\CompanyTokenTransformer; use App\Transformers\CreditTransformer; use App\Transformers\PaymentTermTransformer; @@ -82,7 +83,8 @@ class CompanyTransformer extends EntityTransformer 'tasks', 'ledger', 'webhooks', - 'tokens' + 'tokens', + 'tokens_hashed' ]; @@ -147,6 +149,13 @@ class CompanyTransformer extends EntityTransformer return $this->includeCollection($company->tokens, $transformer, CompanyToken::class); } + public function includeTokensHashed(Company $company) + { + $transformer = new CompanyTokenHashedTransformer($this->serializer); + + return $this->includeCollection($company->tokens, $transformer, CompanyToken::class); + } + public function includeWebhooks(Company $company) { $transformer = new WebhookTransformer($this->serializer); From 583a92d5bcb7fcea2005f1c49f73f4ac4ae1a1ae Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 13:35:28 +1000 Subject: [PATCH 5/8] Tweak payment dates in demo data --- app/Console/Commands/DemoMode.php | 4 ++++ app/Services/Invoice/AutoBillInvoice.php | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index e4eaf0cda946..32ab3529254d 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -361,6 +361,10 @@ class DemoMode extends Command $invoice = $invoice->service()->markPaid()->save(); + $invoice->payments->each(function ($payment){ + $payment->date = now()->addDays(rand(0,90)); + $payment->save(); + }); } //@todo this slow things down, but gives us PDFs of the invoices for inspection whilst debugging. event(new InvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars())); diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 397336a1855d..6b3922a254a2 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -50,11 +50,20 @@ class AutoBillInvoice extends AbstractService if(!$gateway_token) return $this->invoice; - $fee = $gateway_token->gateway->calcGatewayFee($this->invoice->balance); + if($this->invoice->partial){ + $fee = $gateway_token->gateway->calcGatewayFee($this->invoice->partial); + $amount = $this->invoice->partial + $fee; + } + else{ + $fee = $gateway_token->gateway->calcGatewayFee($this->invoice->balance); + $amount = $this->invoice->balance + $fee; + } if($fee > 0) $this->purgeStaleGatewayFees()->addFeeToInvoice($fee); + + $response = $gateway_token->gateway->driver($this->client)->tokenBilling($gateway_token, $amount, $this->invoice); //if response was successful, toggle the fee type_id to paid From 5dc0fcca0de2f3c1a3bbdf0541ad8b8361cffaf6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 14:46:16 +1000 Subject: [PATCH 6/8] Working on token billing --- .../Requests/Payment/UpdatePaymentRequest.php | 18 ++++++------- app/Models/CompanyGateway.php | 1 - .../Authorize/AuthorizeCreditCard.php | 26 ++++++++++++++++--- app/Services/Invoice/AutoBillInvoice.php | 7 ++--- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/app/Http/Requests/Payment/UpdatePaymentRequest.php b/app/Http/Requests/Payment/UpdatePaymentRequest.php index 9dca927e45fb..6149d3d142a8 100644 --- a/app/Http/Requests/Payment/UpdatePaymentRequest.php +++ b/app/Http/Requests/Payment/UpdatePaymentRequest.php @@ -72,17 +72,17 @@ class UpdatePaymentRequest extends Request unset($input['amount']); } - if (isset($input['type_id'])) { - unset($input['type_id']); - } + // if (isset($input['type_id'])) { + // unset($input['type_id']); + // } - if (isset($input['date'])) { - unset($input['date']); - } + // if (isset($input['date'])) { + // unset($input['date']); + // } - if (isset($input['transaction_reference'])) { - unset($input['transaction_reference']); - } + // if (isset($input['transaction_reference'])) { + // unset($input['transaction_reference']); + // } if (isset($input['number'])) { unset($input['number']); diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index 8221423bb961..3d667610e42c 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -254,7 +254,6 @@ class CompanyGateway extends BaseModel $fee += $pre_tax_fee * $this->fee_tax_rate2 / 100; } - return $fee; } diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index d19e6698786f..3d3c63358628 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -102,6 +102,18 @@ class AuthorizeCreditCard private function tokenBilling($cgt, $amount, $invoice) { + $data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($cgt->gateway_customer_reference, $cgt->token, $amounts); + + if($data['response'] != null && $data['response']->getMessages()->getResultCode() == "Ok") { + + $payment = $this->createPaymentRecord($data, $amount); + + $this->authorize->attachInvoices($payment, $invoice->hashed_id); + //up to here + } + else { + + } } @@ -115,10 +127,11 @@ class AuthorizeCreditCard return $this->processFailedResponse($data, $request); } - private function processSuccessfulResponse($data, $request) + private function createPaymentRecord($data, $amount) :?Payment { + $response = $data['response']; - //create a payment record and fire notifications and then return + //create a payment record $payment = PaymentFactory::create($this->authorize->client->company_id, $this->authorize->client->user_id); $payment->client_id = $this->authorize->client->id; @@ -129,11 +142,18 @@ class AuthorizeCreditCard $payment->currency_id = $this->authorize->client->getSetting('currency_id'); $payment->date = Carbon::now(); $payment->transaction_reference = $response->getTransactionResponse()->getTransId(); - $payment->amount = $request->input('amount_with_fee'); + $payment->amount = $amount; $payment->currency_id = $this->authorize->client->getSetting('currency_id'); $payment->client->getNextPaymentNumber($this->authorize->client); $payment->save(); + return $payment; + } + + private function processSuccessfulResponse($data, $request) + { + $payment = $this->createPaymentRecord($data, $request->input('amount_with_fee')); + $this->authorize->attachInvoices($payment, $request->hashed_ids); $payment->service()->updateInvoicePayment(); diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 6b3922a254a2..30eec874b51c 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -59,10 +59,11 @@ class AutoBillInvoice extends AbstractService $amount = $this->invoice->balance + $fee; } + /* Make sure we remove any stale fees*/ + $this->purgeStaleGatewayFees(); + if($fee > 0) - $this->purgeStaleGatewayFees()->addFeeToInvoice($fee); - - + $this->addFeeToInvoice($fee); $response = $gateway_token->gateway->driver($this->client)->tokenBilling($gateway_token, $amount, $this->invoice); From a9f2f35d557fc4c9f62841d592bfa0453f7f101e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 14:56:07 +1000 Subject: [PATCH 7/8] Working on token billing ' --- .../Authorize/AuthorizeCreditCard.php | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 3d3c63358628..c7767f45e273 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -109,7 +109,22 @@ class AuthorizeCreditCard $payment = $this->createPaymentRecord($data, $amount); $this->authorize->attachInvoices($payment, $invoice->hashed_id); - //up to here + + event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); + + $vars = [ + 'hashed_ids' => $invoice->hashed_id, + 'amount' => $amount + ]; + + $logger_message = [ + 'server_response' => $response->getTransactionResponse()->getTransId(), + 'data' => $this->formatGatewayResponse($data, $vars) + ]; + + SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); + + } else { @@ -160,9 +175,14 @@ class AuthorizeCreditCard event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); + $vars = [ + 'hashed_ids' => $request->input('hashed_ids'), + 'amount' => $request->input('amount') + ]; + $logger_message = [ 'server_response' => $response->getTransactionResponse()->getTransId(), - 'data' => $this->formatGatewayResponse($data, $request) + 'data' => $this->formatGatewayResponse($data, $vars) ]; SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_SUCCESS, SystemLog::TYPE_AUTHORIZE, $this->authorize->client); @@ -176,17 +196,17 @@ class AuthorizeCreditCard info(print_r($data,1)); } - private function formatGatewayResponse($data, $request) + private function formatGatewayResponse($data, $vars) { $response = $data['response']; return [ 'transaction_reference' => $response->getTransactionResponse()->getTransId(), - 'amount' => $request->input('amount'), + 'amount' => $vars['amount'], 'auth_code' => $response->getTransactionResponse()->getAuthCode(), 'code' => $response->getTransactionResponse()->getMessages()[0]->getCode(), 'description' => $response->getTransactionResponse()->getMessages()[0]->getDescription(), - 'invoices' => $request->hashed_ids, + 'invoices' => $vars['hashed_ids'], ]; } From 5af23a40723511e464c6a395810b76924466f86e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Jul 2020 20:12:29 +1000 Subject: [PATCH 8/8] changes for Demo --- app/Console/Commands/DemoMode.php | 1 + app/DataMapper/CompanySettings.php | 2 +- database/factories/CompanyFactory.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/DemoMode.php b/app/Console/Commands/DemoMode.php index 32ab3529254d..c5008f5471ab 100644 --- a/app/Console/Commands/DemoMode.php +++ b/app/Console/Commands/DemoMode.php @@ -76,6 +76,7 @@ class DemoMode extends Command $this->info("Seeding Random Data"); $this->createSmallAccount(); + } diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 478798134ebe..fe523721f150 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -33,7 +33,7 @@ class CompanySettings extends BaseSettings public $enable_client_portal_dashboard = true; //implemented public $signature_on_pdf = false; public $document_email_attachment = false; - //public $send_portal_password = false; + //public $send_portal_password = false; public $portal_design_id = '1'; diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php index f90e418dd0ef..7f60c849b5cc 100644 --- a/database/factories/CompanyFactory.php +++ b/database/factories/CompanyFactory.php @@ -11,7 +11,7 @@ $factory->define(App\Models\Company::class, function (Faker $faker) { 'db' => config('database.default'), 'settings' => CompanySettings::defaults(), 'custom_fields' => (object) [ - 'invoice1' => 'Custom Date|date', + //'invoice1' => 'Custom Date|date', // 'invoice2' => '2|switch', // 'invoice3' => '3|', // 'invoice4' => '4',