Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T18:43:17.910Z
Answers.Text: 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?
Answers.UserDisplayName: H2ONOCK
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T19:14:33.397Z
Answers.Text: Updated answer.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T19:20:33.423Z
Answers.Text: That looks brilliant, I'll try it ASAP. Thank you so much!
Answers.UserDisplayName: H2ONOCK
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T19:44:30.777Z
Answers.Text: Worked a treat, nice one!
Answers.UserDisplayName: H2ONOCK
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-05T18:26:29.160Z
Answers.LastActivityDate: 2015-11-05T19:14:24.950Z
Answers.LastEditDate: 2015-11-05T19:14:24.950Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Tags: <plugin-development>
Title: Best practice for collecting a response from a third party
ThreadText: # 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](http://buildwithcraft.com/docs/plugins/controllers#allowing-anonymous-access-to-actions) [action method](http://buildwithcraft.com/docs/plugins/controllers#linking-directly-to-controller-actions) on your [plugin's](http://buildwithcraft.com/docs/plugins/introduction) [controller](http://buildwithcraft.com/docs/plugins/controllers).
  
  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!  
  
  ---
  
  