[ {"fn":"createCheckoutSession","name":"stripe: a one-off payment with email, reference, metadata and an idempotency key","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[{"price":"price_1PzTshirt","quantity":2},{"price":"price_1PzMug","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart","customerEmail":"ada@example.com","clientReferenceId":"order_42","metadata":{"cart":"c_9","channel":"web"},"idempotencyKey":"order_42-attempt-1"}],"exchanges":[{"request":{"method":"POST","url":"https://api.stripe.com/v1/checkout/sessions","headers":{"authorization":"Bearer sk_test_51NcFakeKeyForContractTests0000","content-type":"application/x-www-form-urlencoded","idempotency-key":"order_42-attempt-1"},"form":{"mode":"payment","line_items[0][price]":"price_1PzTshirt","line_items[0][quantity]":"2","line_items[1][price]":"price_1PzMug","line_items[1][quantity]":"1","success_url":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancel_url":"https://shop.example/cart","customer_email":"ada@example.com","client_reference_id":"order_42","metadata[cart]":"c_9","metadata[channel]":"web"}},"response":{"status":200,"json":{"id":"cs_test_a1B2c3","object":"checkout.session","mode":"payment","url":"https://checkout.stripe.com/c/pay/cs_test_a1B2c3#fidkdWxOYHwnPyd1blpxYHZxWjA0"}}}],"expect":{"provider":"stripe","id":"cs_test_a1B2c3","url":"https://checkout.stripe.com/c/pay/cs_test_a1B2c3#fidkdWxOYHwnPyd1blpxYHZxWjA0"}}, {"fn":"createCheckoutSession","name":"stripe: a subscription, nothing optional","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"subscription","items":[{"price":"price_1PzProMonthly","quantity":1}],"successUrl":"https://app.example/billing/done","cancelUrl":"https://app.example/billing"}],"exchanges":[{"request":{"method":"POST","url":"https://api.stripe.com/v1/checkout/sessions","body":"mode=subscription&line_items%5B0%5D%5Bprice%5D=price_1PzProMonthly&line_items%5B0%5D%5Bquantity%5D=1&success_url=https%3A%2F%2Fapp.example%2Fbilling%2Fdone&cancel_url=https%3A%2F%2Fapp.example%2Fbilling"},"response":{"status":200,"json":{"id":"cs_test_sub9","object":"checkout.session","mode":"subscription","url":"https://checkout.stripe.com/c/pay/cs_test_sub9"}}}],"expect":{"provider":"stripe","id":"cs_test_sub9","url":"https://checkout.stripe.com/c/pay/cs_test_sub9"}}, {"fn":"createCheckoutSession","name":"stripe: an unknown price is thrown with Stripe's code, message and parameter","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[{"price":"price_x","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"exchanges":[{"request":{"method":"POST","url":"https://api.stripe.com/v1/checkout/sessions"},"response":{"status":400,"json":{"error":{"type":"invalid_request_error","code":"resource_missing","message":"No such price: 'price_x'","param":"line_items[0][price]"}}}}],"expectError":"stripe refused the checkout session (400 resource_missing, param line_items[0][price]): No such price: 'price_x'"}, {"fn":"createCheckoutSession","name":"stripe: a refused key names the variable","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_revoked","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[{"price":"price_1PzMug","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"exchanges":[{"request":{"method":"POST","url":"https://api.stripe.com/v1/checkout/sessions","headers":{"authorization":"Bearer sk_test_revoked"}},"response":{"status":401,"json":{"error":{"type":"invalid_request_error","message":"Invalid API Key provided: sk_test_*******oked"}}}}],"expectError":"stripe refused STRIPE_SECRET_KEY (401): Invalid API Key provided"}, {"fn":"createCheckoutSession","name":"stripe: no secret key set","provider":"stripe","env":{"STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[{"price":"price_1PzMug","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"STRIPE_SECRET_KEY is not set"}, {"fn":"createCheckoutSession","name":"local: a session on the machine, its id in the success URL","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only","LOCAL_CHECKOUT_URL":"http://localhost:5173/dev/checkout"},"random":"a1b2c3d4e5f60718293a4b5c","args":[{"mode":"payment","items":[{"price":"price_1PzMug","quantity":3}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expect":{"provider":"local","id":"cs_local_a1b2c3d4e5f60718293a4b5c","url":"http://localhost:5173/dev/checkout?session=cs_local_a1b2c3d4e5f60718293a4b5c&success_url=https%3A%2F%2Fshop.example%2Fthanks%3Fsession%3Dcs_local_a1b2c3d4e5f60718293a4b5c&cancel_url=https%3A%2F%2Fshop.example%2Fcart"}}, {"fn":"createCheckoutSession","name":"local: the default checkout page","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"args":[{"mode":"subscription","items":[{"price":"price_1PzProMonthly","quantity":1}],"successUrl":"https://app.example/done","cancelUrl":"https://app.example/billing"}],"expect":{"provider":"local","id":"cs_local_000102030405060708090a0b","url":"http://localhost:3000/dev/checkout?session=cs_local_000102030405060708090a0b&success_url=https%3A%2F%2Fapp.example%2Fdone&cancel_url=https%3A%2F%2Fapp.example%2Fbilling"}}, {"fn":"createCheckoutSession","name":"stripe: a one-off payment with a Price id and a custom item by name, amount and currency","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[{"price":"price_1PzMug","quantity":1}],"customItems":[{"name":"Gift wrap","amount":350,"currency":"GBP","quantity":2}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"exchanges":[{"request":{"method":"POST","url":"https://api.stripe.com/v1/checkout/sessions","headers":{"authorization":"Bearer sk_test_51NcFakeKeyForContractTests0000","content-type":"application/x-www-form-urlencoded"},"body":"mode=payment&line_items%5B0%5D%5Bprice%5D=price_1PzMug&line_items%5B0%5D%5Bquantity%5D=1&line_items%5B1%5D%5Bprice_data%5D%5Bcurrency%5D=gbp&line_items%5B1%5D%5Bprice_data%5D%5Bunit_amount%5D=350&line_items%5B1%5D%5Bprice_data%5D%5Bproduct_data%5D%5Bname%5D=Gift%20wrap&line_items%5B1%5D%5Bquantity%5D=2&success_url=https%3A%2F%2Fshop.example%2Fthanks%3Fsession%3D%7BCHECKOUT_SESSION_ID%7D&cancel_url=https%3A%2F%2Fshop.example%2Fcart"},"response":{"status":200,"json":{"id":"cs_test_inline7","object":"checkout.session","mode":"payment","url":"https://checkout.stripe.com/c/pay/cs_test_inline7"}}}],"expect":{"provider":"stripe","id":"cs_test_inline7","url":"https://checkout.stripe.com/c/pay/cs_test_inline7"}}, {"fn":"createCheckoutSession","name":"stripe: a one-off payment of only custom items, no Price ids","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[],"customItems":[{"name":"Consultation, 1 hour","amount":12000,"currency":"usd","quantity":1}],"successUrl":"https://app.example/paid","cancelUrl":"https://app.example/book"}],"exchanges":[{"request":{"method":"POST","url":"https://api.stripe.com/v1/checkout/sessions","form":{"mode":"payment","line_items[0][price_data][currency]":"usd","line_items[0][price_data][unit_amount]":"12000","line_items[0][price_data][product_data][name]":"Consultation, 1 hour","line_items[0][quantity]":"1","success_url":"https://app.example/paid","cancel_url":"https://app.example/book"}},"response":{"status":200,"json":{"id":"cs_test_named1","object":"checkout.session","mode":"payment","url":"https://checkout.stripe.com/c/pay/cs_test_named1"}}}],"expect":{"provider":"stripe","id":"cs_test_named1","url":"https://checkout.stripe.com/c/pay/cs_test_named1"}}, {"fn":"createCheckoutSession","name":"local: custom items make a session like any other","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"args":[{"mode":"payment","items":[],"customItems":[{"name":"Gift wrap","amount":350,"currency":"gbp","quantity":1}],"successUrl":"https://app.example/done","cancelUrl":"https://app.example/cart"}],"expect":{"provider":"local","id":"cs_local_000102030405060708090a0b","url":"http://localhost:3000/dev/checkout?session=cs_local_000102030405060708090a0b&success_url=https%3A%2F%2Fapp.example%2Fdone&cancel_url=https%3A%2F%2Fapp.example%2Fcart"}}, {"fn":"createCheckoutSession","name":"a subscription with custom items","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"subscription","items":[{"price":"price_1PzProMonthly","quantity":1}],"customItems":[{"name":"Setup","amount":900,"currency":"gbp","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"customItems are for one-off payments: a subscription's items are Price ids (price_...)"}, {"fn":"createCheckoutSession","name":"no items and no custom items","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[],"customItems":[],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"a checkout needs at least one item"}, {"fn":"createCheckoutSession","name":"a custom item without a currency","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[],"customItems":[{"name":"Mug","amount":900,"quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"customItems[0].currency undefined is not a three-letter currency code, such as gbp"}, {"fn":"createCheckoutSession","name":"a custom item with an amount in pounds, not pence","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[],"customItems":[{"name":"Mug","amount":9.5,"currency":"gbp","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"customItems[0].amount is a whole number of the currency's minor unit (pence, cents), 0 or more"}, {"fn":"createCheckoutSession","name":"a custom item with an empty name","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[],"customItems":[{"name":" ","amount":900,"currency":"gbp","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"customItems[0].name is the text the buyer sees, not empty"}, {"fn":"createCheckoutSession","name":"a custom item with a quantity of 0","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[],"customItems":[{"name":"Mug","amount":900,"currency":"gbp","quantity":0}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"customItems[0].quantity is a whole number, 1 or more"}, {"fn":"createCheckoutSession","name":"no items is refused before anything is sent","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"a checkout needs at least one item"}, {"fn":"createCheckoutSession","name":"a quantity of 0","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"args":[{"mode":"payment","items":[{"price":"price_1PzMug","quantity":0}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"items[0].quantity is a whole number, 1 or more"}, {"fn":"createCheckoutSession","name":"a relative success URL","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[{"price":"price_1PzMug","quantity":1}],"successUrl":"/thanks","cancelUrl":"https://shop.example/cart"}],"expectError":"successUrl is an absolute http(s) URL"}, {"fn":"createCheckoutSession","name":"an unknown mode","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"setup","items":[{"price":"price_1PzMug","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"mode is \"payment\" or \"subscription\""}, {"fn":"createCheckoutSession","name":"no provider chosen","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":[{"mode":"payment","items":[{"price":"price_1PzMug","quantity":1}],"successUrl":"https://shop.example/thanks?session={CHECKOUT_SESSION_ID}","cancelUrl":"https://shop.example/cart"}],"expectError":"PAYMENTS_PROVIDER is not set; set it to one of stripe, local"}, {"fn":"verifyWebhook","name":"stripe: a signed checkout.session.completed","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","t=1772366395,v1=ce9cf61959a8b08333bdb9159cbc281f9ae2fe2dc8cf124803674547f51c591b"],"expect":{"id":"evt_1PzFake0001","type":"checkout.session.completed","created":1772366395,"livemode":false,"object":{"id":"cs_test_a1B2c3","object":"checkout.session","payment_status":"paid","client_reference_id":"order_42","amount_total":2400,"currency":"gbp"}}}, {"fn":"verifyWebhook","name":"local: signed the same way, with the local secret","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_local_0002\",\"object\":\"event\",\"type\":\"customer.subscription.created\",\"created\":1772366400,\"livemode\":false,\"data\":{\"object\":{\"id\":\"sub_local_1\",\"status\":\"active\"}}}","t=1772366400,v1=ce66ae7d98c9d0887d953688691a0f6c995f9bc146a7879ae20cb547180ebae3"],"expect":{"id":"evt_local_0002","type":"customer.subscription.created","created":1772366400,"livemode":false,"object":{"id":"sub_local_1","status":"active"}}}, {"fn":"verifyWebhook","name":"stripe: two v1 signatures while the secret is rolled, the second matching","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","t=1772366395,v1=f2d355ec6f406bf5b9c25662d6f1bb785ae430ae9476ee307dbe145b8e0aa6b1,v1=ce9cf61959a8b08333bdb9159cbc281f9ae2fe2dc8cf124803674547f51c591b,v0=6ffbb59b2300aae63f272406069a9788598b792a944a07aba816edb039989a39"],"expect":{"id":"evt_1PzFake0001","type":"checkout.session.completed","created":1772366395,"livemode":false,"object":{"id":"cs_test_a1B2c3","object":"checkout.session","payment_status":"paid","client_reference_id":"order_42","amount_total":2400,"currency":"gbp"}}}, {"fn":"verifyWebhook","name":"stripe: a changed payload fails","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":1,\"currency\":\"gbp\"}}}","t=1772366395,v1=ce9cf61959a8b08333bdb9159cbc281f9ae2fe2dc8cf124803674547f51c591b"],"expectError":"no v1 signature matches"}, {"fn":"verifyWebhook","name":"local: signed with another secret","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_local_0002\",\"object\":\"event\",\"type\":\"customer.subscription.created\",\"created\":1772366400,\"livemode\":false,\"data\":{\"object\":{\"id\":\"sub_local_1\",\"status\":\"active\"}}}","t=1772366400,v1=a5c097940474ff08ed4427b0726d7b2e0a13b756fd56e02f9f913c35f5340eb4"],"expectError":"no v1 signature matches"}, {"fn":"verifyWebhook","name":"stripe: an old signature is a replay","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","t=1772365800,v1=c5aad6ea4511d6fbbd00b3f74c029c8db64c6841f9198f7575c68c3cc75acdc2"],"expectError":"signed 600 seconds from now, more than the 300 allowed"}, {"fn":"verifyWebhook","name":"stripe: a wider tolerance lets it through","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","t=1772365800,v1=c5aad6ea4511d6fbbd00b3f74c029c8db64c6841f9198f7575c68c3cc75acdc2",900],"expect":{"id":"evt_1PzFake0001","type":"checkout.session.completed","created":1772366395,"livemode":false,"object":{"id":"cs_test_a1B2c3","object":"checkout.session","payment_status":"paid","client_reference_id":"order_42","amount_total":2400,"currency":"gbp"}}}, {"fn":"verifyWebhook","name":"a header without v1","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","t=1772366400"],"expectError":"the Stripe-Signature header has no v1 signature"}, {"fn":"verifyWebhook","name":"a header without t","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","v1=945f08dc95c6b6ddeca6c21c6f6ea1a80911d4fe7a4f39ec32a2861123d50db8"],"expectError":"the Stripe-Signature header has no timestamp"}, {"fn":"verifyWebhook","name":"signed, but not JSON","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"now":"2026-03-01T12:00:00Z","args":["not json","t=1772366400,v1=46fdb387bc2ef316054dacb9c6f4d5ff026c2b527818f46f9a5eed5042e6c70f"],"expectError":"the payload is signed but is not JSON"}, {"fn":"verifyWebhook","name":"no webhook secret set","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","t=1772366400,v1=945f08dc95c6b6ddeca6c21c6f6ea1a80911d4fe7a4f39ec32a2861123d50db8"],"expectError":"STRIPE_WEBHOOK_SECRET is not set"}, {"fn":"verifyWebhook","name":"a tolerance of 0","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}","t=1772366400,v1=945f08dc95c6b6ddeca6c21c6f6ea1a80911d4fe7a4f39ec32a2861123d50db8",0],"expectError":"toleranceSeconds is a whole number of seconds, 1 or more"}, {"fn":"signWebhook","name":"stripe: signs at the default clock","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}"],"expect":"t=1767225600,v1=32a09722e6bc81c9beb45a97053a722dcbf489865c9bf1ca6e77abfe092b9ad4"}, {"fn":"signWebhook","name":"local: signs with the local secret","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_local_0002\",\"object\":\"event\",\"type\":\"customer.subscription.created\",\"created\":1772366400,\"livemode\":false,\"data\":{\"object\":{\"id\":\"sub_local_1\",\"status\":\"active\"}}}"],"expect":"t=1772366400,v1=ce66ae7d98c9d0887d953688691a0f6c995f9bc146a7879ae20cb547180ebae3"}, {"fn":"signWebhook","name":"stripe: the time is whole seconds, rounded down","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":1772366400999,"args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}"],"expect":"t=1772366400,v1=945f08dc95c6b6ddeca6c21c6f6ea1a80911d4fe7a4f39ec32a2861123d50db8"}, {"fn":"signWebhook","name":"an empty payload is still signed","provider":"local","env":{"LOCAL_WEBHOOK_SECRET":"local-webhook-secret-for-development-only"},"now":"2026-03-01T12:00:00Z","args":[""],"expect":"t=1772366400,v1=eab97be9a0971b85b33ee11fc1b7f87997b426369b073d9fc5eded8859f182a9"}, {"fn":"signWebhook","name":"non-ASCII text is signed as UTF-8","provider":"stripe","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1\",\"type\":\"note\",\"data\":{\"object\":{\"text\":\"café ☕ — £5\"}}}"],"expect":"t=1772366400,v1=435ac2e071cc7a794b9bbf02ac8a94dff0ac5360471526bb6dc22a4f3aee84e6"}, {"fn":"signWebhook","name":"no local secret set","provider":"local","env":{},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_local_0002\",\"object\":\"event\",\"type\":\"customer.subscription.created\",\"created\":1772366400,\"livemode\":false,\"data\":{\"object\":{\"id\":\"sub_local_1\",\"status\":\"active\"}}}"],"expectError":"LOCAL_WEBHOOK_SECRET is not set"}, {"fn":"signWebhook","name":"no provider chosen","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}"],"expectError":"PAYMENTS_PROVIDER is not set"}, {"fn":"signWebhook","name":"an unknown provider","env":{"STRIPE_SECRET_KEY":"sk_test_51NcFakeKeyForContractTests0000","STRIPE_WEBHOOK_SECRET":"whsec_test_5f2b8c1d9e7a4b3c6d0e1f2a3b4c5d6e","PAYMENTS_PROVIDER":"paypal"},"now":"2026-03-01T12:00:00Z","args":["{\"id\":\"evt_1PzFake0001\",\"object\":\"event\",\"type\":\"checkout.session.completed\",\"created\":1772366395,\"livemode\":false,\"data\":{\"object\":{\"id\":\"cs_test_a1B2c3\",\"object\":\"checkout.session\",\"payment_status\":\"paid\",\"client_reference_id\":\"order_42\",\"amount_total\":2400,\"currency\":\"gbp\"}}}"],"expectError":"PAYMENTS_PROVIDER is \"paypal\"; set it to one of stripe, local"} ]