我正在尝试将Payfast集成为支付网关,由于某种原因,它无法正常工作。一切正常,但现在在生产中似乎无法正常工作。
我首先获得想要支付的期望金额:
<form class="reservation-form" method="post" action="{{route('photography.store')}}">
@csrf
<div class="form-group">
<input id="datetimepicker1" placeholder="Date and Time" type="text" name="date_and_time" class="form-control">
</div>
<div class="form-group">
<input placeholder="Enter Amount" type="number" name="deposit_amount" min="250" class="form-control">
</div>
<div class="form-group">
<textarea placeholder="Leave a message" class="form-control" name="message"></textarea>
</div>
<div class="form-group">
<button class="btn1 btn1-primary" type="submit">Book</button>
</div>
</form>
提交表单后,我将重定向到此页面:
https://myurl.co.za/payfast
向我显示一个“在这里付款”按钮。
然后,在单击该按钮后,我被重定向到Payfast页面,并且看到以下错误:
Error The supplied variables are not according to specification:
signature : Generated signature does not match submitted signature
下图中要注意的一件事是,我在表格中输入的金额得到了传递。
以下是我的路线:
Route::get('payfast', 'PaymentsController@confirmPayment')->name('payfast.confirm');
Route::get('Success', 'PaymentsController@success')->name('payfast.success')->middleware('listing.details');
Route::get('Cancel', 'PaymentsController@cancel')->name('payfast.cancel')->middleware('listing.details');
所有有关预订的记录都应存储在名为“预订”的表中。
以下是所需的所有方法:
public function cancel(){
$payment_success = session('payment_success');
Booking::whereId($payment_success)->delete();
session()->flush();
return "Your payment failed";
}
public function success(){
$payment_success = session('payment_success');
Booking::whereId($payment_success)->update(['status'=> 1]);
$booking = Booking::whereId($payment_success)->where(['status'=> 1])->first();
$personal = session('personal');
$property = session('property');
}
public function confirmPayment(PaymentProcessor $payfast)
{
$nada = session('nada');
$order = Booking::create([
'deposit_amount' => $nada['deposit_amount'],
'date_and_time' => $nada['date_and_time'],
'message' => $nada['message'],
'status' => 0
]);
$payment_success = $order->id;
Session::put('payment_success', $payment_success);
$payfast->setBuyer('first name', 'last name', 'email');
$payfast->setAmount($order->deposit_amount);
$payfast->setItem('Photography Booking', 'item-description');
$payfast->setMerchantReference($order->id);
return $payfast->paymentForm('Pay Here');
}
如果需要的话,按照文档说明,我在config文件夹中有payfast.php文件,该文件存放了商家和站点的详细信息:
return
[
'testing' => false,
'merchant' => [
'merchant_id' => '13192354',
'merchant_key' => 'vg0qcw17c5sxd',
'return_url' => 'https://mydomain.co.za/Success',
'cancel_url' => 'https://mydomain.co.za/Cancel',
'notify_url' => 'https://mydomain.co.za/itn',
],
'hosts' => [
'www.payfast.co.za',
'sandbox.payfast.co.za',
'w1w.payfast.co.za',
'w2w.payfast.co.za',
]
];
This是我找到的唯一软件包。