mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for subscriptions
This commit is contained in:
parent
90540d6403
commit
946ab58f13
@ -46,7 +46,7 @@ class BillingSubscriptionService
|
||||
public function completePurchase(PaymentHash $payment_hash)
|
||||
{
|
||||
|
||||
if (!property_exists($payment_hash, 'billing_context')) {
|
||||
if (!property_exists($payment_hash->data, 'billing_context')) {
|
||||
throw new \Exception("Illegal entrypoint into method, payload must contain billing context");
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ class BillingSubscriptionService
|
||||
$cs->subscription_id = $this->billing_subscription->id;
|
||||
$cs->company_id = $this->billing_subscription->company_id;
|
||||
$cs->trial_started = time();
|
||||
$cs->trial_duration = time() + $this->billing_subscription->trial_duration;
|
||||
$cs->trial_ends = time() + $this->billing_subscription->trial_duration;
|
||||
$cs->quantity = $data['quantity'];
|
||||
$cs->client_id = $contact->client->id;
|
||||
$cs->save();
|
||||
|
@ -34,6 +34,8 @@ class BillingSubscriptionTransformer extends EntityTransformer
|
||||
|
||||
public function transform(BillingSubscription $billing_subscription): array
|
||||
{
|
||||
$std = new stdClass;
|
||||
|
||||
return [
|
||||
'id' => $this->encodePrimaryKey($billing_subscription->id),
|
||||
'user_id' => $this->encodePrimaryKey($billing_subscription->user_id),
|
||||
@ -56,7 +58,7 @@ class BillingSubscriptionTransformer extends EntityTransformer
|
||||
'allow_plan_changes' => (bool)$billing_subscription->allow_plan_changes,
|
||||
'plan_map' => (string)$billing_subscription->plan_map,
|
||||
'refund_period' => (int)$billing_subscription->refund_period,
|
||||
'webhook_configuration' => (string)$billing_subscription->webhook_configuration,
|
||||
'webhook_configuration' => $billing_subscription->webhook_configuration ?: $std,
|
||||
'purchase_page' => (string)route('client.subscription.purchase', $billing_subscription->hashed_id),
|
||||
'is_deleted' => (bool)$billing_subscription->is_deleted,
|
||||
'created_at' => (int)$billing_subscription->created_at,
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddNullableConstraintToRecurringInvoiceId extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('client_subscriptions', function (Blueprint $table) {
|
||||
$table->unsignedInteger('recurring_invoice_id')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user