سلام دوستان
@ali.bayat @hesammousavi @Alimotreb
من یه فررم برای ثبت نام دارم جند مرحله ای می باشد که به صورت تصویر زیر است
من می خوام بعد از ثبت نام کاربر پرداخت شو انجام بدهد
protected $MerchantID = 'f83cc956-f59f-11e6-889a-005056a205be';
public function payment(Request $request)
{
$this->validate(request() , [
'register_id' => 'required'
]);
$user = User::findOrFail($request->register_id);
$price = 100;
$Description = 'توضیحات تراکنش تستی'; // Required
$Email = $user->email; // Optional
$CallbackURL = 'http://localhost:8000/marketing/payment/checker'; // Required
$client = new SoapClient('https://www.zarinpal.com/pg/services/WebGate/wsdl', ['encoding' => 'UTF-8']);
$result = $client->PaymentRequest(
[
'MerchantID' => $this->MerchantID,
'Amount' => $price,
'Description' => $Description,
'Email' => $Email,
'CallbackURL' => $CallbackURL,
]
);
//Redirect to URL You can do it also by creating a form
if ($result->Status == 100) {
$user->payments()->create([
'resnumber' => $result->Authority,
'price' => $price,
'register_id' => Input::get('register_id'),
]);
return redirect('https://www.zarinpal.com/pg/StartPay/'.$result->Authority);
} else {
echo 'ERR: ' . $result->Status;
}
}
public function checker()
{
$Authority = request('Authority');
$payment = Payment::whereResnumber($Authority)->firstOrFail();
$register_id = User::findOrFail($payment->register_id);
if (request('Status') == 'OK') {
$client = new SoapClient('https://www.zarinpal.com/pg/services/WebGate/wsdl', ['encoding' => 'UTF-8']);
$result = $client->PaymentVerification(
[
'MerchantID' => $this->MerchantID,
'Authority' => $Authority,
'Amount' => $payment->price,
]
);
if ($result->Status == 100) {
if($this->AddUserForOrder($payment, $register_id)) {
alert()->success('عملیات مورد نظر با موفقیت انجام شد','با تشکر');
return redirect()->route('home');
}
} else {
echo 'Transaction failed. Status:'.$result->Status;
}
} else {
echo 'Transaction canceled by user';
}
}
protected function AddUserForOrder($payment, $register)
{
$payment->update([
'payment' => 1
]);
Order::create([
'user_id' => auth()->id(),
'register_id' => $register->id,
]);
return true;
}
خب اول ثبت نامش کن و بعدش لاگینش کن
$user = User::create([
'namefamily' => $request->namefamily,
'email' => $request->email,
'password' => Hash::make($request->password),
'mobile' => $request->mobile,
]);
Auth::loginUsingId($user->id);
return redirect('/payment');
بعدش ریدارکت کن برای پرای پرداخت
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟