<p>There's alot of different things that could be going on here.</p>

<p>First, if your action is named <code>actionPayWithPaypal</code> (as in the code above) the action url should be <code>paypalPayments/payment/payWithPaypal</code> I guess?</p>

<p>You won't be able to hit the cocktail recipes method directly from your browser since it requires the request to be a post. But you should be able to hit your controller with yourdomain.com/actions/paypalPayments/payment/payWithPaypal.</p>

<p>But, only if you're logged in. If you're not logged in, that will give you a 404 unless you enable anonymous access to the controller, see <a href="http://buildwithcraft.com/docs/plugins/controllers#allowing-anonymous-access-to-actions">the documentation</a> on how to do that.</p>

<p>Also, is your .htaccess rewriting working as it should? If not, that could cause problems with calling the action directly. </p>

<p>Try generating an action url and see if that works:</p>

<pre><code>&lt;a href="{{ actionUrl('paypalPayments/payment/payWithPaypal') }}"&gt;Test me&lt;/a&gt;
</code></pre>

CC BY-SA 3.0
2014-09-17T15:21:33.500Z
Thank you... the problem was that anonymous access was not granted to the controller... It now works fine!
Paul Timoce
CC BY-SA 3.0
2014-09-17T14:13:51.560Z
2014-09-17T14:13:51.560Z
André Elvan
<p>I have a form in one of my templates</p>

<pre><code> &lt;form method="post" action="" accept-charset="UTF-8"&gt;
    &lt;input type="hidden" name="action" value="paypalPayments/payment/pay"&gt;

     [...] 
 &lt;/form&gt;
</code></pre>

<p>I also created a simple plugin like so:</p>

<pre><code>//PaypalPaymentsPlugin.php
 &lt;?php 
 namespace Craft;
 class PaypalPaymentsPlugin extends BasePlugin {

    function getName() {
       return Craft::t('Paypal Payments');
     }

     function getVersion() {
       return '1.0';
     }

     function getDeveloper() {
       return 'Paul Timoce';
     }

     function getDeveloperUrl() {
       return "http://paultimoce.net";
     }
 }
</code></pre>

<p>And also a controller file inside a controller folder:</p>

<pre><code> //File PaypalPayments_PaymentController.php
 &lt;?php 

   namespace Craft;

   class PaypalPayments_PaymentController extends BaseController {

     public function actionPayWithPaypal() 
     {
        echo "I'm in...";
     }
   }
</code></pre>

<p>All I want to do is post some variables through my form and process them with my plugin controller but every time I submit my form I hit the 404 page...</p>

<p>Do you guys have any idea as to why this is happening? I also installed and activated the sample cocktailRecipes plugin trying to do the same thing but unsuccessfully also... I tried to point my browser to /actions/paypalPayments/payment/pay and /actions/cocktailRecipes/ingredients/saveIngredient but also no luck... I always get redirected to the 404 page. </p>

<p>Can you help?</p>

<controller><routing>
Cannot post data to a plugin controller action
# Cannot post data to a plugin controller action

(Asked by: username_0 on 2014-09-17)

I have a form in one of my templates
 
    

     [...] 
 

I also created a simple plugin like so:
//PaypalPaymentsPlugin.php
 
And also a controller file inside a controller folder:
 //File PaypalPayments_PaymentController.php
 
All I want to do is post some variables through my form and process them with my plugin controller but every time I submit my form I hit the 404 page...
Do you guys have any idea as to why this is happening? I also installed and activated the sample cocktailRecipes plugin trying to do the same thing but unsuccessfully also... I tried to point my browser to /actions/paypalPayments/payment/pay and /actions/cocktailRecipes/ingredients/saveIngredient but also no luck... I always get redirected to the 404 page. 
Can you help?

**Tags:** controller, routing

---

## 1 answers

### Answer by username_1 on 2014-09-17. Score: 7 | Accepted answer

There's alot of different things that could be going on here.
First, if your action is named actionPayWithPaypal (as in the code above) the action url should be paypalPayments/payment/payWithPaypal I guess?
You won't be able to hit the cocktail recipes method directly from your browser since it requires the request to be a post. But you should be able to hit your controller with yourdomain.com/actions/paypalPayments/payment/payWithPaypal.
But, only if you're logged in. If you're not logged in, that will give you a 404 unless you enable anonymous access to the controller, see the documentation on how to do that.
Also, is your .htaccess rewriting working as it should? If not, that could cause problems with calling the action directly. 
Try generating an action url and see if that works:
Test me

> **Comments:**
> **username_0**: Thank you... the problem was that anonymous access was not granted to the controller... It now works fine!  

---

