-
-
Notifications
You must be signed in to change notification settings - Fork 374
Billing controller error #115
Comments
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 |
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. |
Okay so the charge ID coming back from Shopify is being set as a string... I can force cast it |
Please check out v4.0.3 which includes the casting now. |
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 |
Im not on my computer now but hasnt the charge id been changed to a bigInt
and not just a standard int?
…On Sat, Oct 6, 2018, 15:11 demoskp ***@***.***> wrote:
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
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB0MbPk05KNF5yHMobtrBZwYagr-62H9ks5uiKvvgaJpZM4XJx-t>
.
|
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. |
Well how large are these numbers? Based on a quick google I found this from
a 2009 SO answer: 9223372036854775807 (2^63-1)
The max value of an int in PHP is platform dependant but I dont think
Shopifys charge ids are even close to this length.
… |
I've done a test a dumped the string to the screen as an integer and then when it was cast as a string and the number was different and quite smaller.
|
I guess I can revert it to a string |
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 :) |
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;
Is this correct to do or would it end up with issues in the future?
The text was updated successfully, but these errors were encountered: