【发布时间】:2018-05-12 07:15:40
【问题描述】:
我使用用户为 paytm 制作的 package(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 商家页面以使用户进行付款?
【问题讨论】:
-
你试过
return redirect('http://payment_page')吗? -
我的意思是正在使用 paytm 支付网关。我已经按照他们所说的完成了 evrythng,但是当我点击提交按钮时,它说“将您重定向到商家页面”,但它会将我重定向到 localhost/payment/api /地位。 paytm 为我们提供了回调 url 之类的信息。你知道在哪里放置回调 url
标签: php laravel laravel-5 laravel-5.2 paytm