2

I've been trying to figure this out for a couple days now and haven't been able to. I'm using the Squarebit Charge plugin to accept donations on a website.

I have everything working fine on my local Vagrant machine. However, when I push it to my staging server, the redirect to the "thank you" page never works. Instead of redirecting to the thank you page, the Donate page is reloaded and displays a single "1".

Does anyone have any ideas? I do get a TypeError in console because the card expiry date field had to be changed. Stripe would complain that the card exp_month field wasn't present so I had to create that field. I get the error on my Vagrant box too so I don't think it's causing the process to fail.

My staging link is here: kb.topsdev.net/donate

Any help is really appreciated.

4

I'm the developer of Charge.

I've never directly observed that behaviour, but it sounds like it's most likely hitting a redirect failure and falling back to some base success/fail responses.

The most likely cause of that, is that you've not specified the default success route in the Charge settings. You'll find that under Charge > Settings > General > Success URL.

In there, you can specify the exact redirect route to push a user to after a successful transaction.

A common format would be something like thanks/{slug}, and load up your receipt template, on a path like payments/receipt etc..

Alternatively you can supply a hidden input on the form called redirect with the url you'd want the user redirected to after the transaction completes.

| improve this answer | |
  • 1
    Thanks, Joel! I don't seem to have the option to set the Success URL (imgur.com/xftdNSV). I do have the hidden redirect input, though - {% if charge is defined %} %<input type="hidden" name="redirect" value="/thanks/{{charge.hash}}">{% endif %}. But still no luck. – anguiac7 Jun 10 '16 at 17:12
  • PS, I just noticed the extraneous % in there. I removed it and it doesn't seem to make a difference. – anguiac7 Jun 10 '16 at 17:15
  • It seems like the redirect hidden input is being ignored. No matter what I change the value to, the page I'm directed to is the donate page with the "1" on it. – anguiac7 Jun 11 '16 at 0:02
  • You explicitly shouldn't be putting that redirect hidden input within an {% if defined ..%} block. It needs to be just a hidden input on the form. Looking at the "Success URL" I mentioned above, the wording has changed for the full release, so I actually mean just the "Charge URL Format". Just set that and the template path if you'd prefer. – Joel Bradbury Jun 13 '16 at 13:05
  • Well, when I add it just as a hidden input, Craft freaks out because the charge variable is undefined. However, if I remove the hidden input and set the preference in Charge, I'm still redirected to the "1" upon form submission. – anguiac7 Jun 14 '16 at 1:04
2

I have seen this before - yesterday in fact, with this plugin. But I was messing about trying to get it to report errors back to the calling template from a plugin I was writing. I still don't know what caused it, but there might be a clue in that :/

Currently I have an issue with it where the redirect to success url never actually completes. Just hangs there. No errors in the logs, all successful. I'm in testing mode for Stripe though; have you remembered to change your Account mode to Live?

| improve this answer | |
  • Hmm... I'll have to investigate that further. I've been wracking my brain trying to find anything that could be causing it. Craft logs are ok, Charge logs say successful, Apache logs are fine. It just seems to be ignoring the part where Charge intercepts the form and directs it to the thank you page. I'm still in testing mode, but it completes successfully on my Vagrant box I'm developing on. Pushing to staging is when the issue happens. Can't find any differences between staging and Vagrant though... – anguiac7 Jun 10 '16 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.