Skip to content

Commit dd4e207

Browse files
committed
test(payments): keep Stripe webhook creation out of CI runs
With real Stripe test credentials now present in CI, the previously skipped payment tests started running - and every path that registers a webhook endpoint against the real Stripe API died with "Can not create the Stripe Webhook": Stripe rejects non-publicly-accessible URLs server-side (verified empirically: WebhookEndpoint::create with the CI APP_URL fails with "Invalid URL: URL must be publicly accessible"), so no localhost environment can ever exercise webhook creation, regardless of local configuration. Two treatments: - OAuth2SummitOrdersApiTest: the payment profile is built with pre-seeded webhook data (set_webhooks + test_web_hook_secret from the TEST_STRIPE_WEBHOOK_SECRET secret), the factory's escape hatch for pre-existing webhooks - activate()->buildWebHook() then short-circuits on existsWebHook() and never calls Stripe. This lets testReserveWithActivePaymentProfile actually exercise the paid reservation flow (real PaymentIntent in test mode) in CI. - OAuth2PaymentGatewayProfileApiTest (add/update/delete): profile creation through the API always registers a webhook endpoint (the API validation rules accept no pre-seeded webhook data), so these tests are environment-gated: they now also skip when APP_URL is localhost, with the real reason documented. They run only against an environment with a publicly routable URL.
1 parent 09662ff commit dd4e207

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

tests/oauth2/OAuth2PaymentGatewayProfileApiTest.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ public function testAddProfileFail(){
160160

161161

162162
public function testAddProfileOK(){
163-
if (self::$test_secret_key === 'sk_test_dummy_key') {
164-
$this->markTestSkipped('Valid Stripe test credentials required (TEST_STRIPE_SECRET_KEY env var).');
163+
if (self::$test_secret_key === 'sk_test_dummy_key' || str_contains((string)env('APP_URL'), 'localhost')) {
164+
// profile creation through the API always registers a webhook endpoint
165+
// against the real Stripe API, and Stripe rejects non-public URLs -
166+
// this flow cannot run from CI (APP_URL=localhost)
167+
$this->markTestSkipped('Valid Stripe test credentials and a publicly accessible APP_URL are required (webhook creation hits the real Stripe API).');
165168
}
166169
$params = [
167170
'id' => self::$summit->getId(),
@@ -202,8 +205,11 @@ public function testAddProfileOK(){
202205
}
203206

204207
public function testUpdateOK(){
205-
if (self::$test_secret_key === 'sk_test_dummy_key') {
206-
$this->markTestSkipped('Valid Stripe test credentials required (TEST_STRIPE_SECRET_KEY env var).');
208+
if (self::$test_secret_key === 'sk_test_dummy_key' || str_contains((string)env('APP_URL'), 'localhost')) {
209+
// profile creation through the API always registers a webhook endpoint
210+
// against the real Stripe API, and Stripe rejects non-public URLs -
211+
// this flow cannot run from CI (APP_URL=localhost)
212+
$this->markTestSkipped('Valid Stripe test credentials and a publicly accessible APP_URL are required (webhook creation hits the real Stripe API).');
207213
}
208214
$params = [
209215
'id' => self::$summit->getId(),
@@ -276,8 +282,11 @@ public function testUpdateOK(){
276282
}
277283

278284
public function testDelete(){
279-
if (self::$test_secret_key === 'sk_test_dummy_key') {
280-
$this->markTestSkipped('Valid Stripe test credentials required (TEST_STRIPE_SECRET_KEY env var).');
285+
if (self::$test_secret_key === 'sk_test_dummy_key' || str_contains((string)env('APP_URL'), 'localhost')) {
286+
// profile creation through the API always registers a webhook endpoint
287+
// against the real Stripe API, and Stripe rejects non-public URLs -
288+
// this flow cannot run from CI (APP_URL=localhost)
289+
$this->markTestSkipped('Valid Stripe test credentials and a publicly accessible APP_URL are required (webhook creation hits the real Stripe API).');
281290
}
282291

283292
$params = [

tests/oauth2/OAuth2SummitOrdersApiTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ protected function setUp():void
7676
'test_publishable_key' => self::$test_public_key,
7777
'test_secret_key' => self::$test_secret_key,
7878
'is_active' => false,
79+
// pre-seed the webhook data so activate()->buildWebHook() never tries to
80+
// register a webhook endpoint against the real Stripe API - CI's APP_URL
81+
// (localhost) is not publicly routable, so Stripe would reject it
82+
'set_webhooks' => true,
83+
'test_web_hook_secret' => env('TEST_STRIPE_WEBHOOK_SECRET', 'whsec_dummy'),
7984
]);
8085

8186
// build default badge type

0 commit comments

Comments
 (0)