mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 07:14:37 -04:00
Subscriptions
This commit is contained in:
parent
1595df1b49
commit
bde5166827
@ -236,6 +236,7 @@ class CreateSingleAccount extends Command
|
|||||||
$webhook_config = [
|
$webhook_config = [
|
||||||
'post_purchase_url' => 'http://ninja.test:8000/api/admin/plan',
|
'post_purchase_url' => 'http://ninja.test:8000/api/admin/plan',
|
||||||
'post_purchase_rest_method' => 'POST',
|
'post_purchase_rest_method' => 'POST',
|
||||||
|
'post_purchase_headers' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
$sub = SubscriptionFactory::create($company->id, $user->id);
|
$sub = SubscriptionFactory::create($company->id, $user->id);
|
||||||
|
@ -34,8 +34,15 @@ class SubscriptionPlanSwitchController extends Controller
|
|||||||
|
|
||||||
$amount = $recurring_invoice->subscription->service()->calculateUpgradePrice($recurring_invoice, $target);
|
$amount = $recurring_invoice->subscription->service()->calculateUpgradePrice($recurring_invoice, $target);
|
||||||
|
|
||||||
|
nlog($amount);
|
||||||
|
|
||||||
|
//if($amount == null)
|
||||||
|
//please show account upgrade unavailable
|
||||||
|
//@ben
|
||||||
|
|
||||||
return render('subscriptions.switch', [
|
return render('subscriptions.switch', [
|
||||||
'subscription' => $subscription,
|
'subscription' => $recurring_invoice->subscription,
|
||||||
|
'recurring_invoice' => $recurring_invoice,
|
||||||
'target' => $target,
|
'target' => $target,
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
]);
|
]);
|
||||||
|
@ -19,11 +19,21 @@ use Livewire\Component;
|
|||||||
|
|
||||||
class SubscriptionPlanSwitch extends Component
|
class SubscriptionPlanSwitch extends Component
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var RecurringInvoice
|
||||||
|
*/
|
||||||
|
public $recurring_invoice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Subscription
|
* @var Subscription
|
||||||
*/
|
*/
|
||||||
public $subscription;
|
public $subscription;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ?float
|
||||||
|
*/
|
||||||
|
public $amount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Subscription
|
* @var Subscription
|
||||||
*/
|
*/
|
||||||
@ -62,7 +72,9 @@ class SubscriptionPlanSwitch extends Component
|
|||||||
|
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->total = $this->subscription->service()->getPriceBetweenSubscriptions($this->subscription, $this->target);
|
// $this->total = $this->subscription->service()->getPriceBetweenSubscriptions($this->subscription, $this->target);
|
||||||
|
|
||||||
|
$this->total = $this->amount;
|
||||||
|
|
||||||
$this->methods = $this->contact->client->service()->getPaymentMethods(100);
|
$this->methods = $this->contact->client->service()->getPaymentMethods(100);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class ShowPlanSwitchRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize()
|
public function authorize()
|
||||||
{
|
{
|
||||||
return (bool)$this->subscription->allow_plan_changes;
|
return (bool)$this->recurring_invoice->subscription->allow_plan_changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -209,7 +209,8 @@ class CheckoutComPaymentDriver extends BaseDriver
|
|||||||
|
|
||||||
$payment = new \Checkout\Models\Payments\Payment($method, $this->client->getCurrencyCode());
|
$payment = new \Checkout\Models\Payments\Payment($method, $this->client->getCurrencyCode());
|
||||||
$payment->amount = $this->convertToCheckoutAmount($amount, $this->client->getCurrencyCode());
|
$payment->amount = $this->convertToCheckoutAmount($amount, $this->client->getCurrencyCode());
|
||||||
$payment->reference = $cgt->meta->last4 . '-' . now();
|
//$payment->reference = $cgt->meta->last4 . '-' . now();
|
||||||
|
$payment->reference = $invoice->number . '-' . now();
|
||||||
|
|
||||||
$request = new PaymentResponseRequest();
|
$request = new PaymentResponseRequest();
|
||||||
$request->setMethod('POST');
|
$request->setMethod('POST');
|
||||||
|
@ -196,7 +196,8 @@ class SubscriptionService
|
|||||||
->where('balance', '>', 0);
|
->where('balance', '>', 0);
|
||||||
|
|
||||||
$outstanding_amounts = $outstanding->sum('balance');
|
$outstanding_amounts = $outstanding->sum('balance');
|
||||||
$outstanding_invoices = $outstanding->get();
|
// $outstanding_invoices = $outstanding->get();
|
||||||
|
$outstanding_invoices = $outstanding;
|
||||||
|
|
||||||
if ($outstanding->count() == 0){
|
if ($outstanding->count() == 0){
|
||||||
//nothing outstanding
|
//nothing outstanding
|
||||||
|
Loading…
x
Reference in New Issue
Block a user