Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Billable app throwing exception on install #1110

Closed
ashwin-nath-m opened this issue Mar 19, 2022 · 32 comments
Closed

Billable app throwing exception on install #1110

ashwin-nath-m opened this issue Mar 19, 2022 · 32 comments
Labels
bug Bug with the code help-wanted Contributor help would be nice!

Comments

@ashwin-nath-m
Copy link

ashwin-nath-m commented Mar 19, 2022

For bug reporting only! If you're posting a feature request or discussion, please ignore.

Expected Behavior

App installed and user billed sucesfully

Current Behavior

App gets installed but crashes at billing part with exception

Failure Information

This is the exception
TypeError
Osiset\ShopifyApp\Http\Controllers\BillingController::index(): Argument #1 ($plan) must be of type ?int, Illuminate\Http\Request given, called in /var/www/xxx/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54

Steps to Reproduce

  1. Add plans using INSERT INTO plans (type,name,price,interval,capped_amount,terms,trial_days,test,on_install,created_at,updated_at) VALUES
    ('RECURRING','Test Plan',5.00,'EVERY_30_DAYS',10.00,'Test terms',7,TRUE,1,NULL,NULL);

  2. Add middleware (['auth.shopify', 'billable']) to app home page route

  3. Try installing the app

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Package Version: v17.1.0
  • Laravel Version: v8.83.5
  • PHP Version: 8.1.2
  • Using a toolset (Docker, Laradock, Vagrant, etc.): none

Failure Logs

Please include any relevant log snippets or files here.

@folio3git
Copy link

also getting the same error in php 8.1, while using billing

TypeError
Osiset\ShopifyApp\Http\Controllers\BillingController::index(): Argument #1 ($plan) must be of type ?int, Illuminate\Http\Request given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54

@Kyon147
Copy link
Collaborator

Kyon147 commented Mar 22, 2022

@ashwin-nath-m and @folio3git - Have you enabled billing in your ENV?

@ashwin-nath-m
Copy link
Author

@Kyon147 yes billing is enabled in env

@Kyon147
Copy link
Collaborator

Kyon147 commented Mar 22, 2022

From the error, you basically not passing over the ID for the plan itself Illuminate\Http\Request given instead the request is being passed.

I've seen this issue before, when there's no plans in the DB or incorrectly and it tries to add a plan but without 4 parameters and the 2nd param which is the Request, gets passed as the first hence the error.

@ashwin-nath-m
Copy link
Author

I am just going to a billable route ie my app's home route. There is already a plan in table (insert sql in description). where should i pass plan id?

@bilal186
Copy link

@Kyon147,

I have also encountered the same error in php 8.1
although I have enable billing from .env
SHOPIFY_BILLING_ENABLED=true
added billable middleware

INSERT INTO plans (type,name,price,interval,capped_amount,terms,trial_days,test,on_install,created_at,updated_at) VALUES
('RECURRING','Test Plan',5.00,'EVERY_30_DAYS',10.00,'Test terms',7,FALSE,1,NULL,NULL);

insert plans as well

and when I change php version to 7.4 then no error

Package Version: v17.1.0
Laravel Version: v8.77.1
PHP Version: 8.1.3

Thank you

@Kyon147
Copy link
Collaborator

Kyon147 commented Mar 22, 2022

Trying on php 8.1.2 I do see a deprecated warning that will need fixing

PHP Deprecated: Optional parameter $plan declared before required parameter $getPlanUrl is implicitly treated as a required parameter in /vendor/osiset/laravel-shopify/src/Traits/BillingController.php on line 37

However, I can get the Plan correctly - so not sure if this is the same error you are facing. Can you have a look in your laravel logs to see if there's any more details?

@ashwin-nath-m
Copy link
Author

This is the stacktrace . Maybe because of this?

local.ERROR: Osiset\ShopifyApp\Http\Controllers\BillingController::index(): Argument #1 ($plan) must be of type ?int, Illuminate\Http\Request given, called in /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54 {"userId":3,"exception":"[object] (TypeError(code: 0): Osiset\ShopifyApp\Http\Controllers\BillingController::index(): Argument #1 ($plan) must be of type ?int, Illuminate\Http\Request given, called in /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54 at /var/www/app/releases/15/vendor/osiset/laravel-shopify/src/Traits/BillingController.php:37)
[stacktrace]
#0 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Osiset\ShopifyApp\Http\Controllers\BillingController->index()
#1 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction()
#2 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\Routing\ControllerDispatcher->dispatch()
#3 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\Routing\Route->runController()
#4 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Router.php(721): Illuminate\Routing\Route->run()
#5 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Routing\Router->Illuminate\Routing\{closure}()
#6 /var/www/app/releases/15/vendor/osiset/laravel-shopify/src/Http/Middleware/VerifyShopify.php(101): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#7 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Osiset\ShopifyApp\Http\Middleware\VerifyShopify->handle()
#8 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#9 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Routing\Middleware\SubstituteBindings->handle()
#10 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#11 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
#12 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#13 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle()
#14 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#15 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest()
#16 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle()
#17 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#18 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
#19 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#20 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle()
#21 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#22 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Pipeline\Pipeline->then()
#23 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router->runRouteWithinStack()
#24 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router->runRoute()
#25 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router->dispatchToRoute()
#26 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Routing\Router->dispatch()
#27 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
#28 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#29 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#30 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
#31 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#32 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
#33 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\TrimStrings->handle()
#34 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#35 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
#36 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#37 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
#38 /var/www/app/releases/15/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#39 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\Cors\HandleCors->handle()
#40 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#41 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Http\Middleware\TrustProxies->handle()
#42 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
#43 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Pipeline\Pipeline->then()
#44 /var/www/app/releases/15/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#45 /var/www/app/releases/15/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle()
#46 {main}
"}

@bilal186
Copy link

bilal186 commented Mar 31, 2022

@Kyon147
any resolution on this ?

Thank you

@Kyon147
Copy link
Collaborator

Kyon147 commented Mar 31, 2022

Hey @bilal186

Can you try using [email protected] and see if the issue persists?

@bilal186
Copy link

I have checked with [email protected] its working fine

@d-shannon
Copy link

Yep same here with fresh install on PHP 8.1

@Kyon147
Copy link
Collaborator

Kyon147 commented Apr 27, 2022

I believe this bug is on 8.1 - can you try 8.0 and see if it works @d-shannon

@d-shannon
Copy link

@Kyon147 yep confirming it works on 8.0. Had a job getting valet to isolate the version but got there in the end! Cheers

@Kyon147 Kyon147 added bug Bug with the code help-wanted Contributor help would be nice! labels May 14, 2022
@talktohenryj
Copy link

So is the answer to just lower our version to 8.0? Has their been a fix for 8.1 with this bug? I am running into this issue now as well.

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 3, 2022

Yeah I believe on PHP8.1 optional parameters must be at the end of the method, which is why this gets flagged as an issue.

@talktohenryj
Copy link

Makes sense. So doesn't that mean we should update the Osiset package?

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 3, 2022

Hey @talktohenryj

Yeah A PR with the fix needs to be done. I think i have seen another PR for another fix also tackable, of the top of my head it might be the laravel 9 PR.

@DeveloperHashmi
Copy link

Hi @Kyon147
I'm also getting the same error. Could you fixed it or tell me the way to resolve, Please.

TypeError
Osiset\ShopifyApp\Http\Controllers\BillingController::index(): Argument #1 ($plan) must be of type ?int, Illuminate\Http\Request given, called in /var/www/shopify/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54
git_report

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 18, 2022

Hi @DeveloperHashmi

Easiest solution for now, drop to php version 8.0 not 8.1

@talktohenryj
Copy link

@DeveloperHashmi thats what I did. I lowered my php. To do so I had to delete my vendor folder and do a composer install though.

@DeveloperHashmi
Copy link

DeveloperHashmi commented Aug 18, 2022

Hi @Kyon147
I drop my php version to 8.0.17 (SS Attached) also deleted vendor folder and run composer again and now I'm getting this error. (SS Attached)

Osiset\ShopifyApp\Exceptions\ApiException
Unknown error
Stack Trace : Osiset\ShopifyApp\Services\ApiHelper::doRequest
vendor/osiset/laravel-shopify/src/Services/ApiHelper.php:493

Should we create a plan using shopify Recurring Application Charge API or this API can create plan automatically.

If I've to create plan, Then should we pass plan id in route page with billable middleware. (SS Attached)

Could you tell me the way to resolve, please.
image

image
image

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 18, 2022

Do you have your plans set up in the plans table with one of them set to have the on_install to 1?

It look like it is not passing a plan_id to the route to select the right pricing.

@DeveloperHashmi
Copy link

Dear @Kyon147
I have already setup my plan in plans table. (SS Attched)
image
I passed plan_id to the route as mentioned in my above reply (SS Attached), If that's not correct, Could you please tell me the way to pass plan_id.
image

Please reply this also.
#Should we create a plan using shopify Recurring Application Charge API or this API can create plan automatically.

If I've to create plan, should we pass plan id in route page with billable middleware.

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 18, 2022

Hi @DeveloperHashmi

As you have set id 1 to be on_install you don't need to pass it as you have done in the middleware as that will be defaulted too automatically.

The package will create the charge automatically when you send them to a certain plan. If you have not, i recommend reading the Creating a billable app wiki page

This will go through the basic setup for creating the billable routes etc.

One thing to remember when selecting plans, you need to pass the plan id and the shop admin url i.e teststore.myshopify.com. It's mentioned here.

@DeveloperHashmi
Copy link

DeveloperHashmi commented Aug 20, 2022

Hi @Kyon147,

Got billing/process/{id} page not found error. Please help to resolve.

I implemented every thing as you said, and got billing page. But, whenever I clicked on cancel button (i.e. available on payment page - SS Attached)
image
I got an another pop-up page (SS Attached) and when I clicked on close button. I got Not Found error page (SS Attached)
image
image

I didn't get payment page on the time of app installation for accepting payment terms (Plan 1, Already set to 1 on_install).

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 20, 2022

Hi @DeveloperHashmi

I can confirm I get the same error, that new apps popup page is new since they moved apps to the "search" dropdown so I think the internal redirects after a cancelled charge have changed.

@osiset - just flagging and will try and get a PR out for it next week when I have time.

@Kyon147
Copy link
Collaborator

Kyon147 commented Aug 26, 2022

There is a PR out for this #1145 which we will try and ger merged.

@Avdkash
Copy link

Avdkash commented Sep 5, 2022

Hello @Kyon147 @osiset,

This has been an issue (Billable app throwing an exception on install) for a while now. We urgently need your assistance, Please let me know how we may help you move the process along faster. Could you please help me with the timeline to get this done? That will be really helpful!

Thank you!

@Kyon147
Copy link
Collaborator

Kyon147 commented Sep 5, 2022

Hi @Avdkash

This has been merged now into master and will be in the next release which I am working on this week hopefully.

@Avdkash
Copy link

Avdkash commented Sep 5, 2022

Hello @Kyon147 Thank you! I will be waiting for the update.

@Kyon147
Copy link
Collaborator

Kyon147 commented Sep 13, 2022

This should be sorted now I believe in v17.2.0 so closing for now.

@Kyon147 Kyon147 closed this as completed Sep 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug with the code help-wanted Contributor help would be nice!
Projects
None yet
Development

No branches or pull requests

8 participants