-1

我使用用户制作的 paytm 包(anand siddharth package)创建了与我的网站paytm集成
ordercontroller的如下:

<?php


namespace App\Http\Controllers;


use PaytmWallet;
use Illuminate\Http\Request;
use App\EventRegistration;


class OrderController extends Controller
{


    /**
     * Redirect the user to the Payment Gateway.
     *
     * @return Response
     */
    public function register()
    {
        return view('payment');
    }


    /**
     * Redirect the user to the Payment Gateway.
     *
     * @return Response
     */
    public function order(Request $request)
    {


        $this->validate($request, [
            'name' => 'required',
            'mobile_no' => 'required',
            'email' => 'required',
        ]);


        $input = $request->all();
        $input['order_id'] = $request->mobile_no.rand(1,100);
        $input['fee'] = 50;


        EventRegistration::create($input);


        $payment = PaytmWallet::with('receive');
        $payment->prepare([
          'order' => $input['order_id'],
          'user' => 'your paytm user',
          'mobile_number' => 'your paytm number',
          'email' => 'your paytm email',
          'amount' => $input['fee'],
          'callback_url' => url('api/payment/status')
        ]);
        return $payment->receive();
    }


    /**
     * Obtain the payment information.
     *
     * @return Object
     */
    public function paymentCallback()
    {
        $transaction = PaytmWallet::with('receive');


        $response = $transaction->response();
        $order_id = $transaction->getOrderId();


        if($transaction->isSuccessful()){
          EventRegistration::where('order_id',$order_id)->update(['status'=>2, 'transaction_id'=>$transaction->getTransactionId()]);


          dd('Payment Successfully Paid.');
        }else if($transaction->isFailed()){
          EventRegistration::where('order_id',$order_id)->update(['status'=>1, 'transaction_id'=>$transaction->getTransactionId()]);
          dd('Payment Failed.');
        }
    }
}

我知道回调 url 用于在付款完成后进行重定向。但是我如何编辑它ordercontroller以重定向到 paytm 商家页面以使用户进行付款?

4

1 回答 1

0

我找到了这个,它看起来就像你一直遵循的教程:

http://itsolutionstuff.com/post/paytm-payment-gateway-integration-example-in-laravel-5example.html

如果是这种情况,那么只需将浏览器导航到http://yoursite.com/event-registration将显示本教程最后提到的register.php文件(实际上是支付视图)。请注意,此文件包含一个POSTHTML 表单,提交时会将http://yoursite.com/payment启动该OrderController@order方法的用户发送到该表单。

编辑

参考问题的标题-如果您想从控制器内部将用户重定向到另一个路由,请在此处查看文档:

https://laravel.com/docs/5.6/redirects

总之,使用return redirect('route/path')将实现这一点。

于 2018-05-12T07:50:46.047 回答