Keep Mini QR Paystack checkout fully in-app.
Stop form POSTs from 307ing to ladl.link or redirecting away to checkout.paystack.com, open Paystack Inline with access_code, and use the single-chrome sheet so payment stays on the Mini page.
This commit is contained in:
@@ -44,13 +44,15 @@ class MiniPaymentCheckoutTest extends TestCase
|
||||
->assertSee('md:items-center', false)
|
||||
->assertSee('Complete your payment', false)
|
||||
->assertSee('data-ladill-pay-sheet', false)
|
||||
->assertSee('data-ladill-pay-loading', false)
|
||||
->assertSee('resumeTransaction', false)
|
||||
->assertSee('/q/'.$qr->short_code.'/pay', false)
|
||||
->assertDontSee('https://ladl.link/'.$qr->short_code.'/pay', false)
|
||||
->assertDontSee('MTN MoMo number', false)
|
||||
->assertDontSee('Pay with MTN MoMo', false)
|
||||
->assertDontSee('Continue to Paystack', false)
|
||||
->assertDontSee('Paystack checkout', false);
|
||||
->assertDontSee('Paystack checkout', false)
|
||||
->assertDontSee('window.location.assign(data.checkout_url)', false);
|
||||
}
|
||||
|
||||
public function test_json_pay_post_is_not_redirected_to_ladill_link(): void
|
||||
@@ -101,6 +103,55 @@ class MiniPaymentCheckoutTest extends TestCase
|
||||
->assertJsonPath('provider', 'paystack');
|
||||
}
|
||||
|
||||
public function test_html_pay_post_does_not_redirect_browser_to_paystack(): void
|
||||
{
|
||||
$user = User::create([
|
||||
'public_id' => (string) Str::uuid(),
|
||||
'name' => 'Vendor',
|
||||
'email' => 'vendor-html@example.com',
|
||||
]);
|
||||
|
||||
$qr = QrCode::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'short_code' => 'payhtml01',
|
||||
'type' => QrCode::TYPE_PAYMENT,
|
||||
'label' => 'Till',
|
||||
'payload' => [
|
||||
'content' => [
|
||||
'business_name' => 'Accra Kiosk',
|
||||
'currency' => 'GHS',
|
||||
],
|
||||
'style' => [],
|
||||
],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$pay = Mockery::mock(PayClient::class);
|
||||
$pay->shouldReceive('createCheckout')
|
||||
->once()
|
||||
->andReturn([
|
||||
'id' => 101,
|
||||
'reference' => 'LP-TESTMINIHtml01',
|
||||
'checkout_url' => 'https://checkout.paystack.com/mini-html',
|
||||
'access_code' => 'mini-html',
|
||||
'public_key' => 'pk_test_x',
|
||||
'provider' => 'paystack',
|
||||
'platform_fee_minor' => 15,
|
||||
'merchant_amount_minor' => 985,
|
||||
]);
|
||||
$this->app->instance(PayClient::class, $pay);
|
||||
|
||||
// HTML form POST (no Accept: application/json) must stay on Mini and
|
||||
// must not 307 to ladl.link or away to checkout.paystack.com.
|
||||
$this->post('/q/'.$qr->short_code.'/pay', [
|
||||
'amount' => 10,
|
||||
])
|
||||
->assertRedirect(url('/q/'.$qr->short_code))
|
||||
->assertSessionHas('checkout_url', 'https://checkout.paystack.com/mini-html')
|
||||
->assertSessionHas('access_code', 'mini-html')
|
||||
->assertSessionMissing('error');
|
||||
}
|
||||
|
||||
public function test_pay_initiation_does_not_require_phone_and_returns_paystack_checkout(): void
|
||||
{
|
||||
$user = User::create([
|
||||
|
||||
@@ -28,11 +28,13 @@ class ResponsivePaystackSheetTest extends TestCase
|
||||
$this->assertStringContainsString('LadillPayCheckout', $html);
|
||||
$this->assertStringContainsString('resumeTransaction', $html);
|
||||
$this->assertStringContainsString('js.paystack.co/v2/inline.js', $html);
|
||||
$this->assertStringContainsString('Starting secure checkout', $html);
|
||||
$this->assertStringContainsString('not in a separate browser', $html);
|
||||
$this->assertStringContainsString('Opening payment', $html);
|
||||
$this->assertStringContainsString('data-ladill-pay-loading', $html);
|
||||
$this->assertStringContainsString('pointer-events-none', $html);
|
||||
// Must not push Paystack to a separate browser as the primary path.
|
||||
$this->assertStringNotContainsString('Continue to Paystack', $html);
|
||||
$this->assertStringNotContainsString('window.open(', $html);
|
||||
$this->assertStringNotContainsString('Complete payment in the Paystack window', $html);
|
||||
// Must not use Tailwind `hidden` + x-show on the panel (desktop stays invisible).
|
||||
$this->assertStringNotContainsString('hidden w-full max-w-lg', $html);
|
||||
$this->assertStringNotContainsString('Paystack checkout', $html);
|
||||
|
||||
Reference in New Issue
Block a user