我尝试使用Onmipay-Mollie和Barryvdh-Laravel-Omnipay
在我的网站上建立付款系统当我想要“付款”时,并提交用于付款的表单。我收到了一个错误:
Omnipay \ Common \ Exception \ RuntimeException
This response does not support redirection.
我的路线档案:
Route::get('mollietest', ['uses'=>'PurchaseController@index','as'=>'purchase.index']);
Route::get('paymenturl', ['uses'=>'PurchaseController@create','as'=>'purchase.create']);
Route::post('paymenturl', ['uses'=>'PurchaseController@store','as'=>'purchase.store']);
Route::get('checkout', ['uses'=>'PurchaseController@show','as'=>'purchase.show']);
我的PurchaseController:
public function index()
{
return View::make('mollie');
}
public function create()
{
// get list of issuers
$gateway = Omnipay::create('Mollie');
$gateway->setApiKey(mytestapi);
$payment = $gateway->fetchPaymentMethods()->send();
if($payment->isSuccessful()){
$pay = $payment->getPaymentMethods();
}
$henk = $gateway->fetchIssuers()->send();
if($henk->isSuccessful()){
$issuers = $henk->getIssuers();
}
return View::make('gewoonbetalen')
->with(['issuers'=>$issuers,'pay'=>$pay]);
}
public function store()
{
// make payment
$gateway = Omnipay::create('Mollie');
$gateway->setApiKey(mytestapi);
$order_id = time();
$params = array(
'amount'=>'10.00',
'description'=> time(),
'method'=>Input::get('paymentmethod'),
'returnUrl'=>URL::route('purchase.show'),
'redirectUrl'=>URL::route('purchase.show'),
'metadata'=> array(
'order_id' => $order_id,
),
'issuer'=>Input::get('issuer'),
);
$response = $gateway->purchase($params)->send();
Log::error('blablalllll');
if($response->isRedirect()){
$response->redirect();
} elseif($reponse->isPending()) {
return "Pending, Reference: ". $response->getTransactionReference();
} else {
return "Error " .$response->getCode() . ': ' .$response->getMessage();
}
}
public function show($id)
{
$gateway = Omnipay::create('Mollie');
$gateway->setApiKey(mytestapi);
$response = $gateway->completePurchase()->send();
$data = $response->getData();
print_r($data);
}
付款观点:
{{Form::open(array('action'=>'purchase.store','method'=>'POST'))}}
<select name="paymentmethod">
@foreach($pay as $payment)
<option value="{{$payment->getId() }}">{{$payment->getName()}}</option>
@endforeach
</select>
<select name="issuer">
@foreach($issuers as $issuer)
<option value="{{ $issuer->getId() }}" name="issuer">{{$issuer->getName();}}</option>
@endforeach
<option value="1">of wat anders</option>
</select>
{{Form::submit()}}
{{Form::close()}}
有什么遗漏或什么?我整个周末都忙着这个,但没有成功。有谁能告诉我出了什么问题?
仅供参考:我在本地主机上这样做。不知道这是否有任何问题(不应该)
答案 0 :(得分:0)
我遇到了同样的问题。它确实在重定向部分,我建议更改$ response-&gt; redirect();像... ...
返回Redirect :: away($ response-&gt; getData()['links'] ['paymentUrl']);
这会将用户从您的网站重定向到mollie支付网址,因为这将在网关打开并指定时生成。至少,这就是我设法解决它的方法。