Improve subscription service

This commit is contained in:
David Bomba 2021-12-01 16:22:22 +11:00
parent 445ba94201
commit 0c267131c4
3 changed files with 335 additions and 317 deletions

View File

@ -92,7 +92,7 @@ class SubscriptionService
'client' => $recurring_invoice->client->hashed_id,
'subscription' => $this->subscription->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'account_key' => auth('contact')->user()->account->account_key,
'account_key' => $recurring_invoice->client->custom_value2,
];
$response = $this->triggerWebhook($context);
@ -109,7 +109,7 @@ class SubscriptionService
'invoice' => $this->encodePrimaryKey($payment_hash->fee_invoice_id),
'client' => $invoice->client->hashed_id,
'subscription' => $this->subscription->hashed_id,
'account_key' => auth('contact')->user()->account->account_key,
'account_key' => $invoice->client->custom_value2,
];
//execute any webhooks
@ -129,6 +129,7 @@ class SubscriptionService
'contact' => $contact->hashed_id,
'contact_email' => $contact->email,
'client' => $contact->client->hashed_id,
'account_key' => $contact->client->custom_value2,
];
$response = $this->triggerWebhook($context);
@ -179,6 +180,7 @@ class SubscriptionService
'recurring_invoice' => $recurring_invoice->hashed_id,
'client' => $recurring_invoice->client->hashed_id,
'subscription' => $this->subscription->hashed_id,
'account_key' => $recurring_invoice->client->custom_value2,
];
//execute any webhooks
@ -451,6 +453,7 @@ class SubscriptionService
'client' => $new_recurring_invoice->client->hashed_id,
'subscription' => $target_subscription->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'account_key' => $new_recurring_invoice->client->custom_value2,
];
$response = $this->triggerWebhook($context);
@ -571,6 +574,7 @@ class SubscriptionService
'client' => $recurring_invoice->client->hashed_id,
'subscription' => $this->subscription->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'account_key' => $recurring_invoice->client->custom_value2,
];
@ -767,8 +771,6 @@ class SubscriptionService
$response = false;
$body = array_merge($context, [
'company_key' => $this->subscription->company->company_key,
'account_key' => $this->subscription->company->account->key,
'db' => $this->subscription->company->db,
]);
@ -920,6 +922,7 @@ class SubscriptionService
'recurring_invoice' => $recurring_invoice->hashed_id,
'client' => $recurring_invoice->client->hashed_id,
'contact' => auth('contact')->user()->hashed_id,
'account_key' => $recurring_invoice->client->custom_value2,
];
$this->triggerWebhook($context);
@ -1042,7 +1045,7 @@ class SubscriptionService
'client' => $invoice->client->hashed_id,
'contact' => $invoice->client->primary_contact()->first() ? $invoice->client->primary_contact()->first()->hashed_id: $invoice->client->contacts->first()->hashed_id,
'invoice' => $invoice->hashed_id,
'account_key' => $invoice->client->custom
'account_key' => $invoice->client->custom_value2,
];
$response = $this->triggerWebhook($context);

635
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -110,14 +110,14 @@
document.getElementById('handlePlanChange').addEventListener('click', function() {
if(document.getElementById("newPlan").value.length > 1)
location.href = 'https://invoiceninja.invoicing.co/client/subscriptions/{{ $current_recurring_id }}/plan_switch/' + document.getElementById("newPlan").value + '';
location.href = 'http://devhosted.test:8000/client/subscriptions/{{ $current_recurring_id }}/plan_switch/' + document.getElementById("newPlan").value + '';
});
@else
document.getElementById('handleNewPlan').addEventListener('click', function() {
if(document.getElementById("newPlan").value.length > 1)
location.href = 'https://invoiceninja.invoicing.co/client/subscriptions/' + document.getElementById("newPlan").value + '/purchase';
location.href = 'http://devhosted.test:8000/client/subscriptions/' + document.getElementById("newPlan").value + '/purchase';
});
@endif