mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 15:57:33 -04:00 
			
		
		
		
	
						commit
						38c238cbba
					
				| @ -1 +1 @@ | ||||
| 5.0.54 | ||||
| 5.0.55 | ||||
| @ -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) { | ||||
|  | ||||
| @ -73,6 +73,8 @@ class StartMigration implements ShouldQueue | ||||
|      */ | ||||
|     public function handle() | ||||
|     { | ||||
|         nlog("Inside Migration Job"); | ||||
|          | ||||
|         set_time_limit(0); | ||||
| 
 | ||||
|         MultiDB::setDb($this->company->db); | ||||
|  | ||||
| @ -40,6 +40,5 @@ class PaymentEmailedActivity implements ShouldQueue | ||||
| 
 | ||||
|         $payment = $event->payment; | ||||
|          | ||||
|         nlog("i succeeded in emailing payment {$payment->number}"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -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 = '<br><br>'; | ||||
| 
 | ||||
|         foreach ($this->payment->invoices as $invoice) { | ||||
|             $invoice_list .= ctrans('texts.invoice_number_short') . " {$invoice->number} - " . Number::formatMoney($invoice->pivot->amount, $this->client) . "<br>"; | ||||
|  | ||||
| @ -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); | ||||
|         } | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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(); | ||||
|  | ||||
| @ -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); | ||||
|             } | ||||
|  | ||||
| @ -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); | ||||
| 
 | ||||
|  | ||||
| @ -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); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -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]; | ||||
|                     } | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user