HI all, I need to use a Payment method for my site and by using PayPal seems to be the easiest and most secure way of payment on the internet. However, the API seems to be broken and very buggy on my end. I have installed PayPal api successfully with Laravel but when I call the function to create a payment, it returns an unspecified error which it's impossible for me to debug it as I have no idea on the internals of the Laravel API. The error. I am getting is the following: checkout.js:5857 Uncaught Error: Error: Request to post /api/create-payment failed with 404 error. Correlation id: unknown { "message": "", "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException", "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Foundation/Application.php", "line": 992, "trace": [ { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php", "line": 46, "function": "abort", "class": "Illuminate\\Foundation\\Application", "type": "->" }, { "file": "/Users/georgeka/sites/example/routes/web.php", "line": 413, "function": "abort" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 205, "function": "{closure}", "class": "Illuminate\\Routing\\RouteFileRegistrar", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Route.php", "line": 179, "function": "runCallable", "class": "Illuminate\\Routing\\Route", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Router.php", "line": 680, "function": "run", "class": "Illuminate\\Routing\\Route", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 30, "function": "Illuminate\\Routing\\{closure}", "class": "Illuminate\\Routing\\Router", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php", "line": 41, "function": "Illuminate\\Routing\\{closure}", "class": "Illuminate\\Routing\\Pipeline", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php", "line": 75, "function": "Illuminate\\Routing\\{closure}", "class": "Illuminate\\Routing\\Pipeline", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php", "line": 49, "function": "Illuminate\\Routing\\{closure}", "class": "Illuminate\\Routing\\Pipeline", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php", "line": 163, "function": "handle", "class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php", "line": 53, "function": "Illuminate\\Pipeline\\{closure}", "class": "Illuminate\\Pipeline\\Pipeline", "type": "->" }, { "file": "/Users/georgeka/sites/example/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php", "line": 56, "function": "Illuminate\\Routing\\{closure}", "class": "Illuminate\\Routing\\Pipeline", "type": "->" }, checkout.js:1588) at Object._RECEIVE_MESSAGE_TYPE.<computed> [as postrobot_message_response] (checkout.js:5218) at receiveMessage (checkout.js:5254) at messageListener (checkout.js:5276) at checkout.js:5857 at checkout.js:5860 at checkout.js:5687 at checkout.js:5682 at checkout.js:5683 at replaceObject (checkout.js:5686) at checkout.js:5688 at checkout.js:5684 at checkout.js:5685 at replaceObject (checkout.js:5686) (anonymous) @ checkout.js:5857 (anonymous) @ checkout.js:5860 (anonymous) @ checkout.js:5687 (anonymous) @ checkout.js:5682 (anonymous) @ checkout.js:5683 replaceObject @ checkout.js:5686 (anonymous) @ checkout.js:5688 (anonymous) @ checkout.js:5684 (anonymous) @ checkout.js:5685 replaceObject @ checkout.js:5686 (anonymous) @ checkout.js:5688 (anonymous) @ checkout.js:5684 (anonymous) @ checkout.js:5685 replaceObject @ checkout.js:5686 deserializeMethods @ checkout.js:5853 receiveMessage @ checkout.js:5253 messageListener @ checkout.js:5276 setTimeout (async) (anonymous) @ checkout.js:24553 (anonymous) @ checkout.js:3929 ZalgoPromise.try @ checkout.js:1160 (anonymous) @ checkout.js:3928 resultValue @ checkout.js:9164 (anonymous) @ checkout.js:3467 (anonymous) @ checkout.js:5765 ZalgoPromise.try @ checkout.js:1160 (anonymous) @ checkout.js:5764 (anonymous) @ checkout.js:5188 ZalgoPromise.try @ checkout.js:1160 _RECEIVE_MESSAGE_TYPE.<computed> @ checkout.js:5185 receiveMessage @ checkout.js:5254 messageListener @ checkout.js:5276 The Javascript code I use to call the create-payment function is as follows: paypal.Button.render({ env: 'sandbox', // Or 'production' style:{ size:"large", color: "gold", shape: "pill", }, // Set up the payment: // 1. Add a payment callback payment: function(data, actions) { // 2. Make a request to your server var data = { "offer_id": document.getElementById("offer_id").value, "comment": document.getElementById("comment").value, } return actions.request.post('/api/create-payment', {data: JSON.stringify(data), _token: "{{csrf_token()}}"} ) .then(function(res) { // 3. Return res.id from the response return res.id; }); }, // Execute the payment: // 1. Add an onAuthorize callback onAuthorize: function(data, actions) { // 2. Make a request to your server return actions.request.post('/api/execute-payment', { paymentID: data.paymentID, payerID: data.payerID, _token: "{{csrf_token()}}" }) .then(function(res) { // 3. Show the buyer a confirmation message. console.log(res) }); } }, '#paypal-button'); The routes is as follows: Route::post('create-payment', ["uses" => "BuyingLessOfferController@create_payment", 'as' => "api.create_payment"]); Route::post('execute-payment', ["uses" => "BuyingLessOfferController@execute_payment", 'as' => "api.execute_payment"]); I really need to get this issue fixed as soon as possible as the deadline to publish my web app is approaching. Thanks
... View more