diff --git a/VERSION.txt b/VERSION.txt
index 764d664a1d8d..65c5e6f31326 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-5.0.54
\ No newline at end of file
+5.0.55
\ No newline at end of file
diff --git a/app/Http/Controllers/MigrationController.php b/app/Http/Controllers/MigrationController.php
index 45c12105445b..bbc361c41321 100644
--- a/app/Http/Controllers/MigrationController.php
+++ b/app/Http/Controllers/MigrationController.php
@@ -218,6 +218,8 @@ class MigrationController extends BaseController
*/
public function startMigration(Request $request)
{
+ nlog("Starting Migration");
+
$companies = json_decode($request->companies);
if (app()->environment() === 'local') {
@@ -290,6 +292,9 @@ class MigrationController extends BaseController
// If there's no existing company migrate just normally.
if ($checks['existing_company'] == false) {
+
+ nlog("creating fresh company");
+
$account = auth()->user()->account;
$fresh_company = (new ImportMigrations())->getCompany($account);
@@ -325,11 +330,13 @@ class MigrationController extends BaseController
);
if (app()->environment() == 'testing') {
+ nlog("environment is testing = bailing out now");
return;
}
try {
// StartMigration::dispatch(base_path("storage/app/public/$migration_file"), $user, $fresh_company)->delay(now()->addSeconds(5));
+ nlog("starting migration job");
nlog($migration_file);
StartMigration::dispatch($migration_file, $user, $fresh_company);
} catch (\Exception $e) {
diff --git a/app/Jobs/Util/StartMigration.php b/app/Jobs/Util/StartMigration.php
index bfc5f3470199..84509b6a500a 100644
--- a/app/Jobs/Util/StartMigration.php
+++ b/app/Jobs/Util/StartMigration.php
@@ -73,6 +73,8 @@ class StartMigration implements ShouldQueue
*/
public function handle()
{
+ nlog("Inside Migration Job");
+
set_time_limit(0);
MultiDB::setDb($this->company->db);
diff --git a/app/Listeners/Payment/PaymentEmailedActivity.php b/app/Listeners/Payment/PaymentEmailedActivity.php
index f3d39cdb88b8..0ddfeacb880d 100644
--- a/app/Listeners/Payment/PaymentEmailedActivity.php
+++ b/app/Listeners/Payment/PaymentEmailedActivity.php
@@ -40,6 +40,5 @@ class PaymentEmailedActivity implements ShouldQueue
$payment = $event->payment;
- nlog("i succeeded in emailing payment {$payment->number}");
}
}
diff --git a/app/Mail/Engine/PaymentEmailEngine.php b/app/Mail/Engine/PaymentEmailEngine.php
index 7021ecb097eb..218a92995551 100644
--- a/app/Mail/Engine/PaymentEmailEngine.php
+++ b/app/Mail/Engine/PaymentEmailEngine.php
@@ -55,39 +55,6 @@ class PaymentEmailEngine extends BaseEmailEngine
$body_template = EmailTemplateDefaults::getDefaultTemplate('email_template_payment', $this->client->locale());
}
- /* Use default translations if a custom message has not been set*/
- if (iconv_strlen($body_template) == 0) {
-
- if ($payment->invoices()->exists())
- {
- $invoice_texts = ctrans('texts.invoice_number_short');
-
- foreach ($this->payment->invoices as $invoice) {
- $invoice_texts .= $invoice->number.',';
- }
-
- $invoice_texts = substr($invoice_texts, 0, -1);
-
- $body_template = trans(
- 'texts.payment_message_extended',
- ['amount' => $payment->amount, 'company' => $payment->company->present()->name(), 'invoice' => $invoice_texts],
- null,
- $this->client->locale()
- );
- }
- else
- {
-
- $body_template = trans(
- 'texts.payment_message',
- ['amount' => $payment->amount, 'company' => $payment->company->present()->name()],
- null,
- $this->client->locale()
- );
- }
-
- }
-
if (is_array($this->template_data) && array_key_exists('subject', $this->template_data) && strlen($this->template_data['subject']) > 0) {
$subject_template = $this->template_data['subject'];
} elseif (strlen($this->client->getSetting('email_subject_payment')) > 0) {
@@ -96,15 +63,6 @@ class PaymentEmailEngine extends BaseEmailEngine
$subject_template = EmailTemplateDefaults::getDefaultTemplate('email_subject_payment', $this->client->locale());
}
- if (iconv_strlen($subject_template) == 0) {
- $subject_template = trans(
- 'texts.payment_subject',
- ['number' => $payment->number, 'company' => $payment->company->present()->name()],
- null,
- $this->client->locale()
- );
- }
-
$this->setTemplate($this->client->getSetting('email_style'))
->setContact($this->contact)
->setVariables($this->makeValues())
@@ -221,7 +179,7 @@ class PaymentEmailEngine extends BaseEmailEngine
private function formatInvoices()
{
- $invoice_list = '';
+ $invoice_list = '
';
foreach ($this->payment->invoices as $invoice) {
$invoice_list .= ctrans('texts.invoice_number_short') . " {$invoice->number} - " . Number::formatMoney($invoice->pivot->amount, $this->client) . "
";
diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php
index 10569e081c9f..86c9f5afd45e 100644
--- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php
+++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php
@@ -140,7 +140,6 @@ class AuthorizeCreditCard
$response = $data['response'];
if ($response != null && $response->getMessages()->getResultCode() == 'Ok') {
- $this->authorize->confirmGatewayFee($request);
return $this->processSuccessfulResponse($data, $request);
}
diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php
index 13efcf6d6d74..5e86c125ad0d 100644
--- a/app/PaymentDrivers/AuthorizePaymentDriver.php
+++ b/app/PaymentDrivers/AuthorizePaymentDriver.php
@@ -103,9 +103,7 @@ class AuthorizePaymentDriver extends BaseDriver
}
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
- {
- $this->setPaymentHash($payment_hash);
-
+ {
$this->setPaymentMethod($cgt->gateway_type_id);
return $this->payment_method->tokenBilling($cgt, $payment_hash);
diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php
index 16f2c3442cb5..ff1807f71965 100644
--- a/app/PaymentDrivers/BaseDriver.php
+++ b/app/PaymentDrivers/BaseDriver.php
@@ -202,14 +202,15 @@ class BaseDriver extends AbstractPaymentDriver
*/
public function createPayment($data, $status = Payment::STATUS_COMPLETED): Payment
{
+ $this->confirmGatewayFee();
+
$payment = PaymentFactory::create($this->client->company->id, $this->client->user->id);
$payment->client_id = $this->client->id;
$payment->company_gateway_id = $this->company_gateway->id;
$payment->status_id = $status;
$payment->currency_id = $this->client->getSetting('currency_id');
$payment->date = Carbon::now();
-
- //$payment->gateway_type_id = $data['gateway_type_id'];
+ $payment->gateway_type_id = $data['gateway_type_id'];
$client_contact = $this->getContact();
$client_contact_id = $client_contact ? $client_contact->id : null;
@@ -245,19 +246,14 @@ class BaseDriver extends AbstractPaymentDriver
* @param PaymentResponseRequest $request The incoming payment request
* @return void Success/Failure
*/
- public function confirmGatewayFee(PaymentResponseRequest $request) :void
+ public function confirmGatewayFee() :void
{
- /*Payment meta data*/
- $payment_hash = $request->getPaymentHash();
/*Payment invoices*/
- $payment_invoices = $payment_hash->invoices();
+ $payment_invoices = $this->payment_hash->invoices();
/*Fee charged at gateway*/
- $fee_total = $payment_hash->fee_total;
-
- // Sum of invoice amounts
- // $invoice_totals = array_sum(array_column($payment_invoices,'amount'));
+ $fee_total = $this->payment_hash->fee_total;
/*Hydrate invoices*/
$invoices = Invoice::whereIn('id', $this->transformKeys(array_column($payment_invoices, 'invoice_id')))->get();
diff --git a/app/PaymentDrivers/CheckoutCom/CreditCard.php b/app/PaymentDrivers/CheckoutCom/CreditCard.php
index d9855594d12b..aa35d5ad3dde 100644
--- a/app/PaymentDrivers/CheckoutCom/CreditCard.php
+++ b/app/PaymentDrivers/CheckoutCom/CreditCard.php
@@ -142,7 +142,6 @@ class CreditCard
$response = $this->checkout->gateway->payments()->request($payment);
if ($response->status == 'Authorized') {
- $this->checkout->confirmGatewayFee($request);
return $this->processSuccessfulPayment($response);
}
diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php
index 48f59eb382cc..d9b007b02a08 100644
--- a/app/PaymentDrivers/Stripe/CreditCard.php
+++ b/app/PaymentDrivers/Stripe/CreditCard.php
@@ -95,7 +95,6 @@ class CreditCard
$server_response = $this->stripe->payment_hash->data->server_response;
if ($server_response->status == 'succeeded') {
- $this->stripe->confirmGatewayFee($request);
$this->stripe->logSuccessfulGatewayResponse(['response' => json_decode($request->gateway_response), 'data' => $this->stripe->payment_hash], SystemLog::TYPE_STRIPE);
diff --git a/app/PaymentDrivers/StripePaymentDriver.php b/app/PaymentDrivers/StripePaymentDriver.php
index 71a920631077..c84c59272a58 100644
--- a/app/PaymentDrivers/StripePaymentDriver.php
+++ b/app/PaymentDrivers/StripePaymentDriver.php
@@ -322,8 +322,6 @@ class StripePaymentDriver extends BaseDriver
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)
{
- $this->setPaymentHash($payment_hash);
-
return (new Charge($this))->tokenBilling($cgt, $payment_hash);
}
diff --git a/app/Services/Client/PaymentMethod.php b/app/Services/Client/PaymentMethod.php
index 59253d0883b4..811c04c9186e 100644
--- a/app/Services/Client/PaymentMethod.php
+++ b/app/Services/Client/PaymentMethod.php
@@ -141,7 +141,6 @@ class PaymentMethod
if ($this->validGatewayForAmount($gateway->fees_and_limits->{$type}, $this->amount) && $gateway->fees_and_limits->{$type}->is_enabled) {
if($type == GatewayType::BANK_TRANSFER);
- nlog($gateway->fees_and_limits);
$this->payment_methods[] = [$gateway->id => $type];
}
diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php
index 7641f6caad30..1718c5a7e243 100644
--- a/app/Services/Invoice/AutoBillInvoice.php
+++ b/app/Services/Invoice/AutoBillInvoice.php
@@ -41,9 +41,8 @@ class AutoBillInvoice extends AbstractService
public function run()
{
/* Is the invoice payable? */
- if (! $this->invoice->isPayable()) {
+ if (! $this->invoice->isPayable())
return $this->invoice;
- }
/* Mark the invoice as sent */
$this->invoice = $this->invoice->service()->markSent()->save();
@@ -67,6 +66,7 @@ class AutoBillInvoice extends AbstractService
info("balance remains to be paid!!");
+ /* Retrieve the Client Gateway Token */
$gateway_token = $this->getGateway($amount);
/* Bail out if no payment methods available */
@@ -74,7 +74,10 @@ class AutoBillInvoice extends AbstractService
return $this->invoice;
/* $gateway fee */
- $fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes);
+ //$fee = $gateway_token->gateway->calcGatewayFee($amount, $gateway_token->gateway_type_id, $this->invoice->uses_inclusive_taxes);
+ $this->invoice = $this->invoice->service()->addGatewayFee($gateway_token->gateway, $gateway_token->gateway_type_id, $amount)->save();
+
+ $fee = $this->invoice->amount - $amount;
/* Build payment hash */
$payment_hash = PaymentHash::create([
@@ -86,6 +89,7 @@ class AutoBillInvoice extends AbstractService
$payment = $gateway_token->gateway
->driver($this->client)
+ ->setPaymentHash($payment_hash)
->tokenBilling($gateway_token, $payment_hash);
return $this->invoice;
diff --git a/config/ninja.php b/config/ninja.php
index 910753f54ea5..283c361c0a58 100644
--- a/config/ninja.php
+++ b/config/ninja.php
@@ -13,7 +13,7 @@ return [
'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', ''),
- 'app_version' => '5.0.54',
+ 'app_version' => '5.0.55',
'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', false),