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

V17 Billing Route Not Wokring #872

Closed
hamzasgd opened this issue Jul 8, 2021 · 26 comments
Closed

V17 Billing Route Not Wokring #872

hamzasgd opened this issue Jul 8, 2021 · 26 comments

Comments

@hamzasgd
Copy link

hamzasgd commented Jul 8, 2021

InvalidArgumentException
Can only instantiate this object with a string.

@andreuka
Copy link

andreuka commented Jul 8, 2021

No route works in safari, only homepage:

"Can only instantiate this object with a string."

@BrandonR-16
Copy link

Dealing with the same thing. Not with billing, but with authenticate. Giving the exact same error.

@ghost
Copy link

ghost commented Jul 8, 2021

give examples of code.
also write the browser you are using, the operating system, etc.

without this it is impossible to reproduce your problem

@andreuka
Copy link

andreuka commented Jul 8, 2021

@enmaboya do you using package with turbolinks?

@hamzasgd
Copy link
Author

hamzasgd commented Jul 8, 2021

Found the problem missing shop parameter in the URL

@andreuka
Copy link

andreuka commented Jul 8, 2021

Found the problem missing shop parameter in the URL

do you have fix?

@hamzasgd
Copy link
Author

hamzasgd commented Jul 8, 2021

Yes, I think this is not mention in upgrade guide but available in billing section of the wiki

@hamzasgd
Copy link
Author

hamzasgd commented Jul 8, 2021

This is the new
{{ route('billing', ['plan' => 2, 'shop' => Auth::user()->name]) }}

@hamzasgd
Copy link
Author

hamzasgd commented Jul 8, 2021

In v16 only plan param is needed

@andreuka
Copy link

andreuka commented Jul 8, 2021

This is the new
{{ route('billing', ['plan' => 2, 'shop' => Auth::user()->name]) }}

Duh, all my routes are broken when using without turbolinks.
Are you with turbolinks?

@ghost
Copy link

ghost commented Jul 8, 2021

@enmaboya do you using package with turbolinks?

depends on the application.
some with turbolinks, some without.

all work the same.

and yes, for safari and private mode (e.g. in chrome), you need to pass the second parameter
" 'shop' => Auth::user()->name"

@andreuka
Copy link

andreuka commented Jul 8, 2021

@enmaboya do you using package with turbolinks?

depends on the application.
some with turbolinks, some without.

all work the same.

and yes, for safari and private mode (e.g. in chrome), you need to pass the second parameter
" 'shop' => Auth::user()->name"

But do you have multipages applications (server rendered) without turbolinks, right?
So all issue is we need to add shop to all links?

@BrandonR-16
Copy link

BrandonR-16 commented Jul 8, 2021

@enmaboya do you using package with turbolinks?

depends on the application.
some with turbolinks, some without.

all work the same.

and yes, for safari and private mode (e.g. in chrome), you need to pass the second parameter
" 'shop' => Auth::user()->name"

Where do you pass this parameter? Sort of new to Laravel so I'm kinda confused

@andreuka
Copy link

andreuka commented Jul 8, 2021

@enmaboya do you using package with turbolinks?

depends on the application.
some with turbolinks, some without.
all work the same.
and yes, for safari and private mode (e.g. in chrome), you need to pass the second parameter
" 'shop' => Auth::user()->name"

Where do you pass this parameter. Sort of new to Laravel so I'm kinda confused

seems like it needs to be added for all links.

@ghost
Copy link

ghost commented Jul 8, 2021

seems like it needs to be added for all links.

No, for all other links you should have in your layout template
@include('shopify-app::partials.token_handler')

and add @sessionToken for post requests

@BrandonR-16
Copy link

seems like it needs to be added for all links.

No, for all other links you should have in your layout template
@include('shopify-app::partials.token_handler')

and add @sessionToken for post requests

Could you provide an example of where @include('shopify-app::partials.token_handler') goes in your code and how it's used?

@andreuka
Copy link

andreuka commented Jul 8, 2021

seems like it needs to be added for all links.

No, for all other links you should have in your layout template
@include('shopify-app::partials.token_handler')
and add @sessionToken for post requests

Could you provide an example of where @include('shopify-app::partials.token_handler') goes in your code and how it's used?

its included by default in latest version of package, but it doesnt solve anything when using without turbolinks for me

@BrandonR-16
Copy link

BrandonR-16 commented Jul 8, 2021

seems like it needs to be added for all links.

No, for all other links you should have in your layout template
@include('shopify-app::partials.token_handler')
and add @sessionToken for post requests

Could you provide an example of where @include('shopify-app::partials.token_handler') goes in your code and how it's used?

its included by default in latest version of package, but it doesnt solve anything when using without turbolinks for me

Yeah I'm in the same boat

@andreuka
Copy link

andreuka commented Jul 8, 2021

seems like it needs to be added for all links.

No, for all other links you should have in your layout template
@include('shopify-app::partials.token_handler')
and add @sessionToken for post requests

Could you provide an example of where @include('shopify-app::partials.token_handler') goes in your code and how it's used?

its included by default in latest version of package, but it doesnt solve anything when using without turbolinks for me

Yeah I'm in the same boat

Add ?shop=current-shop.myshopify.com to all your links, this seems to be solving issue

@ghost
Copy link

ghost commented Jul 8, 2021

here

But, it is not necessary for billing.


Simply add the "shop" parameter to the route for billing

@andreuka
Copy link

andreuka commented Jul 8, 2021

here

But, it is not necessary for billing.

Simply add the "shop" parameter to the route for billing

not work out of the box for some reason :(

@andreuka
Copy link

andreuka commented Jul 8, 2021

seems like it needs to be added for all links.

No, for all other links you should have in your layout template
@include('shopify-app::partials.token_handler')
and add @sessionToken for post requests

Could you provide an example of where @include('shopify-app::partials.token_handler') goes in your code and how it's used?

its included by default in latest version of package, but it doesnt solve anything when using without turbolinks for me

Yeah I'm in the same boat

Fix with JS:

var shopOrigin = '{{ Auth::user()->name }}';

$(document).ready(function () {

    function addToQueryString(url, key, value) {
        var query = url.indexOf('?');
        var anchor = url.indexOf('#');
        if (query == url.length - 1) {
            // Strip any ? on the end of the URL
            url = url.substring(0, query);
            query = -1;
        }
        return (anchor > 0 ? url.substring(0, anchor) : url)
            + (query > 0 ? "&" + key + "=" + value : "?" + key + "=" + value)
            + (anchor > 0 ? url.substring(anchor) : "");
    }
    
    $('a[href]').each(function(){
        if(location.hostname === this.hostname || !this.hostname.length) {
            var a = $(this);
            var href = a.attr('href');
            var url = addToQueryString(href, 'shop', shopOrigin);
            a.attr('href', url);
        }
    });
});

@BrandonR-16
Copy link

That worked! Thank you so much! :)

@gnikyt
Copy link
Owner

gnikyt commented Jul 9, 2021

@hamzasgd

{{ URL::tokenRoute('billing', ['plan' => 2, 'shop' => Auth::user()->name]) }}

Should work.. I should maybe auto-add shop param to append with tokenRoute...

@hamzasgd
Copy link
Author

hamzasgd commented Jul 9, 2021

@hamzasgd

{{ URL::tokenRoute('billing', ['plan' => 2, 'shop' => Auth::user()->name]) }}

Should work.. I should maybe auto-add shop param to append with tokenRoute...

@osiset Yes that's a good idea.

@Kyon147
Copy link
Collaborator

Kyon147 commented Nov 3, 2021

'shop' was added automatically to Url:tokenRoute()on release V17 and PR #847 so closing this now.

@Kyon147 Kyon147 closed this as completed Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants