<p>I'm the developer of Charge.</p>

<p>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. </p>

<p>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 <strong>Charge > Settings > General > Success URL</strong>. </p>

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

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

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

CC BY-SA 3.0
2016-06-10T17:12:54.890Z
Thanks, Joel! I don't seem to have the option to set the Success URL (http://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
CC BY-SA 3.0
2016-06-10T17:15:52.323Z
PS, I just noticed the extraneous `%` in there. I removed it and it doesn't seem to make a difference.
anguiac7
CC BY-SA 3.0
2016-06-11T00:02:02.720Z
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
CC BY-SA 3.0
2016-06-13T13:05:10.133Z
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
CC BY-SA 3.0
2016-06-14T01:04:15.133Z
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
CC BY-SA 3.0
2016-06-14T08:27:08.743Z
The hidden input should have a value of 'thanks/{hash}' or similar. Not including the {{ charge.hash }} part.
Joel Bradbury
CC BY-SA 3.0
2016-06-14T12:31:02.083Z
Switching the redirect hidden field to have a value of "thanks/{hash}" didn't seem to make a difference. Still being directed to /donate after the form submission. `<input type="hidden" name="redirect" value="thanks/{hash}">`
anguiac7
CC BY-SA 3.0
2016-06-21T09:41:45.783Z
Has anyone has any success on this one? We're trying to set a custom redirect based on the current page. `<input type="hidden" name="redirect" value="{{ craft.request.getPath() }}/success/{hash}">` but `{hash}` isn't being parsed/rendered into the form.
Brendan Underwood
CC BY-SA 3.0
2016-06-21T12:53:42.793Z
@BrendanUnderwood the `{hash}` explicitly isn't rendered in the form. It should be passed through to the submit unaltered. It only get's rendered at the point the Charge has actually been created, which is at the end of the request.
Joel Bradbury
CC BY-SA 3.0
2016-06-21T16:24:16.267Z
@JoelBradbury I still haven't been able to find a solution for this. Nothing I do seems to change the result.
anguiac7
CC BY-SA 3.0
2016-06-22T10:19:53.090Z
@anguiac7 can you send me some details directly (to support@squarebit.co.uk) and I'll look at what you're actually doing on the page. It's going to be something specific with your setup that you've got misconfigured.
Joel Bradbury
CC BY-SA 3.0
2016-06-23T00:54:16.337Z
@JoelBradbury thanks mate, we have it working on our end. Although we're not using the `{hash}` in our case unless you have a reason to.
Brendan Underwood
CC BY-SA 3.0
2016-06-10T16:12:01.323Z
2016-06-10T16:12:01.323Z
Joel Bradbury
<p>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 :/</p>

<p>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?</p>

CC BY-SA 3.0
2016-06-10T13:46:44.830Z
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
CC BY-SA 3.0
2016-06-10T10:32:42.127Z
2016-06-10T10:32:42.127Z
Matt Wilcox
<p>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. </p>

<p>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".</p>

<p>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.</p>

<p>My staging link is here: <a href="http://kb.topsdev.net/donate" rel="nofollow">kb.topsdev.net/donate</a></p>

<p>Any help is really appreciated.</p>

<plugins><redirect><plugin-charge>
Charge plugin redirecting to page with "1" on it
# Charge plugin redirecting to page with "1" on it

(Asked by: username_0 on 2016-06-10)

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](http://kb.topsdev.net/donate)

Any help is really appreciated.

**Tags:** plugins, redirect, plugin-charge


---

## 2 answers

### Answer by username_1 on 2016-06-10. Score: 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.

> **Comments:**
> **username_0**: Thanks, Joel! I don't seem to have the option to set the Success URL (http://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.  
> **username_0**: PS, I just noticed the extraneous `%` in there. I removed it and it doesn't seem to make a difference.  
> **username_0**: 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.  
> **username_1**: 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.  
> **username_0**: 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.  
> **username_1**: The hidden input should have a value of 'thanks/{hash}' or similar. Not including the {{ charge.hash }} part.  
> **username_0**: Switching the redirect hidden field to have a value of "thanks/{hash}" didn't seem to make a difference. Still being directed to /donate after the form submission. `<input type="hidden" name="redirect" value="thanks/{hash}">`  
> **username_2**: Has anyone has any success on this one? We're trying to set a custom redirect based on the current page. `<input type="hidden" name="redirect" value="{{ craft.request.getPath() }}/success/{hash}">` but `{hash}` isn't being parsed/rendered into the form.  
> **username_1**: @BrendanUnderwood the `{hash}` explicitly isn't rendered in the form. It should be passed through to the submit unaltered. It only get's rendered at the point the Charge has actually been created, which is at the end of the request.  
> **username_0**: @JoelBradbury I still haven't been able to find a solution for this. Nothing I do seems to change the result.  
> **username_1**: @username_0 can you send me some details directly (to support@squarebit.co.uk) and I'll look at what you're actually doing on the page. It's going to be something specific with your setup that you've got misconfigured.  
> **username_2**: @JoelBradbury thanks mate, we have it working on our end. Although we're not using the `{hash}` in our case unless you have a reason to.  

---

### Answer by username_3 on 2016-06-10. Score: 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?

> **Comments:**
> **username_0**: 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...  

---

