mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on white label licensing
This commit is contained in:
parent
39eb75c440
commit
a32a9a0015
@ -11,22 +11,23 @@
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Utils\Ninja;
|
||||
use App\Models\Client;
|
||||
use App\Models\Invoice;
|
||||
use Livewire\Component;
|
||||
use App\Libraries\MultiDB;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Subscription;
|
||||
use App\Models\ClientContact;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Jobs\Mail\NinjaMailerJob;
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Jobs\Mail\NinjaMailerObject;
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Mail\ContactPasswordlessLogin;
|
||||
use App\Models\Client;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Subscription;
|
||||
use App\Repositories\ClientContactRepository;
|
||||
use App\Repositories\ClientRepository;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
use App\Mail\ContactPasswordlessLogin;
|
||||
use App\Repositories\ClientRepository;
|
||||
use App\Repositories\ClientContactRepository;
|
||||
|
||||
class BillingPortalPurchase extends Component
|
||||
{
|
||||
@ -168,7 +169,7 @@ class BillingPortalPurchase extends Component
|
||||
/**
|
||||
* Instance of company.
|
||||
*
|
||||
* @var Company
|
||||
* @var \App\Models\Company
|
||||
*/
|
||||
public $company;
|
||||
|
||||
@ -396,12 +397,19 @@ class BillingPortalPurchase extends Component
|
||||
->adjustInventory()
|
||||
->save();
|
||||
|
||||
$context = 'purchase';
|
||||
|
||||
// if(Ninja::isHosted() && $this->subscription->service()->recurring_products()->first()->product_key == 'whitelabel') {
|
||||
if($this->subscription->service()->recurring_products()->first()?->product_key == 'whitelabel') {
|
||||
$context = 'whitelabel';
|
||||
}
|
||||
|
||||
Cache::put($this->hash, [
|
||||
'subscription_id' => $this->subscription->hashed_id,
|
||||
'email' => $this->email ?? $this->contact->email,
|
||||
'client_id' => $this->contact->client->hashed_id,
|
||||
'invoice_id' => $this->invoice->hashed_id,
|
||||
'context' => 'purchase',
|
||||
'context' => $context,
|
||||
'campaign' => $this->campaign,
|
||||
], now()->addMinutes(60));
|
||||
|
||||
|
@ -169,9 +169,24 @@ class SubscriptionService
|
||||
//send license to the user.
|
||||
$invoice = $payment_hash->fee_invoice;
|
||||
$license_key = Str::uuid()->toString();
|
||||
$invoice->public_notes = $license_key;
|
||||
$invoice->save();
|
||||
$invoice->footer = ctrans('texts.white_label_body',['license_key' => $license_key]);
|
||||
|
||||
$recurring_invoice = $this->convertInvoiceToRecurring($payment_hash->payment->client_id);
|
||||
|
||||
$recurring_invoice_repo = new RecurringInvoiceRepository();
|
||||
$recurring_invoice = $recurring_invoice_repo->save([], $recurring_invoice);
|
||||
$recurring_invoice->auto_bill = $this->subscription->auto_bill;
|
||||
|
||||
/* Start the recurring service */
|
||||
$recurring_invoice->service()
|
||||
->start()
|
||||
->save();
|
||||
|
||||
//update the invoice and attach to the recurring invoice!!!!!
|
||||
$invoice->recurring_id = $recurring_invoice->id;
|
||||
$invoice->is_proforma = false;
|
||||
$invoice->service()->touchPdf();
|
||||
$invoice->save();
|
||||
|
||||
$contact = $invoice->client->contacts()->whereNotNull('email')->first();
|
||||
|
||||
@ -183,16 +198,20 @@ class SubscriptionService
|
||||
$license->is_claimed = 1;
|
||||
$license->transaction_reference = $payment_hash?->payment?->transaction_reference ?: ' ';
|
||||
$license->product_id = self::WHITE_LABEL;
|
||||
$license->recurring_invoice_id = $recurring_invoice->id;
|
||||
|
||||
$license->save();
|
||||
|
||||
$invitation = $invoice->invitations()->first();
|
||||
|
||||
$email_object = new EmailObject;
|
||||
$email_object->to = $contact->email;
|
||||
$email_object->to = [$contact->email];
|
||||
$email_object->subject = ctrans('texts.white_label_link') . " " .ctrans('texts.payment_subject');
|
||||
$email_object->body = ctrans('texts.white_label_body',['license_key' => $license_key]);
|
||||
$email_object->client_id = $invoice->client_id;
|
||||
$email_object->client_contact_id = $contact->id;
|
||||
$email_object->invitation_key = $invoice->invitations()->first()->invitation_key;
|
||||
$email_object->invitation_key = $invitation->invitation_key;
|
||||
$email_object->invitation_id = $invitation->id;
|
||||
$email_object->entity_id = $invoice->id;
|
||||
$email_object->entity_class = Invoice::class;
|
||||
$email_object->user_id = $invoice->user_id;
|
||||
|
@ -5014,7 +5014,7 @@ $LANG = array(
|
||||
'no_assigned_tasks' => 'No billable tasks for this project',
|
||||
'authorization_failure' => 'Insufficient permissions to perform this action',
|
||||
'authorization_sms_failure' => 'Please verify your account to send emails.',
|
||||
'white_label_body' => 'Thank you for purchasing a white label license. Your license key is :license_key.',
|
||||
'white_label_body' => 'Thank you for purchasing a white label license. \n\n Your license key is: \n\n :license_key',
|
||||
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user