Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PayU seccssUrl not work #90

Open
bmiit145 opened this issue Jul 17, 2024 · 0 comments
Open

PayU seccssUrl not work #90

bmiit145 opened this issue Jul 17, 2024 · 0 comments

Comments

@bmiit145
Copy link

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);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant