Stripe – The requested address was not found on this server

| By Webner

Stripe Payment Gateway Integration – The requested address was not found on this server

Stripe Payment Issue while capturing payment:

I was implementing Stripe payment in one of my cake3 project. My Stripe Charge Capture Request was:

1) Check out Form :

<div class="col-sm-12 nopadd mrgn-10">
 <div class="container">
 <div class="page-content">
 <h3><?= __('Payment') ?></h3>
 <div class="col-sm-12 header-one">
  <form action="/Stripe/payment" method="POST">
 <script  src="" class="stripe-button"
	  data-key=<?php echo $publisherKey;?>
	  data-description="Example charge"
<div class="clearfix"></div>

action="/Stripe/payment" - is the call back url where stripe will redirect after payment.

2) Controller Action for payment:

$response = StripeCharge::create(array(
			"amount" => 2000,
			"currency" => "eur",
			'source' => $stripeToken,
			"description" => "Charge for",
			"capture"=>false, //set this to true if you immediately want to capture it
$response = $response ->jsonSerialize();
 $stripePaymentKey - Stripe gateway secret key 
 $stripeToken - Token provided by the Stripe gateway after submitting card details.

I got Stripe token to capture payments successfully. After that I hit the above action. Payment captured successfully but in the response instead of returning to the return url I was getting below error in the browser (In this case Stripe is the controller name and payment is the method name where control should return. In your case this path will be different.):
Stripe Payment Gateway Integration

Solution :
After inspecting the response of the above request using Inspect element, I found the actual cause of the issue.

Stripe Payment Gateway Integration

Stripe Payment Gateway Integration

CSRF token is sent by cakephp in each of its request from view to controller to find out that each time request is coming from same origin or not. It doesn’t allow request from other origin, as in our case. To resolve the issue, add below code in your controller’s beforeFilter method:

public function beforeFilter(Event $event){
		if (in_array($this->request->action, ['payment'])) {

After making the above change it worked fine and I returned back to the
Correct location by stripe.

Leave a Reply

Your email address will not be published. Required fields are marked *