此帖子弹出按钮
<a href="#small-dialog-1" onclick="moveprice({{ $bid->id}}), payment({{ $bid->id}})" class="popup-with-zoom-anim button ripple-effect"><i class="icon-material-outline-check"></i> Accept Offer</a>
这是带有表单的弹出窗口
<div id="small-dialog-1" class="zoom-anim-dialog mfp-hide dialog-with-tabs">
<!--Tabs -->
<div class="sign-in-form">
<ul class="popup-tabs-nav">
<li><a href="#tab1">Accept Offer</a></li>
</ul>
<div class="popup-tabs-container">
<!-- Tab -->
<div class="popup-tab-content" id="tab">
<!-- Welcome Text -->
<div class="welcome-text">
<h3>Accept Offer From David</h3>
<div class="bid-acceptance margin-top-15">
<span id="test"></span>
</div>
</div>
<script src="https://js.stripe.com/v3/"></script>
<form method="post" id="payment-form" action="{{url('/charge-payment')}}">
@csrf
@foreach($bidder as $key=> $detail)
{{--<input type="hidden" name="post_price" id="post_price">--}}
<input type="hidden" name="bid_price[]" class="removeLater" value="{{$detail->bid_price}}">
<input type="hidden" name="post_id[]" class="removeLater" value="{{$detail->post_id}}">
<input type="hidden" name="tutor_id[]" class="removeLater" value="{{$detail->tutor_id}}">
@endforeach
<div class="form-row">
<label for="card-element">
Credit or debit card
</label>
<div id="card-element">
<!-- A Stripe Element will be inserted here. -->
</div>
<!-- Used to display form errors. -->
<div id="card-errors" role="alert"></div>
</div>
{{-- @dd($bid->bid_price)--}}
<button class="margin-top-15 button full-width button-sliding-icon ripple-effect" >Submit Payment<i class="icon-material-outline-arrow-right-alt"></i></button>
</form>
</div>
</div>
</div>
</div>
这是控制者
public function charge(Request $request)
{
// dd($request);
foreach ($request->bid_price as $approver) {
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey('sk_test_dd1nMs2PEqbGLOF6SpsDIl0c00QPcwncXY');
// Token is created using Checkout or Elements!
// Get the payment token ID submitted by the form:
$token = $_POST['stripeToken'];
$charge = \Stripe\Charge::create([
'amount' =>60,
'currency' => 'usd',
'description' => 'Example charge',
'source' => $token,
]);
$id = Auth::user()->id;
$payment = new Payment();
// $payment->tutor_id = $request->tutor_id;
$payment->user_id = $id;
// $payment->post_id = $request->post_id;
$payment->amount =$charge->amount;
$payment->save();
return redirect()->back();
}
}
我尝试在具有相关帖子控制器的控制器中使用onclick按钮发布弹出表单发送请求,但是控制器接收具有多个帖子数据的请求,但是我需要一个请求接收相关帖子数据。如果我单击另一个帖子请求则接收具有相关帖子数据。