<p>After the payment has been made, you can have the response callback go to an <a href="http://buildwithcraft.com/docs/plugins/controllers#allowing-anonymous-access-to-actions" rel="nofollow">anonymous</a> <a href="http://buildwithcraft.com/docs/plugins/controllers#linking-directly-to-controller-actions" rel="nofollow">action method</a> on your <a href="http://buildwithcraft.com/docs/plugins/introduction" rel="nofollow">plugin's</a> <a href="http://buildwithcraft.com/docs/plugins/controllers" rel="nofollow">controller</a>.</p>

<p>The URL for that would look something like this:</p>

<pre><code>http://mydomain.com/index.php/actions/myPluginHanlde/myPluginController/myPluginAction
</code></pre>

<p>From there you can perform any additional business logic (validation, record saving, etc.), and <code>$this-&gt;redirect('');</code> to a success template.</p>

CC BY-SA 3.0
2015-11-05T18:43:17.910Z
Thanks for your help! Can I? GoCardless wants me to provide a url for the user to be sent to after submitting their payment details. So I've provided my url that is: http://www.<the-site>.co.uk/api/gocardless/payment-made/index.php How can I call the action from within that? Or am I looking at it wrong?
H2ONOCK
CC BY-SA 3.0
2015-11-05T19:14:33.397Z
Updated answer.
Brad Bell
CC BY-SA 3.0
2015-11-05T19:20:33.423Z
That looks brilliant, I'll try it ASAP. Thank you so much!
H2ONOCK
CC BY-SA 3.0
2015-11-05T19:44:30.777Z
Worked a treat, nice one!
H2ONOCK
CC BY-SA 3.0
2015-11-05T18:26:29.160Z
2015-11-05T19:14:24.950Z
2015-11-05T19:14:24.950Z
Brad Bell
<p>So I'm in the middle of creating a plugin that allows users to make payments with GoCardless. Once payment has been made on the GoCardless website the user needs to be redirected to a PHP script that will confirm the payment was all hunkie-dorie... but....</p>

<p>Where do I put this script? At the moment I've put it inside a folder that is inside the htdocs folder but I'm having problems calling <code>craft()-&gt;plugin_name-&gt;confirmPayment()</code> from this location as <code>craft()</code> is undefined here.</p>

<p>Help greatly appreciated, thanks!</p>

<plugin-development>
Best practice for collecting a response from a third party
# Best practice for collecting a response from a third party

(Asked by: username_0 on 2015-11-05)

So I'm in the middle of creating a plugin that allows users to make payments with GoCardless. Once payment has been made on the GoCardless website the user needs to be redirected to a PHP script that will confirm the payment was all hunkie-dorie... but....

Where do I put this script? At the moment I've put it inside a folder that is inside the htdocs folder but I'm having problems calling `craft()->plugin_name->confirmPayment()` from this location as `craft()` is undefined here.

Help greatly appreciated, thanks!

**Tags:** plugin-development


---

## 1 answers

### Answer by username_1 on 2015-11-05. Score: 1 | Accepted answer

After the payment has been made, you can have the response callback go to an anonymous action method on your plugin's controller.
The URL for that would look something like this:
http://mydomain.com/index.php/actions/myPluginHanlde/myPluginController/myPluginAction

From there you can perform any additional business logic (validation, record saving, etc.), and $this->redirect(''); to a success template.

> **Comments:**
> **username_0**: Thanks for your help! Can I? GoCardless wants me to provide a url for the user to be sent to after submitting their payment details. So I've provided my url that is: http://www.<the-site>.co.uk/api/gocardless/payment-made/index.php How can I call the action from within that? Or am I looking at it wrong?  
> **username_1**: Updated answer.  
> **username_0**: That looks brilliant, I'll try it ASAP. Thank you so much!  
> **username_0**: Worked a treat, nice one!  

---

