mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-30 13:12:56 -04:00 
			
		
		
		
	Merge pull request #5069 from turbo124/billing_subscriptions
Billing subscriptions
This commit is contained in:
		
						commit
						0e33587dad
					
				| @ -1,5 +1,13 @@ | ||||
| <?php | ||||
| 
 | ||||
| /** | ||||
|  * Invoice Ninja (https://invoiceninja.com). | ||||
|  * | ||||
|  * @link https://github.com/invoiceninja/invoiceninja source repository | ||||
|  * | ||||
|  * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) | ||||
|  * | ||||
|  * @license https://opensource.org/licenses/AAL | ||||
|  */ | ||||
| 
 | ||||
| namespace App\Factory; | ||||
| 
 | ||||
| @ -11,6 +19,8 @@ class BillingSubscriptionFactory | ||||
|     public static function create(int $company_id, int $user_id): BillingSubscription | ||||
|     { | ||||
|         $billing_subscription = new BillingSubscription(); | ||||
|         $billing_subscription->company_id = $company_id; | ||||
|         $billing_subscription->user_id = $user_id; | ||||
| 
 | ||||
|         return $billing_subscription; | ||||
|     } | ||||
|  | ||||
| @ -84,6 +84,45 @@ class BillingSubscriptionController extends BaseController | ||||
|         return $this->listResponse($billing_subscriptions); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Show the form for creating a new resource. | ||||
|      * | ||||
|      * @param CreateBillingSubscriptionRequest $request  The request | ||||
|      * | ||||
|      * @return Response | ||||
|      * | ||||
|      * | ||||
|      * @OA\Get( | ||||
|      *      path="/api/v1/billing_subscriptions/create", | ||||
|      *      operationId="getBillingSubscriptionsCreate", | ||||
|      *      tags={"billing_subscriptions"}, | ||||
|      *      summary="Gets a new blank billing_subscriptions object", | ||||
|      *      description="Returns a blank object with default values", | ||||
|      *      @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 blank billing_subscriptions object", | ||||
|      *          @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 create(CreateBillingSubscriptionRequest $request): \Illuminate\Http\Response | ||||
|     { | ||||
|         $billing_subscription = BillingSubscriptionFactory::create(auth()->user()->company()->id, auth()->user()->id); | ||||
| @ -91,6 +130,45 @@ class BillingSubscriptionController extends BaseController | ||||
|         return $this->itemResponse($billing_subscription); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Store a newly created resource in storage. | ||||
|      * | ||||
|      * @param StoreBillingSubscriptionRequest $request  The request | ||||
|      * | ||||
|      * @return Response | ||||
|      * | ||||
|      * | ||||
|      * @OA\Post( | ||||
|      *      path="/api/v1/billing_subscriptions", | ||||
|      *      operationId="storeBillingSubscription", | ||||
|      *      tags={"billing_subscriptions"}, | ||||
|      *      summary="Adds a billing_subscriptions", | ||||
|      *      description="Adds an billing_subscriptions to the system", | ||||
|      *      @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="Returns the saved billing_subscriptions object", | ||||
|      *          @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 store(StoreBillingSubscriptionRequest $request): \Illuminate\Http\Response | ||||
|     { | ||||
|         $billing_subscription = $this->billing_subscription_repo->save($request->all(), BillingSubscriptionFactory::create(auth()->user()->company()->id, auth()->user()->id)); | ||||
| @ -100,16 +178,168 @@ class BillingSubscriptionController extends BaseController | ||||
|         return $this->itemResponse($billing_subscription); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Display the specified resource. | ||||
|      * | ||||
|      * @param ShowBillingSubscriptionRequest $request  The request | ||||
|      * @param Invoice $billing_subscription  The invoice | ||||
|      * | ||||
|      * @return Response | ||||
|      * | ||||
|      * | ||||
|      * @OA\Get( | ||||
|      *      path="/api/v1/billing_subscriptions/{id}", | ||||
|      *      operationId="showBillingSubscription", | ||||
|      *      tags={"billing_subscriptions"}, | ||||
|      *      summary="Shows an billing_subscriptions", | ||||
|      *      description="Displays an billing_subscriptions by id", | ||||
|      *      @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\Parameter( | ||||
|      *          name="id", | ||||
|      *          in="path", | ||||
|      *          description="The BillingSubscription Hashed ID", | ||||
|      *          example="D2J234DFA", | ||||
|      *          required=true, | ||||
|      *          @OA\Schema( | ||||
|      *              type="string", | ||||
|      *              format="string", | ||||
|      *          ), | ||||
|      *      ), | ||||
|      *      @OA\Response( | ||||
|      *          response=200, | ||||
|      *          description="Returns the BillingSubscription object", | ||||
|      *          @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 show(ShowBillingSubscriptionRequest $request, BillingSubscription $billing_subscription): \Illuminate\Http\Response | ||||
|     { | ||||
|         return $this->itemResponse($billing_subscription); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Show the form for editing the specified resource. | ||||
|      * | ||||
|      * @param EditBillingSubscriptionRequest $request  The request | ||||
|      * @param Invoice $billing_subscription  The invoice | ||||
|      * | ||||
|      * @return Response | ||||
|      * | ||||
|      * @OA\Get( | ||||
|      *      path="/api/v1/billing_subscriptions/{id}/edit", | ||||
|      *      operationId="editBillingSubscription", | ||||
|      *      tags={"billing_subscriptions"}, | ||||
|      *      summary="Shows an billing_subscriptions for editting", | ||||
|      *      description="Displays an billing_subscriptions by id", | ||||
|      *      @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\Parameter( | ||||
|      *          name="id", | ||||
|      *          in="path", | ||||
|      *          description="The BillingSubscription Hashed ID", | ||||
|      *          example="D2J234DFA", | ||||
|      *          required=true, | ||||
|      *          @OA\Schema( | ||||
|      *              type="string", | ||||
|      *              format="string", | ||||
|      *          ), | ||||
|      *      ), | ||||
|      *      @OA\Response( | ||||
|      *          response=200, | ||||
|      *          description="Returns the invoice object", | ||||
|      *          @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 edit(EditBillingSubscriptionRequest $request, BillingSubscription $billing_subscription): \Illuminate\Http\Response | ||||
|     { | ||||
|         return $this->itemResponse($billing_subscription); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Update the specified resource in storage. | ||||
|      * | ||||
|      * @param UpdateBillingSubscriptionRequest $request  The request | ||||
|      * @param BillingSubscription $billing_subscription  The invoice | ||||
|      * | ||||
|      * @return Response | ||||
|      * | ||||
|      * | ||||
|      * @OA\Put( | ||||
|      *      path="/api/v1/billing_subscriptions/{id}", | ||||
|      *      operationId="updateBillingSubscription", | ||||
|      *      tags={"billing_subscriptions"}, | ||||
|      *      summary="Updates an billing_subscriptions", | ||||
|      *      description="Handles the updating of an billing_subscriptions by id", | ||||
|      *      @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\Parameter( | ||||
|      *          name="id", | ||||
|      *          in="path", | ||||
|      *          description="The BillingSubscription Hashed ID", | ||||
|      *          example="D2J234DFA", | ||||
|      *          required=true, | ||||
|      *          @OA\Schema( | ||||
|      *              type="string", | ||||
|      *              format="string", | ||||
|      *          ), | ||||
|      *      ), | ||||
|      *      @OA\Response( | ||||
|      *          response=200, | ||||
|      *          description="Returns the billing_subscriptions object", | ||||
|      *          @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 update(UpdateBillingSubscriptionRequest $request, BillingSubscription $billing_subscription) | ||||
|     { | ||||
|         if ($request->entityIsDeleted($billing_subscription)) { | ||||
| @ -121,6 +351,56 @@ class BillingSubscriptionController extends BaseController | ||||
|         return $this->itemResponse($billing_subscription); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Remove the specified resource from storage. | ||||
|      * | ||||
|      * @param DestroyBillingSubscriptionRequest $request | ||||
|      * @param BillingSubscription $invoice | ||||
|      * | ||||
|      * @return     Response | ||||
|      * | ||||
|      * @throws \Exception | ||||
|      * @OA\Delete( | ||||
|      *      path="/api/v1/billing_subscriptions/{id}", | ||||
|      *      operationId="deleteBillingSubscription", | ||||
|      *      tags={"billing_subscriptions"}, | ||||
|      *      summary="Deletes a billing_subscriptions", | ||||
|      *      description="Handles the deletion of an billing_subscriptions by id", | ||||
|      *      @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\Parameter( | ||||
|      *          name="id", | ||||
|      *          in="path", | ||||
|      *          description="The BillingSubscription Hashed ID", | ||||
|      *          example="D2J234DFA", | ||||
|      *          required=true, | ||||
|      *          @OA\Schema( | ||||
|      *              type="string", | ||||
|      *              format="string", | ||||
|      *          ), | ||||
|      *      ), | ||||
|      *      @OA\Response( | ||||
|      *          response=200, | ||||
|      *          description="Returns a HTTP status", | ||||
|      *          @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\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 destroy(DestroyBillingSubscriptionRequest $request, BillingSubscription $billing_subscription): \Illuminate\Http\Response | ||||
|     { | ||||
|         $this->billing_subscription_repo->delete($billing_subscription); | ||||
|  | ||||
| @ -11,8 +11,8 @@ | ||||
|  *       @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="promo_code", type="string", example="PROMOCODE4U", description="______"), | ||||
|  *       @OA\Property(property="promo_discount", type="number", 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="______"), | ||||
|  | ||||
| @ -439,7 +439,7 @@ class RecurringInvoiceController extends BaseController | ||||
|     /** | ||||
|      * @OA\Get( | ||||
|      *      path="/api/v1/recurring_invoice/{invitation_key}/download", | ||||
|      *      operationId="downloadInvoice", | ||||
|      *      operationId="downloadRecurringInvoice", | ||||
|      *      tags={"invoices"}, | ||||
|      *      summary="Download a specific invoice by invitation key", | ||||
|      *      description="Downloads a specific invoice", | ||||
|  | ||||
| @ -38,7 +38,7 @@ class TwoFactorController extends BaseController | ||||
| 
 | ||||
|         $data = [ | ||||
|             'secret' => $secret, | ||||
|             'qrCode' => $qrCode, | ||||
|             'qrCode' => $qr_code, | ||||
|         ]; | ||||
| 
 | ||||
|         return response()->json(['data' => $data], 200); | ||||
|  | ||||
| @ -31,18 +31,12 @@ class PasswordProtection | ||||
|      */ | ||||
|     public function handle($request, Closure $next) | ||||
|     { | ||||
|     // {nlog($request->headers->all());
 | ||||
|     //  nlog($request->all());
 | ||||
|      | ||||
|         $error = [ | ||||
|             'message' => 'Invalid Password', | ||||
|             'errors' => new stdClass, | ||||
|         ]; | ||||
| 
 | ||||
|         nlog(Cache::get(auth()->user()->hashed_id.'_logged_in')); | ||||
|         nlog($request->header('X-API-OAUTH-PASSWORD')); | ||||
| 
 | ||||
| 
 | ||||
|         if (Cache::get(auth()->user()->hashed_id.'_logged_in')) { | ||||
| 
 | ||||
|             Cache::pull(auth()->user()->hashed_id.'_logged_in'); | ||||
|  | ||||
| @ -13,7 +13,7 @@ return [ | ||||
|     | | ||||
|     */ | ||||
| 
 | ||||
|     'default' => env('QUEUE_CONNECTION', 'database'), | ||||
|     'default' => env('QUEUE_CONNECTION', 'sync'), | ||||
| 
 | ||||
|     /* | ||||
|     |-------------------------------------------------------------------------- | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user