Forms Example
Forms Example
Create a payment form where customers can enter their order and billing information before initiating the payment. This is example form. You need to modify it to fit your application's requirements.
resources/views/payment/form.blade.php
You need to create a new form view in your Laravel application to handle the payment form submission.
bash
<!DOCTYPE html>
<html>
<head>
<title>bKash Payment</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-header bg-success text-white">
<h4>Pay with bKash</h4>
</div>
<div class="card-body">
@if(session('error'))
<div class="alert alert-danger">{{ session('error') }}</div>
@endif
<form action="{{ route('payment.initiate') }}" method="POST">
@csrf
<div class="mb-3">
<label class="form-label">Amount (BDT)</label>
<input type="number" name="amount" class="form-control"
required min="1" value="100">
</div>
<div class="mb-3">
<label class="form-label">Invoice Number</label>
<input type="text" name="invoice_number" class="form-control"
required value="INV-{{ time() }}">
</div>
<div class="mb-3">
<label class="form-label">Description (Optional)</label>
<input type="text" name="description" class="form-control"
placeholder="Payment description" value=" Payment">
</div>
<button type="submit" class="btn btn-success w-100">Pay Now</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>resources/views/payment/success.blade.php
You need to create a new view in resources/views/payment/success.blade.php to display the success form in your application.
bash
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
Success
</body>
</html>resources/views/payment/fail.blade.php
You need to create a new view in resources/views/payment/fail.blade.php to display the fail form in your application.
bash
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
Failed
</body>
</html>resources/views/payment/cancel.blade.php
You need to create a new view in resources/views/payment/cancel.blade.php to display the cancel form in your application.
bash
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
Cancel
</body>
</html>