-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
I have tried a payU gateway in laravel as It's not redirected to mentioned success url after payment in test mode and not about live
as I also mention my code for that
'payumoney' => [ // PayUMoney Parameters
'merchantKey' => env('PAYU_MERCHANT_KEY', ''),
'salt' => env('PAYU_MERCHANT_SALT', ''),
'workingKey' => env('PAYU_WORKING_KEY', ''),
'redirectUrl' => url('indipay/response'),
'successUrl' => env('PAYU_SUCCESS_URL', url('indipay/response')),
'failureUrl' => env('PAYU_FAILURE_URL', url('indipay/cancel')),
'cancelUrl' => env('PAYU_CANCEL_URL', url('indipay/cancel')),
'currency' => 'INR',
'language' => 'EN',
],
and
public function process(Request $request)
{
$userData = $request->session()->get('user_data_temp');
$request->session()->put('ccavenue_user_data', $userData);
$reg_id = $request->reg_id;
try {
$course_rate = $request->course_rate;
$numeric_course_rate = floatval(preg_replace('/[^0-9.]/', '', $course_rate));
$orderId = uniqid();
$tId = uniqid();
$email = $userData['email'];
// Create transaction table entry
$transaction = new Transaction;
$transaction->order_id = $orderId;
$transaction->tid = $tId;
$transaction->email = $email;
$transaction->save();
$parameters = [
'key' => env('PAYU_MERCHANT_KEY'),
'txnid' => $tId,
'amount' => $numeric_course_rate,
'productinfo' => 'Course for traders',
'firstname' => $userData['full_name'],
'email' => $email,
'phone' => $userData['phone'],
'surl' => route('payment.response'),
'furl' => route('payment.cancel'),
'service_provider' => 'payu_paisa',
'udf1' => '', // Optional user-defined fields
'udf2' => '',
'udf3' => '',
'udf4' => '',
'udf5' => '',
'service_provider' => 'payu_paisa'
];
// Create the hash string according to the provided formula
$hashString = implode('|', array_map('trim', [
$parameters['key'],
$parameters['txnid'],
$parameters['amount'],
$parameters['productinfo'],
$parameters['firstname'],
$parameters['email'],
$parameters['udf1'],
$parameters['udf2'],
$parameters['udf3'],
$parameters['udf4'],
$parameters['udf5'],
'','','','','',
env('PAYU_MERCHANT_SALT')
]));
// Generate the hash
// $parameters['hash'] = strtolower(hash('sha512', $hashString));
$order = Indipay::gateway('PayUMoney')->prepare($parameters);
// dd($order);
return Indipay::process($order);
}catch(IndipayParametersMissingException $e){
\Log::error('Missing Parameter Error:', ['exception' => $e]);
return response()->json(['error' => 'Missing Parameter Please try again. ' . $e->getMessage()], 400);
}
catch (\Exception $e) {
\Log::error('Payment Processing Error:', ['exception' => $e]);
return response()->json(['error' => 'An error occurred while processing the payment. Please try again. ' . $e->getMessage()], 500);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels