Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetPrettyUpdateURL Page Not Found #54

Closed
Romeid opened this issue Sep 7, 2017 · 4 comments
Closed

GetPrettyUpdateURL Page Not Found #54

Romeid opened this issue Sep 7, 2017 · 4 comments

Comments

@Romeid
Copy link

Romeid commented Sep 7, 2017

The GetPrettySubscriptionUpdateURL is 404'ing because the "/" parts of the URL itself are getting encoded. I haven't been able to narrow down what has changed on chargify's end to cause this - it does seem like a bug in Chargify.NET though. I've outlined fixes below.

If you update the Chargify.NET ChargifyConnect class to the following it should resolve the issue.

        public string GetPrettySubscriptionUpdateURL(string firstName, string lastName, int subscriptionId)
        {
            if (string.IsNullOrEmpty(SharedKey)) throw new ArgumentException("SharedKey is required to generate the hosted page url");

            string message = UpdateShortName + "--" + subscriptionId + "--" + SharedKey;
            string token = message.GetChargifyHostedToken();
            string prettyId = string.Format("{0}-{1}-{2}", subscriptionId, PCLWebUtility.WebUtility.UrlEncode(firstName.Trim().ToLower()), PCLWebUtility.WebUtility.UrlEncode(lastName.Trim().ToLower()));
            string methodString = string.Format("{0}/{1}/{2}", UpdateShortName, prettyId, token);
            // just in case?
            // methodString = PCLWebUtility.WebUtility.UrlEncode(methodString);
            string updateUrl = string.Format("{0}{1}{2}", URL, (URL.EndsWith("/") ? "" : "/"), methodString);
            return updateUrl;
        }

All i've done is comment out the global Urlencode call and wrap first and last name in encodes instead (as I believe those are the 2 potential problem areas - each of the sections could be wrapped in encodes instead). I also believe the URL encode in this method could be removed or modified as deemed appropriate.

Edit: I've looked into making a pull request but There's a billion errors - i think related to nuget packages.. or something... that I can't seem to fix at this time.

Edit 2: I updated the code snippets above - I was looking at the Chargify.NET folder in source - and that's apparently.. no longer.. needed/updated/used? I'm honestly not sure - but these changes are based on the code in the chargifydotnet structure instead.

Edit 3: I defeated VS/Git/TheWorld - PR at #55

@kfrancis
Copy link
Owner

Nice! I'll look at this shortly.

@Romeid
Copy link
Author

Romeid commented Sep 14, 2017

Just confirmed this morning the GetSubscriptionUpdateURL does have the same issue - we're using it in another area, so both of those changes would be needed. (Note: Again, you could just URLEncode each of the properties in the URL so the "/' isn't caught up in it - I just chose not to because first name/last name seems like the only potential areas for error)

@kfrancis
Copy link
Owner

Thanks @OSPete for the PR, merged!

@kfrancis
Copy link
Owner

Released in version 1.2.3.

kfrancis added a commit that referenced this issue Sep 19, 2017
hewittj added a commit to hewittj/chargify-dot-net that referenced this issue Oct 25, 2017
* Add option to remove a coupon - kfrancis#37

* Resharper misc cleanup

* .NET Core wip

* more wip

* Finishes kfrancis#33

Released in 1.1.6085.27777

* Finish kfrancis#37

Released in 1.1.6085.28097

* Fixes kfrancis#34

Released in v1.1.6085.28452

* Adds kfrancis#13

* Changes to add endpoints to find all coupons in a product family and retrieve usage details for a single coupon.

* Remove .NET core attempt

* Fixes kfrancis#49

Mark methods as obsolete

* Add support for kfrancis#48

Add hold/pause and resume support

* Handle serialization issue

* Update missing product fields for kfrancis#45

* Scrub test key

* Multi-target Net40, Net45 and NetCore

Fixes kfrancis#50 migrating to .NET Standard 2.0

* Remove nuspec from old project

* Remove beta tag

* Add invoice payment method

Fixes kfrancis#43

* Remove superfluous project

* wip kfrancis#42

* Use proper subItemObj

Fixes kfrancis#42

* Make test generic

* Add charge create options wip

Addresses kfrancis#40

* Remove old project and fix documentation

* Internalize PCLWebUtility (for now) and update Json.Net

* Update consumer sample apps

* Add test for kfrancis#51

* Fixes kfrancis#39

* Removed URL encode of entire methodString for update subscription URLs and instead encoded properties of the url.

* Version bump for kfrancis#54
hewittj added a commit to hewittj/chargify-dot-net that referenced this issue Oct 25, 2017
* Add option to remove a coupon - kfrancis#37

* Resharper misc cleanup

* .NET Core wip

* more wip

* Finishes kfrancis#33

Released in 1.1.6085.27777

* Finish kfrancis#37

Released in 1.1.6085.28097

* Fixes kfrancis#34

Released in v1.1.6085.28452

* Adds kfrancis#13

* Changes to add endpoints to find all coupons in a product family and retrieve usage details for a single coupon.

* Remove .NET core attempt

* Fixes kfrancis#49

Mark methods as obsolete

* Add support for kfrancis#48

Add hold/pause and resume support

* Handle serialization issue

* Update missing product fields for kfrancis#45

* Scrub test key

* Multi-target Net40, Net45 and NetCore

Fixes kfrancis#50 migrating to .NET Standard 2.0

* Remove nuspec from old project

* Remove beta tag

* Add invoice payment method

Fixes kfrancis#43

* Remove superfluous project

* wip kfrancis#42

* Use proper subItemObj

Fixes kfrancis#42

* Make test generic

* Add charge create options wip

Addresses kfrancis#40

* Remove old project and fix documentation

* Internalize PCLWebUtility (for now) and update Json.Net

* Update consumer sample apps

* Add test for kfrancis#51

* Fixes kfrancis#39

* Removed URL encode of entire methodString for update subscription URLs and instead encoded properties of the url.

* Version bump for kfrancis#54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants