Two-step add-funds modal instead of wallet redirect on insufficient balance
Deploy Ladill QR Plus / deploy (push) Successful in 40s
Deploy Ladill QR Plus / deploy (push) Successful in 40s
When a user hits an action they can't afford (e.g. creating a QR code with 0/low balance), open an in-app two-step modal instead of bouncing them to the central wallet page. Step 1 explains pay-as-you-go billing + shows the action cost and current balance; step 2 takes an amount and starts a Paystack checkout via the central identity wallet-topup API, returning the user where they were. - service-topup-modal: rebuilt as two-step (billing explainer -> amount/pay) - IdentityClient::walletTopup + WalletTopupController + POST /wallet/topup - balanceGate.openTopup / qrCustomizer.redirectTopup now prefer the modal, falling back to the wallet page only when no modal is wired - qr-codes index + create render the modal and open it on insufficient balance Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
bbef00b2f0
commit
73faa20fff
@@ -43,6 +43,24 @@ class IdentityClient
|
||||
return (array) $response->json('data', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a central-wallet Paystack top-up for an account and return the
|
||||
* Paystack checkout URL. Backs the in-app "Add funds" modal so users top up
|
||||
* without leaving the app for the central wallet page.
|
||||
*/
|
||||
public function walletTopup(string $publicId, float $amount, string $returnUrl): string
|
||||
{
|
||||
$response = $this->request()->post($this->url('/identity/wallet-topup-account'), [
|
||||
'user' => $publicId,
|
||||
'amount' => $amount,
|
||||
'return_url' => $returnUrl,
|
||||
]);
|
||||
|
||||
$response->throw();
|
||||
|
||||
return (string) $response->json('data.checkout_url', '');
|
||||
}
|
||||
|
||||
private function request()
|
||||
{
|
||||
return Http::withToken((string) config('identity.api_key'))
|
||||
|
||||
Reference in New Issue
Block a user