Embed POS checkouts in a modal/sheet using the seller email.
Deploy Ladill POS / deploy (push) Successful in 40s

Card/MoMo always initializes with the merchant email, and Paystack/Flutterwave/Hubtel open in-page (desktop modal, mobile bottomsheet) instead of a full redirect.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-15 08:29:07 +00:00
co-authored by Cursor
parent 3ea9fdfe33
commit 3c0172f098
10 changed files with 230 additions and 35 deletions
+28 -12
View File
@@ -7,7 +7,6 @@ use App\Models\PosLocation;
use App\Models\PosProduct;
use App\Models\PosSale;
use App\Models\User;
use App\Services\Pay\PayClient;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
@@ -122,27 +121,44 @@ class PosRegisterTest extends TestCase
$this->assertSame(2000, $sale->total_minor);
}
public function test_pay_sale_redirects_to_checkout(): void
public function test_pay_sale_opens_embedded_checkout(): void
{
$user = $this->user();
$this->mock(PayClient::class, function ($mock) {
$mock->shouldReceive('createCheckout')->once()->andReturn([
'id' => 99,
'reference' => 'LP-TESTREF',
'checkout_url' => 'https://checkout.paystack.com/test',
]);
});
\App\Models\PaymentGatewaySetting::create([
'owner_ref' => $user->public_id,
'provider' => \App\Models\PaymentGatewaySetting::PROVIDER_PAYSTACK,
'public_key' => 'pk_test',
'secret_key' => 'sk_test',
'is_active' => true,
]);
$this->actingAs($user)->post(route('pos.register.charge'), [
Http::fake([
'crm.test/api/customers*' => Http::response(['data' => []], 200),
'https://api.paystack.co/transaction/initialize' => Http::response([
'status' => true,
'data' => [
'authorization_url' => 'https://checkout.paystack.com/test',
'reference' => 'POSS-TESTREF',
],
], 200),
]);
$response = $this->actingAs($user)->post(route('pos.register.charge'), [
'payment_method' => 'pay',
'lines' => [
['name' => 'Snack', 'unit_price_minor' => 500, 'quantity' => 1],
],
])->assertRedirect('https://checkout.paystack.com/test');
]);
$sale = PosSale::where('owner_ref', $user->public_id)->first();
$this->assertSame('LP-TESTREF', $sale->payment_reference);
$this->assertNotNull($sale);
$response->assertRedirect(route('pos.sales.show', $sale));
$response->assertSessionHas('checkout_url', 'https://checkout.paystack.com/test');
$this->assertSame(PosSale::STATUS_PENDING, $sale->status);
$this->assertNotEmpty($sale->payment_reference);
Http::assertSent(fn ($r) => str_contains($r->url(), 'paystack.co')
&& ($r['email'] ?? null) === $user->email);
}
}