Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

I have a form in one of my templates

 <form method="post" action="" accept-charset="UTF-8">
    <input type="hidden" name="action" value="paypalPayments/payment/pay">

     [...] 
 </form>

I also created a simple plugin like so:

//PaypalPaymentsPlugin.php
 <?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";
     }
 }

And also a controller file inside a controller folder:

 //File PaypalPayments_PaymentController.php
 <?php 

   namespace Craft;

   class PaypalPayments_PaymentController extends BaseController {

     public function actionPayWithPaypal() 
     {
        echo "I'm in...";
     }
   }

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?

share|improve this question

1 Answer 1

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:

<a href="{{ actionUrl('paypalPayments/payment/payWithPaypal') }}">Test me</a>
share|improve this answer
    
Thank you... the problem was that anonymous access was not granted to the controller... It now works fine! –  Paul Timoce 3 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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