Peppol
This commit is contained in:
parent
8e1feeff69
commit
e14f9286a2
|
|
@ -469,10 +469,14 @@ class BillingPortalPurchase extends Component
|
||||||
|
|
||||||
$context = 'purchase';
|
$context = 'purchase';
|
||||||
|
|
||||||
if (Ninja::isHosted() && $this->subscription->service()->recurring_products()->first()?->product_key == 'whitelabel') {
|
if (config('ninja.ninja_default_company_id') == $this->subscription->company_id && $this->subscription->service()->recurring_products()->first()?->product_key == 'whitelabel') {
|
||||||
$context = 'whitelabel';
|
$context = 'whitelabel';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config('ninja.ninja_default_company_id') == $this->subscription->company_id && in_array($this->subscription->service()->products()->first()?->product_key,['peppol_500','peppol_1000','selfhost_peppol_500','selfhost_peppol_1000'])) {
|
||||||
|
$context = $this->subscription->service()->products()->first()?->product_key;
|
||||||
|
}
|
||||||
|
|
||||||
Cache::put($this->hash, [
|
Cache::put($this->hash, [
|
||||||
'subscription_id' => $this->subscription->hashed_id,
|
'subscription_id' => $this->subscription->hashed_id,
|
||||||
'email' => $this->email ?? $this->contact->email,
|
'email' => $this->email ?? $this->contact->email,
|
||||||
|
|
|
||||||
|
|
@ -52,41 +52,15 @@ class StripeConnectFailed extends Mailable
|
||||||
{
|
{
|
||||||
|
|
||||||
return new Content(
|
return new Content(
|
||||||
view: 'email.admin.stripe_connect_failed',
|
view: 'email.einvoice.peppol_purchase_allocation_failed',
|
||||||
text: 'email.admin.stripe_connect_failed_text',
|
text: 'email.einvoice.peppol_purchase_allocation_failed_text',
|
||||||
with: [
|
with: [
|
||||||
'text_body' => $this->textBody(), //@todo this is a bit hacky here.
|
|
||||||
'body' => $this->htmlBody(),
|
|
||||||
'title' => 'Connect your Stripe account',
|
|
||||||
'settings' => $this->company->settings,
|
|
||||||
'logo' => $this->company->present()->logo(),
|
|
||||||
'signature' => '',
|
|
||||||
'company' => $this->company,
|
|
||||||
'greeting' => '',
|
|
||||||
'links' => [],
|
|
||||||
'url' => 'https://www.loom.com/share/a3dc3131cc924e14a34634d5d48065c8?sid=b1971aa2-9deb-4339-8ebd-53f9947ef633',
|
|
||||||
'button' => "texts.view"
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function textBody()
|
|
||||||
{
|
|
||||||
return "
|
|
||||||
We note you are yet to connect your Stripe account to Invoice Ninja. Please log in to Invoice Ninja and connect your Stripe account.\n\n
|
|
||||||
Once logged in you can use the following resource to connect your Stripe account: \n\n
|
|
||||||
";
|
|
||||||
}
|
|
||||||
|
|
||||||
private function htmlBody()
|
|
||||||
{
|
|
||||||
return "
|
|
||||||
We note you are yet to connect your Stripe account to Invoice Ninja. Please log in to Invoice Ninja and connect your Stripe account.<br><br>
|
|
||||||
|
|
||||||
Once logged in you can use the following resource to connect your Stripe account: <br><br>
|
|
||||||
|
|
||||||
";
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Get the attachments for the message.
|
* Get the attachments for the message.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,13 @@ class SubscriptionService
|
||||||
|
|
||||||
public const WHITE_LABEL = 4316;
|
public const WHITE_LABEL = 4316;
|
||||||
|
|
||||||
|
private array $peppol_keys = [
|
||||||
|
'peppol_500',
|
||||||
|
'peppol_1000',
|
||||||
|
'selfhost_peppol_500',
|
||||||
|
'selfhost_peppol_1000',
|
||||||
|
];
|
||||||
|
|
||||||
private float $credit_payments = 0;
|
private float $credit_payments = 0;
|
||||||
|
|
||||||
public function __construct(Subscription $subscription)
|
public function __construct(Subscription $subscription)
|
||||||
|
|
@ -86,6 +93,9 @@ class SubscriptionService
|
||||||
return $this->handleWhiteLabelPurchase($payment_hash);
|
return $this->handleWhiteLabelPurchase($payment_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (in_array($payment_hash->data->billing_context->context, $this->peppol_keys)) {
|
||||||
|
return $this->handlePeppolPurchase($payment_hash);
|
||||||
|
}
|
||||||
|
|
||||||
// if we have a recurring product - then generate a recurring invoice
|
// if we have a recurring product - then generate a recurring invoice
|
||||||
if (strlen($this->subscription->recurring_product_ids ?? '') >= 1) {
|
if (strlen($this->subscription->recurring_product_ids ?? '') >= 1) {
|
||||||
|
|
@ -168,6 +178,15 @@ class SubscriptionService
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function handlePeppolPurchase(PaymentHash $payment_hash)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (class_exists(\Modules\Admin\Jobs\Account\PeppolPurchase::class)) {
|
||||||
|
(new \Modules\Admin\Jobs\Account\PeppolPurchase($payment_hash))->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function handleWhiteLabelPurchase(PaymentHash $payment_hash): bool
|
private function handleWhiteLabelPurchase(PaymentHash $payment_hash): bool
|
||||||
{
|
{
|
||||||
//send license to the user.
|
//send license to the user.
|
||||||
|
|
@ -189,7 +208,6 @@ class SubscriptionService
|
||||||
//update the invoice and attach to the recurring invoice!!!!!
|
//update the invoice and attach to the recurring invoice!!!!!
|
||||||
$invoice->recurring_id = $recurring_invoice->id;
|
$invoice->recurring_id = $recurring_invoice->id;
|
||||||
$invoice->is_proforma = false;
|
$invoice->is_proforma = false;
|
||||||
// $invoice->service()->deletePdf();
|
|
||||||
$invoice->save();
|
$invoice->save();
|
||||||
|
|
||||||
$contact = $invoice->client->contacts()->whereNotNull('email')->first();
|
$contact = $invoice->client->contacts()->whereNotNull('email')->first();
|
||||||
|
|
@ -1176,9 +1194,9 @@ class SubscriptionService
|
||||||
$keys = $this->transformKeys(explode(",", $this->subscription->product_ids));
|
$keys = $this->transformKeys(explode(",", $this->subscription->product_ids));
|
||||||
|
|
||||||
if (is_array($keys)) {
|
if (is_array($keys)) {
|
||||||
return Product::query()->whereIn('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->whereIn('id', $keys)->get();
|
||||||
} else {
|
} else {
|
||||||
return Product::query()->where('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->where('id', $keys)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1196,9 +1214,9 @@ class SubscriptionService
|
||||||
$keys = $this->transformKeys(explode(",", $this->subscription->recurring_product_ids));
|
$keys = $this->transformKeys(explode(",", $this->subscription->recurring_product_ids));
|
||||||
|
|
||||||
if (is_array($keys)) {
|
if (is_array($keys)) {
|
||||||
return Product::query()->whereIn('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->whereIn('id', $keys)->get();
|
||||||
} else {
|
} else {
|
||||||
return Product::query()->where('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->where('id', $keys)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1217,9 +1235,9 @@ class SubscriptionService
|
||||||
$keys = $this->transformKeys(explode(",", $this->subscription->optional_product_ids));
|
$keys = $this->transformKeys(explode(",", $this->subscription->optional_product_ids));
|
||||||
|
|
||||||
if (is_array($keys)) {
|
if (is_array($keys)) {
|
||||||
return Product::query()->whereIn('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->whereIn('id', $keys)->get();
|
||||||
} else {
|
} else {
|
||||||
return Product::query()->where('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->where('id', $keys)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1237,9 +1255,9 @@ class SubscriptionService
|
||||||
$keys = $this->transformKeys(explode(",", $this->subscription->optional_recurring_product_ids));
|
$keys = $this->transformKeys(explode(",", $this->subscription->optional_recurring_product_ids));
|
||||||
|
|
||||||
if (is_array($keys)) {
|
if (is_array($keys)) {
|
||||||
return Product::query()->whereIn('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->whereIn('id', $keys)->get();
|
||||||
} else {
|
} else {
|
||||||
return Product::query()->where('id', $keys)->get();
|
return Product::query()->where('company_id', $this->subscription->company_id)->where('id', $keys)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue