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

Billing controller error #115

Closed
demoskp opened this issue Oct 5, 2018 · 11 comments
Closed

Billing controller error #115

demoskp opened this issue Oct 5, 2018 · 11 comments
Assignees
Labels
bug Bug with the code

Comments

@demoskp
Copy link

demoskp commented Oct 5, 2018

When trying to upgrade the plan of a freemium app I get redirected to the billing page and upon accepting the charge I get the following error:

"Type error: Argument 1 passed to OhMyBrew\ShopifyApp\Libraries\BillingPlan::setChargeId() must be of the type integer, string given"

I manage solve that error by changing the expected type to a string of the setChargeId method of the BillingPlan.php file inside the Libraries folder so it now looks like:

public function setChargeId(string $chargeId)
{
$this->chargeId = $chargeId;

    return $this;
}

Is this correct to do or would it end up with issues in the future?

@tobiasdalhof
Copy link

tobiasdalhof commented Oct 5, 2018

How are you upgrading the plan? Can you show us the related code? I'd try to type cast the string to int. Changing the setter type will probably cause you more issues in the future

@demoskp
Copy link
Author

demoskp commented Oct 5, 2018

Hi there, I tried casting to an integer which solver the initial error but created a subsequent error.

The way I am upgrading is exactly as outline I. The documentation:

a href="{{ route('billing', ['plan_id' => 2]) }}">Upgrade</a

I just have a button which redirects to the billing controller with the relevant plan_id as I have them in my database which is how it was recommended they are added in the Plans table.

@gnikyt
Copy link
Owner

gnikyt commented Oct 5, 2018

Okay so the charge ID coming back from Shopify is being set as a string... I can force cast it

@gnikyt gnikyt self-assigned this Oct 5, 2018
@gnikyt gnikyt added bug Bug with the code fix-in-progress In progress labels Oct 5, 2018
gnikyt added a commit that referenced this issue Oct 5, 2018
@gnikyt
Copy link
Owner

gnikyt commented Oct 5, 2018

Please check out v4.0.3 which includes the casting now.

@gnikyt gnikyt added status-resolved and removed fix-in-progress In progress labels Oct 5, 2018
@demoskp
Copy link
Author

demoskp commented Oct 6, 2018

This will not work as casting from a long string to an integer will change the number as such long numbers are not supported in the int type. This goes back to Shopify and does and get request to get the charge and comes back with a 404 not found as the charge_id does not match.

As it stands I believe the best solution is changing the expected type to integer within BillingPlan.php

@ncpope
Copy link
Contributor

ncpope commented Oct 6, 2018 via email

@demoskp
Copy link
Author

demoskp commented Oct 6, 2018

You are talking about the database value whereas the issue now is with casting to integers in the code which is even before the values are stored in the database but instead handled as variables.

@ncpope
Copy link
Contributor

ncpope commented Oct 6, 2018 via email

@demoskp
Copy link
Author

demoskp commented Oct 6, 2018 via email

@gnikyt
Copy link
Owner

gnikyt commented Oct 8, 2018

I guess I can revert it to a string
Quite stupid there's no proper handling for these types of large Numbers in PHP... I'll release a patch..

@gnikyt
Copy link
Owner

gnikyt commented Oct 9, 2018

Made the method agnostic to solve the issue (still bugs me though 👎 that theres no way to handle the bigints). v4.0.4 has the patch :)

@gnikyt gnikyt closed this as completed Oct 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug with the code
Projects
None yet
Development

No branches or pull requests

4 participants