我具有处理我的应用程序中的付款的功能。当我将Request $request
更改为PropertyPaymentRequest $request
时,有什么原因吗?
public function ProcessAdvertPayment(Property $property, PropertyPaymentRequest $request)
{
$payload = $request->input('payload', false);
$nonce = $payload['nonce'];
$payment = Braintree_Transaction::sale([
'amount' => 1,
'paymentMethodNonce' => $nonce,
'creditCard' => [
'number' => request('cardnumber'), 'expirationDate' => request('month').'/'.request('year'),
"cvv" => request('cvv')
],
]);
if ($payment->success) {
$property->payment()->create($request);
}
return response()->json($payment);
}
请求的导入
use App\Http\Requests\PropertyPaymentRequest;
路线
Route::prefix('advertisement')->group(function () {
Route::post('{property}/payment', 'API\PropertyController@ProcessAdvertPayment');
});