mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
update billing_context to use hashed_ids
This commit is contained in:
parent
a746384976
commit
0d767f7d98
@ -26,7 +26,7 @@ function isActive($page, bool $boolean = false)
|
|||||||
$current_page = Route::currentRouteName();
|
$current_page = Route::currentRouteName();
|
||||||
$action = Route::currentRouteAction(); // string
|
$action = Route::currentRouteAction(); // string
|
||||||
|
|
||||||
$show = str_replace(['.show','payment_methodss','documentss','subscriptionss'],['s.index','payment_methods','documents','subscriptions'], $current_page);
|
$show = str_replace(['.show','payment_methodss','documentss','subscriptionss','paymentss'],['s.index','payment_methods','documents','subscriptions','payments'], $current_page);
|
||||||
|
|
||||||
if ($page == $current_page && $boolean) {
|
if ($page == $current_page && $boolean) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -160,7 +160,7 @@ class PaymentController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (property_exists($payment_hash->data, 'billing_context')) {
|
if (property_exists($payment_hash->data, 'billing_context')) {
|
||||||
$billing_subscription = \App\Models\Subscription::find($payment_hash->data->billing_context->subscription_id);
|
$billing_subscription = \App\Models\Subscription::find($this->decodePrimaryKey($payment_hash->data->billing_context->subscription_id));
|
||||||
|
|
||||||
return (new SubscriptionService($billing_subscription))->completePurchase($payment_hash);
|
return (new SubscriptionService($billing_subscription))->completePurchase($payment_hash);
|
||||||
}
|
}
|
||||||
|
@ -403,10 +403,10 @@ class BillingPortalPurchase extends Component
|
|||||||
->save();
|
->save();
|
||||||
|
|
||||||
Cache::put($this->hash, [
|
Cache::put($this->hash, [
|
||||||
'subscription_id' => $this->subscription->id,
|
'subscription_id' => $this->subscription->hashed_id,
|
||||||
'email' => $this->email ?? $this->contact->email,
|
'email' => $this->email ?? $this->contact->email,
|
||||||
'client_id' => $this->contact->client->id,
|
'client_id' => $this->contact->client->hashed_id,
|
||||||
'invoice_id' => $this->invoice->id,
|
'invoice_id' => $this->invoice->hashed_id,
|
||||||
'context' => 'purchase',
|
'context' => 'purchase',
|
||||||
'campaign' => $this->campaign,
|
'campaign' => $this->campaign,
|
||||||
], now()->addMinutes(60));
|
], now()->addMinutes(60));
|
||||||
|
@ -526,7 +526,7 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'client_id' => $this->contact->client->id,
|
'client_id' => $this->contact->client->hashed_id,
|
||||||
'date' => now()->format('Y-m-d'),
|
'date' => now()->format('Y-m-d'),
|
||||||
'invitations' => [[
|
'invitations' => [[
|
||||||
'key' => '',
|
'key' => '',
|
||||||
@ -547,10 +547,10 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
->save();
|
->save();
|
||||||
|
|
||||||
Cache::put($this->hash, [
|
Cache::put($this->hash, [
|
||||||
'subscription_id' => $this->subscription->id,
|
'subscription_id' => $this->subscription->hashed_id,
|
||||||
'email' => $this->email ?? $this->contact->email,
|
'email' => $this->email ?? $this->contact->email,
|
||||||
'client_id' => $this->contact->client->id,
|
'client_id' => $this->contact->client->hashed_id,
|
||||||
'invoice_id' => $this->invoice->id,
|
'invoice_id' => $this->invoice->hashed_id,
|
||||||
'context' => 'purchase',
|
'context' => 'purchase',
|
||||||
'campaign' => $this->campaign,
|
'campaign' => $this->campaign,
|
||||||
'bundle' => $this->bundle,
|
'bundle' => $this->bundle,
|
||||||
@ -567,8 +567,8 @@ class BillingPortalPurchasev2 extends Component
|
|||||||
return $this->subscription->service()->startTrial([
|
return $this->subscription->service()->startTrial([
|
||||||
'email' => $this->email ?? $this->contact->email,
|
'email' => $this->email ?? $this->contact->email,
|
||||||
'quantity' => $this->quantity,
|
'quantity' => $this->quantity,
|
||||||
'contact_id' => $this->contact->id,
|
'contact_id' => $this->contact->hashed_id,
|
||||||
'client_id' => $this->contact->client->id,
|
'client_id' => $this->contact->client->hashed_id,
|
||||||
'bundle' => $this->bundle,
|
'bundle' => $this->bundle,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -106,11 +106,11 @@ class SubscriptionPlanSwitch extends Component
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
Cache::put($this->hash, [
|
Cache::put($this->hash, [
|
||||||
'subscription_id' => $this->target->id,
|
'subscription_id' => $this->target->hashed_id,
|
||||||
'target_id' => $this->target->id,
|
'target_id' => $this->target->hashed_id,
|
||||||
'recurring_invoice' => $this->recurring_invoice->id,
|
'recurring_invoice' => $this->recurring_invoice->hashed_id,
|
||||||
'client_id' => $this->recurring_invoice->client->id,
|
'client_id' => $this->recurring_invoice->client->hashed_id,
|
||||||
'invoice_id' => $this->state['invoice']->id,
|
'invoice_id' => $this->state['invoice']->hashed_id,
|
||||||
'context' => 'change_plan',
|
'context' => 'change_plan',
|
||||||
now()->addMinutes(60), ]
|
now()->addMinutes(60), ]
|
||||||
);
|
);
|
||||||
|
@ -319,7 +319,7 @@ class MatchBankTransactions implements ShouldQueue
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}, 1);
|
}, 2);
|
||||||
|
|
||||||
if(!$this->invoice)
|
if(!$this->invoice)
|
||||||
return;
|
return;
|
||||||
|
@ -289,7 +289,7 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||||
|
|
||||||
if (property_exists($this->payment_hash->data, 'billing_context') && $status == Payment::STATUS_COMPLETED) {
|
if (property_exists($this->payment_hash->data, 'billing_context') && $status == Payment::STATUS_COMPLETED) {
|
||||||
$billing_subscription = \App\Models\Subscription::find($this->payment_hash->data->billing_context->subscription_id);
|
$billing_subscription = \App\Models\Subscription::find($this->decodePrimaryKey($this->payment_hash->data->billing_context->subscription_id));
|
||||||
|
|
||||||
// To access campaign hash => $this->payment_hash->data->billing_context->campaign;
|
// To access campaign hash => $this->payment_hash->data->billing_context->campaign;
|
||||||
// To access campaign data => Cache::get(CAMPAIGN_HASH)
|
// To access campaign data => Cache::get(CAMPAIGN_HASH)
|
||||||
|
@ -42,7 +42,7 @@ class ClientService
|
|||||||
$this->client->balance += $amount;
|
$this->client->balance += $amount;
|
||||||
$this->client->save();
|
$this->client->save();
|
||||||
|
|
||||||
}, 1);
|
}, 2);
|
||||||
}
|
}
|
||||||
catch (\Throwable $throwable) {
|
catch (\Throwable $throwable) {
|
||||||
nlog("DB ERROR " . $throwable->getMessage());
|
nlog("DB ERROR " . $throwable->getMessage());
|
||||||
@ -63,7 +63,7 @@ class ClientService
|
|||||||
$this->client->paid_to_date += $paid_to_date;
|
$this->client->paid_to_date += $paid_to_date;
|
||||||
$this->client->save();
|
$this->client->save();
|
||||||
|
|
||||||
}, 1);
|
}, 2);
|
||||||
}
|
}
|
||||||
catch (\Throwable $throwable) {
|
catch (\Throwable $throwable) {
|
||||||
nlog("DB ERROR " . $throwable->getMessage());
|
nlog("DB ERROR " . $throwable->getMessage());
|
||||||
@ -82,7 +82,7 @@ class ClientService
|
|||||||
$this->client->paid_to_date += $amount;
|
$this->client->paid_to_date += $amount;
|
||||||
$this->client->save();
|
$this->client->save();
|
||||||
|
|
||||||
}, 1);
|
}, 2);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
|
@ -230,6 +230,14 @@ class InstantPayment
|
|||||||
elseif($this->request->hash){
|
elseif($this->request->hash){
|
||||||
$hash_data['billing_context'] = Cache::get($this->request->hash);
|
$hash_data['billing_context'] = Cache::get($this->request->hash);
|
||||||
}
|
}
|
||||||
|
elseif($old_hash = PaymentHash::where('fee_invoice_id', $first_invoice->id)->whereNull('payment_id')->first()) {
|
||||||
|
|
||||||
|
if(isset($old_hash->data->billing_context))
|
||||||
|
{
|
||||||
|
$hash_data['billing_context'] = $old_hash->data->billing_context;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$payment_hash = new PaymentHash;
|
$payment_hash = new PaymentHash;
|
||||||
$payment_hash->hash = Str::random(32);
|
$payment_hash->hash = Str::random(32);
|
||||||
|
@ -51,7 +51,7 @@ class DeletePayment
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 1);
|
}, 2);
|
||||||
|
|
||||||
return $this->payment;
|
return $this->payment;
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ class SubscriptionService
|
|||||||
public function startTrial(array $data)
|
public function startTrial(array $data)
|
||||||
{
|
{
|
||||||
// Redirects from here work just fine. Livewire will respect it.
|
// Redirects from here work just fine. Livewire will respect it.
|
||||||
$client_contact = ClientContact::find($data['contact_id']);
|
$client_contact = ClientContact::find($this->decodePrimaryKey($data['contact_id']));
|
||||||
|
|
||||||
if(!$this->subscription->trial_enabled)
|
if(!$this->subscription->trial_enabled)
|
||||||
return new \Exception("Trials are disabled for this product");
|
return new \Exception("Trials are disabled for this product");
|
||||||
@ -734,7 +734,7 @@ class SubscriptionService
|
|||||||
{
|
{
|
||||||
nlog("handle plan change");
|
nlog("handle plan change");
|
||||||
|
|
||||||
$old_recurring_invoice = RecurringInvoice::find($payment_hash->data->billing_context->recurring_invoice);
|
$old_recurring_invoice = RecurringInvoice::find($this->decodePrimaryKey($payment_hash->data->billing_context->recurring_invoice));
|
||||||
|
|
||||||
if(!$old_recurring_invoice)
|
if(!$old_recurring_invoice)
|
||||||
return $this->handleRedirect('/client/recurring_invoices/');
|
return $this->handleRedirect('/client/recurring_invoices/');
|
||||||
|
@ -28,7 +28,7 @@ trait SubscriptionHooker
|
|||||||
];
|
];
|
||||||
|
|
||||||
if(!isset($subscription->webhook_configuration['post_purchase_url']) && !isset($subscription->webhook_configuration['post_purchase_rest_method']))
|
if(!isset($subscription->webhook_configuration['post_purchase_url']) && !isset($subscription->webhook_configuration['post_purchase_rest_method']))
|
||||||
return;
|
return [];
|
||||||
|
|
||||||
if (count($subscription->webhook_configuration['post_purchase_headers']) >= 1) {
|
if (count($subscription->webhook_configuration['post_purchase_headers']) >= 1) {
|
||||||
$headers = array_merge($headers, $subscription->webhook_configuration['post_purchase_headers']);
|
$headers = array_merge($headers, $subscription->webhook_configuration['post_purchase_headers']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user