mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 17:04:45 -04:00
Merge pull request #5728 from turbo124/v5-develop
Download Backup Mailable
This commit is contained in:
commit
b32b1c9c3e
@ -33,9 +33,6 @@ class ClientFactory
|
||||
$client->client_hash = Str::random(40);
|
||||
$client->settings = ClientSettings::defaults();
|
||||
|
||||
// $client_contact = ClientContactFactory::create($company_id, $user_id);
|
||||
// $client->contacts->add($client_contact);
|
||||
|
||||
return $client;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
@ -9,7 +18,6 @@ use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class DownloadBackup extends Mailable
|
||||
{
|
||||
// use Queueable, SerializesModels;
|
||||
|
||||
public $file_path;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
namespace App\PaymentDrivers\Stripe;
|
||||
|
||||
use App\Factory\ClientContactFactory;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Factory\ClientGatewayTokenFactory;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientGatewayToken;
|
||||
@ -55,31 +56,37 @@ class ImportCustomers
|
||||
|
||||
private function addCustomer(Customer $customer)
|
||||
{
|
||||
|
||||
$account = $this->stripe->company_gateway->company->account;
|
||||
|
||||
$account = $this->company_gateway->company->account;
|
||||
|
||||
$existing_customer = $this->company_gateway
|
||||
$existing_customer = $this->stripe
|
||||
->company_gateway
|
||||
->client_gateway_tokens()
|
||||
->where('gateway_customer_reference', $customer->id)
|
||||
->exists();
|
||||
|
||||
|
||||
if($existing_customer)
|
||||
return
|
||||
return;
|
||||
|
||||
$client = ClientFactory::create($this->company_gateway->company_id, $this->company_gateway->user_id);
|
||||
$client->address1 = $customer->address->line1 ?: '';
|
||||
$client->address2 = $customer->address->line2 ?: '';
|
||||
$client->city = $customer->address->city ?: '';
|
||||
$client->state = $customer->address->state ?: '';
|
||||
$client = ClientFactory::create($this->stripe->company_gateway->company_id, $this->stripe->company_gateway->user_id);
|
||||
|
||||
if($customer->address->country){
|
||||
if(property_exists($customer, 'address'))
|
||||
{
|
||||
$client->address1 = property_exists($customer->address, 'line1') ? $customer->address->line1 : '';
|
||||
$client->address2 = property_exists($customer->address, 'line2') ? $customer->address->line2 : '';
|
||||
$client->city = property_exists($customer->address, 'city') ? $customer->address->city : '';
|
||||
$client->state = property_exists($customer->address, 'state') ? $customer->address->state : '';
|
||||
$client->phone = property_exists($customer->address, 'phone') ? $customer->phone : '';
|
||||
|
||||
$country = Country::where('iso_3166_2', $customer->address->country)->first()
|
||||
if(property_exists($customer->address, 'country')){
|
||||
|
||||
if($country)
|
||||
$client->country_id = $country->id;
|
||||
$country = Country::where('iso_3166_2', $customer->address->country)->first();
|
||||
|
||||
if($country)
|
||||
$client->country_id = $country->id;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($customer->currency) {
|
||||
@ -96,12 +103,11 @@ class ImportCustomers
|
||||
|
||||
}
|
||||
|
||||
$client->phone = $customer->phone ?: '';
|
||||
$client->name = $customer->name ?: '';
|
||||
$client->name = property_exists($customer, 'name') ? $customer->name : '';
|
||||
|
||||
if(!$account->isPaidHostedClient() && Client::where('company_id', $this->company_gateway->company_id)->count() <= config('ninja.quotas.free.clients')){
|
||||
if(!$account->isPaidHostedClient() && Client::where('company_id', $this->stripe->company_gateway->company_id)->count() <= config('ninja.quotas.free.clients')){
|
||||
|
||||
$client->save()
|
||||
$client->save();
|
||||
|
||||
$contact = ClientContactFactory::create($client->company_id, $client->user_id);
|
||||
$contact->client_id = $client->id;
|
||||
|
@ -104,7 +104,7 @@ class UpdatePaymentMethods
|
||||
$cgt->token = $bank_account->id;
|
||||
$cgt->gateway_customer_reference = $token->gateway_customer_reference;
|
||||
$cgt->company_gateway_id = $token->company_gateway_id;
|
||||
$cgt->gateway_type_id = GatewayType::BANK_TRANSFER
|
||||
$cgt->gateway_type_id = GatewayType::BANK_TRANSFER;
|
||||
$cgt->meta = new \stdClass;
|
||||
$cgt->routing_number = $bank_account->routing_number;
|
||||
$cgt->save();
|
||||
|
Loading…
x
Reference in New Issue
Block a user