Strip Mini checkout to amount-only and use vendor email for Paystack.
Deploy Ladill Mini / deploy (push) Successful in 30s
Deploy Ladill Mini / deploy (push) Successful in 30s
Customers enter an amount and tap Pay; the merchant's account email (or notifications email from settings) is passed to Paystack instead of asking the payer for details. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,6 +17,7 @@ class PaymentController extends Controller
|
||||
public function pay(Request $request, string $shortCode): RedirectResponse
|
||||
{
|
||||
$qrCode = QrCode::query()
|
||||
->with('user.qrSetting')
|
||||
->where('short_code', $shortCode)
|
||||
->where('type', QrCode::TYPE_PAYMENT)
|
||||
->where('is_active', true)
|
||||
@@ -24,10 +25,6 @@ class PaymentController extends Controller
|
||||
|
||||
$validated = $request->validate([
|
||||
'amount' => 'required|numeric|min:0.01',
|
||||
'payer_email' => 'required|email|max:255',
|
||||
'payer_name' => 'nullable|string|max:120',
|
||||
'payer_phone' => 'nullable|string|max:32',
|
||||
'payer_note' => 'nullable|string|max:255',
|
||||
]);
|
||||
|
||||
try {
|
||||
|
||||
@@ -19,7 +19,7 @@ class MiniPaymentService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @param array{payer_name?: string, payer_email: string, payer_phone?: string, payer_note?: string, amount: float} $data
|
||||
* @param array{amount: float} $data
|
||||
* @return array{payment: MiniPayment, checkout_url: string}
|
||||
*/
|
||||
public function initiate(QrCode $qrCode, array $data): array
|
||||
@@ -33,9 +33,11 @@ class MiniPaymentService
|
||||
throw new RuntimeException('Enter an amount greater than zero.');
|
||||
}
|
||||
|
||||
$email = trim((string) ($data['payer_email'] ?? ''));
|
||||
$qrCode->loadMissing('user.qrSetting');
|
||||
$merchant = $qrCode->user;
|
||||
$email = trim((string) ($merchant?->qrSetting?->notify_email ?: $merchant?->email));
|
||||
if ($email === '' || ! str_contains($email, '@')) {
|
||||
throw new RuntimeException('Enter a valid email address.');
|
||||
throw new RuntimeException('This payment QR is not ready yet — the vendor must add an email in Ladill Mini settings.');
|
||||
}
|
||||
|
||||
$amountMinor = (int) round($amountGhs * 100);
|
||||
@@ -48,10 +50,10 @@ class MiniPaymentService
|
||||
'reference' => $reference,
|
||||
'amount_minor' => $amountMinor,
|
||||
'currency' => $qrCode->content()['currency'] ?? 'GHS',
|
||||
'payer_name' => trim((string) ($data['payer_name'] ?? '')) ?: null,
|
||||
'payer_email' => $email,
|
||||
'payer_phone' => trim((string) ($data['payer_phone'] ?? '')) ?: null,
|
||||
'payer_note' => trim((string) ($data['payer_note'] ?? '')) ?: null,
|
||||
'payer_name' => null,
|
||||
'payer_email' => null,
|
||||
'payer_phone' => null,
|
||||
'payer_note' => null,
|
||||
'status' => MiniPayment::STATUS_PENDING,
|
||||
'payment_reference' => $payRef,
|
||||
]);
|
||||
@@ -111,7 +113,7 @@ class MiniPaymentService
|
||||
'pay',
|
||||
$paymentReference,
|
||||
$payment->id,
|
||||
sprintf('Payment via %s — %s', $businessName, $payment->payer_name ?: 'Customer'),
|
||||
sprintf('Payment via %s', $businessName),
|
||||
);
|
||||
|
||||
if ($payment->payer_phone) {
|
||||
|
||||
Reference in New Issue
Block a user