mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
billing_subscriptions cleanup
This commit is contained in:
parent
a5b397d1ce
commit
053c1ca5fa
@ -40,6 +40,43 @@ class BillingSubscriptionController extends BaseController
|
||||
$this->billing_subscription_repo = $billing_subscription_repo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the list of BillingSubscriptions.
|
||||
* *
|
||||
* @return Response
|
||||
*
|
||||
* @OA\Get(
|
||||
* path="/api/v1/billing_subscriptions",
|
||||
* operationId="getBillingSubscriptions",
|
||||
* tags={"billing_subscriptions"},
|
||||
* summary="Gets a list of billing_subscriptions",
|
||||
* description="Lists billing_subscriptions.",
|
||||
*
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
||||
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
||||
* @OA\Parameter(ref="#/components/parameters/include"),
|
||||
* @OA\Response(
|
||||
* response=200,
|
||||
* description="A list of billing_subscriptions",
|
||||
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
||||
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
||||
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
||||
* @OA\JsonContent(ref="#/components/schemas/BillingSubscription"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response=422,
|
||||
* description="Validation error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
||||
* ),
|
||||
* @OA\Response(
|
||||
* response="default",
|
||||
* description="Unexpected Error",
|
||||
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
||||
* ),
|
||||
* )
|
||||
*/
|
||||
|
||||
public function index(): \Illuminate\Http\Response
|
||||
{
|
||||
$billing_subscriptions = BillingSubscription::query()->company();
|
||||
|
31
app/Http/Controllers/OpenAPI/BillingSubscription.php
Normal file
31
app/Http/Controllers/OpenAPI/BillingSubscription.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @OA\Schema(
|
||||
* schema="BillingSubscription",
|
||||
* type="object",
|
||||
* @OA\Property(property="id", type="string", example="Opnel5aKBz", description="______"),
|
||||
* @OA\Property(property="user_id", type="string", example="Opnel5aKBz", description="______"),
|
||||
* @OA\Property(property="product_id", type="string", example="Opnel5aKBz", description="______"),
|
||||
* @OA\Property(property="company_id", type="string", example="Opnel5aKBz", description="______"),
|
||||
* @OA\Property(property="recurring_invoice_id", type="string", example="Opnel5aKBz", description="______"),
|
||||
* @OA\Property(property="is_recurring", type="boolean", example="true", description="______"),
|
||||
* @OA\Property(property="frequency_id", type="string", example="1", description="integer const representation of the frequency"),
|
||||
* @OA\Property(property="auto_bill", type="string", example="always", description="enum setting"),
|
||||
* @OA\Property(property="promo_code", type="string", example="100OFF", description="______"),
|
||||
* @OA\Property(property="promo_discount", type="float", example=10, description="______"),
|
||||
* @OA\Property(property="is_amount_discount", type="boolean", example="true", description="______"),
|
||||
* @OA\Property(property="allow_cancellation", type="boolean", example="true", description="______"),
|
||||
* @OA\Property(property="per_seat_enabled", type="boolean", example="true", description="______"),
|
||||
* @OA\Property(property="min_seats_limit", type="integer", example="1", description="______"),
|
||||
* @OA\Property(property="max_seats_limit", type="integer", example="100", description="______"),
|
||||
* @OA\Property(property="trial_enabled", type="boolean", example="true", description="______"),
|
||||
* @OA\Property(property="trial_duration", type="integer", example="2", description="______"),
|
||||
* @OA\Property(property="allow_query_overrides", type="boolean", example="true", description="______"),
|
||||
* @OA\Property(property="allow_plan_changes", type="boolean", example="true", description="______"),
|
||||
* @OA\Property(property="plan_map", type="string", example="1", description="map describing the available upgrade/downgrade plans for this subscription"),
|
||||
* @OA\Property(property="refund_period", type="integer", example="2", description="______"),
|
||||
* @OA\Property(property="webhook_configuration", type="string", example="2", description="______"),
|
||||
* @OA\Property(property="is_deleted", type="boolean", example="2", description="______"),
|
||||
* )
|
||||
*/
|
||||
|
@ -43,6 +43,15 @@ class BillingSubscription extends BaseModel
|
||||
'webhook_configuration',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_deleted' => 'boolean',
|
||||
'plan_map' => 'object',
|
||||
'webhook_configuration' => 'object',
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
|
@ -29,7 +29,7 @@ class BillingSubscriptionTransformer extends EntityTransformer
|
||||
* @var array
|
||||
*/
|
||||
protected $availableIncludes = [
|
||||
'products',
|
||||
'product',
|
||||
];
|
||||
|
||||
public function transform(BillingSubscription $billing_subscription): array
|
||||
@ -44,24 +44,27 @@ class BillingSubscriptionTransformer extends EntityTransformer
|
||||
'frequency_id' => (string)$billing_subscription->frequency_id,
|
||||
'auto_bill' => (string)$billing_subscription->auto_bill,
|
||||
'promo_code' => (string)$billing_subscription->promo_code,
|
||||
'promo_discount' => (string)$billing_subscription->promo_discount,
|
||||
'promo_discount' => (float)$billing_subscription->promo_discount,
|
||||
'is_amount_discount' => (bool)$billing_subscription->is_amount_discount,
|
||||
'allow_cancellation' => (bool)$billing_subscription->allow_cancellation,
|
||||
'per_set_enabled' => (bool)$billing_subscription->per_set_enabled,
|
||||
'per_seat_enabled' => (bool)$billing_subscription->per_set_enabled,
|
||||
'min_seats_limit' => (int)$billing_subscription->min_seats_limit,
|
||||
'max_seats_limit' => (int)$billing_subscription->max_seats_limit,
|
||||
'trial_enabled' => (bool)$billing_subscription->trial_enabled,
|
||||
'trial_duration' => (string)$billing_subscription->trial_duration,
|
||||
'trial_duration' => (int)$billing_subscription->trial_duration,
|
||||
'allow_query_overrides' => (bool)$billing_subscription->allow_query_overrides,
|
||||
'allow_plan_changes' => (bool)$billing_subscription->allow_plan_changes,
|
||||
'plan_map' => (string)$billing_subscription->plan_map,
|
||||
'refund_period' => (string)$billing_subscription->refund_period,
|
||||
'refund_period' => (int)$billing_subscription->refund_period,
|
||||
'webhook_configuration' => (string)$billing_subscription->webhook_configuration,
|
||||
'is_deleted' => (bool)$billing_subscription->is_deleted,
|
||||
'created_at' => (int) $credit->created_at,
|
||||
'updated_at' => (int) $credit->updated_at,
|
||||
'archived_at' => (int) $credit->deleted_at,
|
||||
];
|
||||
}
|
||||
|
||||
public function includeProducts(BillingSubscription $billing_subscription): \League\Fractal\Resource\Item
|
||||
public function includeProduct(BillingSubscription $billing_subscription): \League\Fractal\Resource\Item
|
||||
{
|
||||
$transformer = new ProductTransformer($this->serializer);
|
||||
|
||||
|
@ -26,7 +26,7 @@ class CreateBillingSubscriptionsTable extends Migration
|
||||
$table->float('promo_discount')->default(0);
|
||||
$table->boolean('is_amount_discount')->default(false);
|
||||
$table->boolean('allow_cancellation')->default(true);
|
||||
$table->boolean('per_set_enabled')->default(false);
|
||||
$table->boolean('per_seat_enabled')->default(false);
|
||||
$table->unsignedInteger('min_seats_limit');
|
||||
$table->unsignedInteger('max_seats_limit');
|
||||
$table->boolean('trial_enabled')->default(false);
|
||||
|
@ -173,7 +173,7 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
|
||||
// Route::post('hooks', 'SubscriptionController@subscribe')->name('hooks.subscribe');
|
||||
// Route::delete('hooks/{subscription_id}', 'SubscriptionController@unsubscribe')->name('hooks.unsubscribe');
|
||||
|
||||
Route::resource('billing/subscriptions', 'BillingSubscriptionController');
|
||||
Route::resource('billing_subscriptions', 'BillingSubscriptionController');
|
||||
});
|
||||
|
||||
Route::match(['get', 'post'], 'payment_webhook/{company_key}/{company_gateway_id}', 'PaymentWebhookController')
|
||||
|
Loading…
x
Reference in New Issue
Block a user