I have implemented the Payone payment gateway (Creditcard, Sofort, Paydirect and Paypal) successfully. After successful payment I am getting txaction response (appointed and paid) and everything is fine. But sometimes I am not getting response from Payone after customer paid using Paypal
(I checked around 60 successful transactions. But in that 2 or 3 transactions are not got response and the customer's amount has been deducted from their account).
After successful transaction payone is posting data in to this route
/* Response from payone */
Route::post('/payment/response', 'PaymentController@response')->name('payment.response');
I think laravel request is not capturing data from url. or
There is something wrong to using this method Schema::hasColumn
.
Any help would be appreciated thanks.
PaymentController.php
public function response(Request $request)
{
// Here I created to store all request in to table but data is not storing.
/* Testing purpose begin */
$payment = new Payment;
foreach($_POST as $key => $value) {
if(Schema::hasColumn($payment->getTable(), $key)){
if(is_array($value)) {
$payment->{$key} = $value[1];
} else {
$payment->{$key} = $value;
}
}
}
$payment->save();
/* Testing purpose end */
if ($_POST["key"] == hash("md5", env('KEY'))) {
echo "TSOK"; // If key is valid, TSOK notification is for PAYONE
$user = Userlist::where('is_delete', 0)
->where('usrActive', '1')
->where('userid', $_POST["userid"])
->first();
if($user && $_POST["clearingtype"] && $_POST["txaction"]) {
$bookings = Booking::select('_id', 'old_booking_id', 'status', 'payment_status')
->where('user', new \MongoDB\BSON\ObjectID($user->_id))
->whereIn('status', ['5', '8', '10', '11']) //5=>Waiting for payment, 8=>Cart, 10=> Temporary (This status is using in edit booking section), 11=> On processing
->where('is_delete', 0)
->where('txid', $_POST["txid"])
->where('userid', $_POST["userid"])
->get();
if($bookings) {
if ($_POST["txaction"] == "appointed") {
update booking status and sent email
}
else if ($_POST["txaction"] == "paid") {
update paid status
}
else {
update failed status
}
}
}
}
}
laravel log
[2018-09-11 09:04:14] production.ERROR: Method [error] does not exist on [App\Http\Controllers\PaymentController]. {"userId":"5afa790212236cc4660ed509","exception":"[object] (BadMethodCallException(code: 0): Method [error] does not exist on [App\\Http\\Controllers\\PaymentController]. at /var/www/vhosts/cabin-holiday.frontend/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:68)
The solution for this issue is to change the method it should be get method. Because we are getting response from the paypal in url. So you need to set the GET method.