Back to Arky

Test Stores

A free, real store for building and testing, whose payments and emails run on Arky's provider simulator and are driven through the API.

A test store is a real store on the real Arky. It runs the code a live store runs, and its card payments and emails go to Arky’s provider simulator, Arky’s own Stripe, Monri and Resend, so no money moves and no mail leaves. It is free, you make one in one call, and a person or an AI agent drives it entirely through the API: pay, decline or expire a payment, and read every email, sign-in codes included.

Use one to build a site, to run browser tests, or to give an agent a store to work on. You need no copy of Arky and no fake API, and a test that passes on a test store ran the code a live store runs.

What Differs From A Live Store

A store’s mode is "live" or "test". You name it when you make the store, there is no default, and it never changes, so test data can never become live data. There are no environments inside a store: an account owns many stores, and a test store is just a store. It differs from a live store in these ways and no others:

Test storeLive store
PlanFree: it holds the test plan, with the Standard plan’s limits and at most 1,000 media files, and can’t pick or buy one (409 STORE_SUBSCRIPTION.TEST_STORE)Picks an Arky plan
How manyAt most 5 per account at a timeNo such limit
Card paymentsarky_stripe, arky_monri, stripe with test keys, monri in teststripe with live keys, monri in live
Emailarky_resend onlyresend
OwnerStays with the account that made it (409 STORE.TEST_STORE_TRANSFER)Can move to another admin
Checkout return addressMay be loopback http, for a site on your laptophttps
Simulator controlsYesRefused (409 SIMULATOR.LIVE_STORE)
Account tokensA test_stores token makes, reaches and closes itA test_stores token never makes or reaches it
ClosingNeeds no recent sign-in, so the owner’s admin token closes itNeeds a sign-in within the last 15 minutes

Cash on delivery and manual options move nothing through a provider and work in both. Real email stays out of test stores, because it would let a free test store run a real site.

The Limit

An account holds at most 5 test stores at a time, and no other cap applies. One more is refused with 409 STORE.TEST_STORE_LIMIT. A store still being deleted counts until it is gone, so closing one frees its place a little later, not at once. sdk.account.getMe() answers the count as test_stores.

Make One

POST /v1/stores
SDK: sdk.store.create()
import { createAdmin } from "arky-sdk/admin";

const sdk = createAdmin({ apiUrl: "https://api.arky.io" });

const store = await sdk.store.create({
	id: crypto.randomUUID(),
	mode: "test",
	name: "Northwind test",
	timezone: "Europe/Berlin",
	languages: ["en"],
	market: { key: "eu", currency: "eur", tax_mode: "inclusive" },
	sales_channel: { key: "web" },
	location_address: { country: "DE" },
});

Creation makes everything any store’s creation makes, including its first publishable key and its first package, keyed public, and grants the test plan in the same save. The same id with another mode is 409 GENERAL.CONFLICT.

In Admin, choose Test store when you make a store. It shows a Test store badge in place of a plan, and its payment options and email connections offer the Arky providers.

Signing in. Making a store needs an account session, which starts with a code emailed to the account (Account), or an account token. A person signs in once and makes an agent or a CI job an account token for test stores alone, holding admin, which reaches the controls below:

const agentToken = await sdk.account.token.create({
	id: crypto.randomUUID(),
	name: "Test agent",
	stores: { type: "test_stores" },
	permissions: [{ type: "admin" }],
	expires_at: null,
});
if (agentToken.type === "secret_created") console.log(agentToken.value);

const agent = createAdmin({ apiUrl: "https://api.arky.io", accountToken: process.env.ARKY_API_TOKEN });

That token makes test stores and reaches and closes them, and never makes or reaches a live store (403 ACCOUNT_TOKEN.STORE_NOT_COVERED).

Closing. sdk.store.requestDeletion closes a test store as it closes any store, with its name as the confirmation. It needs no recent sign-in, so the owner’s token holding admin closes it too.

Connect The Simulated Providers

Making a store sets up no providers, in either mode, and nothing picks one because a store is a test store. A test store with no payment option has no card payments, and one with no email connection sends no email, until your setup script connects them. Connecting takes no key: Arky opens a simulated account for the store and keeps only what it made.

POST /v1/stores/{store_id}/payment-options/arky-stripe
SDK: sdk.store.paymentOption.arkyStripe.connect()
POST /v1/stores/{store_id}/payment-options/arky-monri
SDK: sdk.store.paymentOption.arkyMonri.connect()
POST /v1/stores/{store_id}/email-providers/arky-resend
SDK: sdk.notification.emailProvider.connectArkyResend()
const card = await sdk.store.paymentOption.arkyStripe.connect({
	store_id: store.id,
	id: crypto.randomUUID(),
	key: "card",
	blocks: [],
	status: "active",
	saved_card_terms: { en: "Save this card for the renewals you agree to." },
});

const monri = await sdk.store.paymentOption.arkyMonri.connect({
	store_id: store.id,
	id: crypto.randomUUID(),
	key: "monri",
	blocks: [],
	status: "active",
	saved_card_terms: { en: "Save this card for the renewals you agree to." },
});

await sdk.store.market.update({
	store_id: store.id,
	id: market.id,
	expected_updated_at: market.updated_at,
	payment_option_ids: [card.id, monri.id],
});

const connection = await sdk.notification.emailProvider.connectArkyResend({
	store_id: store.id,
	id: crypto.randomUUID(),
	name: "Test mail",
	domains: ["northwind.example"],
});
  • Who connects. admin connects a payment option. Only the store’s owner connects email, as on a live store, because the staff sign-in code goes out through it.
  • One account per store and provider. The same connect under the same id answers the same connection, and a store holds one arky_stripe (409 PAYMENT_OPTION.STRIPE_ACCOUNT_TAKEN). Several arky_resend connections share one simulated account.
  • Domains. connectArkyResend names at least one lowercase domain, and each is verified at once for sending and receiving, up to 20 per account (409 SIMULATOR.DOMAIN_LIMIT). The same connect naming a domain the account doesn’t hold is 409 GENERAL.CONFLICT.
  • Nothing to replace. The connection holds only what Arky made, so replacing a key or a webhook secret on one is refused (409 PAYMENT_OPTION.NOT_STRIPE, PAYMENT_OPTION.NOT_MONRI, EMAIL_PROVIDER.NOT_RESEND).
  • The rest is the same. A market lists the option, and addresses and each email’s selection work as in Store Email.
  • Storefronts read the protocol. StorefrontPaymentOption.type says stripe or monri for both kinds, so a site’s code doesn’t change. arky_stripe and arky_monri show only on Admin’s PaymentOption.

Each wrong pairing is refused when the option or connection is made, before any provider call:

ConnectingOnRefused with
Stripe test keys, or monri in testa live store409 PAYMENT_OPTION.LIVE_STORE_NEEDS_LIVE_KEYS
Stripe live keys, or monri in livea test store409 PAYMENT_OPTION.TEST_STORE_REFUSES_LIVE_KEYS
arky_stripe or arky_monria live store409 PAYMENT_OPTION.ARKY_PROVIDER_NEEDS_TEST_STORE
arky_resenda live store409 EMAIL_PROVIDER.ARKY_PROVIDER_NEEDS_TEST_STORE
resenda test store409 EMAIL_PROVIDER.TEST_STORE_NEEDS_ARKY_RESEND

Put Something On Sale

A test store sells the way a live store does: through a package. public is open to everyone from the start, so a setup script prices what it sells there, one item per product and market and one price per variant. It holds nothing until you do. The same script sets up the live store:

const shop = await sdk.eshop.package.getByKey({ store_id: store.id, key: "public" });

const shirtInShop = await sdk.eshop.packageItem.create({
	store_id: store.id,
	id: crypto.randomUUID(),
	package_id: shop.id,
	market_id: market.id,
	item: { type: "product", product_id: product.id },
});

await sdk.eshop.packageItemPrice.create({
	store_id: store.id,
	id: crypto.randomUUID(),
	package_item_id: shirtInShop.id,
	sellable: { type: "product_variant", variant_id: variant.id },
	amount: 2900,
	compare_at: { type: "none" },
	changes: [],
	schedule: { type: "always" },
	status: { type: "active" },
});
  • A cart names the package. The site reads it with arky.eshop.package.find() and names it on every read and cart, and the market comes from the client’s context.
  • The plan’s packages limit counts only packages with automatic items that aren’t archived, so a script can make price lists and newsletters without using it. Past the plan’s limits a save is refused with 402 STORE.USAGE_LIMIT_EXCEEDED, as on a live store, media files included.

Pay, Decline Or Expire A Payment

From the API. These need admin, by an account session or an account token. An agent places an order the way the site does, takes payment_id from the checkout answer and plays the outcome:

POST /v1/stores/{store_id}/simulator/payments/{payment_id}/pay
SDK: sdk.store.simulator.payments.pay()
POST /v1/stores/{store_id}/simulator/payments/{payment_id}/decline
SDK: sdk.store.simulator.payments.decline()
POST /v1/stores/{store_id}/simulator/payments/{payment_id}/expire
SDK: sdk.store.simulator.payments.expire()
await sdk.store.simulator.payments.pay({ store_id: storeId, payment_id: paymentId });
await sdk.store.simulator.payments.decline({ store_id: storeId, payment_id: paymentId });
await sdk.store.simulator.payments.expire({ store_id: storeId, payment_id: paymentId });
ControlStripeMonri
payThe buyer completes the payment pageAn approved purchase
declineA declined card: the page stays open for another try, as after a real declineThe payment’s callback says declined
expireCloses the pageNot offered: a Monri page can’t be closed (409 SIMULATOR.OUTCOME_NOT_OFFERED)
  • Each runs through the same handlers as a real provider’s post and ends in the same payment states. It answers 204 once Arky has taken the provider’s event, so you can read the payment right after.
  • Repeating the outcome a payment already had answers the same. Another outcome on a finished payment is 409 SIMULATOR.PAYMENT_FINISHED, and a payment with no simulated page is 404.
  • A post Arky didn’t take answers 502 SIMULATOR.WEBHOOK_UNDELIVERED, and repeating the control posts the same event.

In a browser. A site changes nothing: on a simulated payment mountCheckoutAction and mountPaymentMethodSetup load no provider script, work on a plain http page, and mount a small panel that says it is a test payment, with a button per outcome marked data-arky-simulator-outcome:

  • A Stripe checkout and a store plan offer complete, decline and expire. A click plays the outcome and then runs onComplete.
  • A Monri payment offers complete and decline. A click picks the outcome, and the mount’s confirm(details) sends it, complete until another is picked.
  • A card setup offers complete, decline and cancel. A click picks the outcome, and confirm sends it and throws ArkyError declined for a decline.

A browser test clicks [data-arky-simulator-outcome="complete"]. A site that wants its own controls checks isSimulatedPayment and calls simulatePayment, which takes no credentials and no address, because the answer that opened the payment names it. A value that runs on the real provider throws a TypeError before anything is sent, and anything but a confirmed answer throws ArkyError not_confirmed:

import { isSimulatedPayment, simulatePayment } from "arky-sdk/storefront";

const { placed } = checkout.state.get();
if (placed && placed.payment_action.type === "stripe_embedded_checkout" && isSimulatedPayment(placed.payment_action)) {
	await simulatePayment({
		simulation: { type: "stripe_checkout", action: placed.payment_action, outcome: "complete" },
	});
}

Read The Store’s Emails

GET /v1/stores/{store_id}/simulator/emails
SDK: sdk.store.simulator.emails.find()
const { items: emails, cursor } = await sdk.store.simulator.emails.find({
	store_id: storeId,
	to: "[email protected]",
	limit: 10,
});

const signInCode = /\d{6}/.exec(emails[0]?.text ?? "")?.[0];

This reads everything Arky handed to the store’s simulated Resend account, newest first, with from, to, cc, bcc, reply_to, subject, html, text, headers, tags, message_id, last_event and idempotency_key. Sign-in codes are included, so an admin of a test store can read any code its staff or customers are sent: keep real people out of test stores. to narrows the list to one recipient, and limit is at most 50. A store with no arky_resend reads an empty page. The store’s outgoing email, Admin’s Sent history, keeps its own rules and leaves sign-in codes out. The worker sends each email within moments, so poll until it arrives. Emails are removed 30 days after their last change.

Plan A Provider Failure Or Delay

POST /v1/stores/{store_id}/simulator/planned-outcomes
SDK: sdk.store.simulator.plannedOutcomes.create()
GET /v1/stores/{store_id}/simulator/planned-outcomes
SDK: sdk.store.simulator.plannedOutcomes.find()
DELETE /v1/stores/{store_id}/simulator/planned-outcomes/{id}
SDK: sdk.store.simulator.plannedOutcomes.remove()
await sdk.store.simulator.plannedOutcomes.create({
	store_id: storeId,
	id: crypto.randomUUID(),
	provider: "resend",
	operation: "send_email",
	matching: { type: "to", address: "[email protected]" },
	outcome: { type: "unavailable" },
});

await sdk.store.simulator.plannedOutcomes.create({
	store_id: storeId,
	id: crypto.randomUUID(),
	provider: "stripe",
	operation: "create_card_charge",
	matching: { type: "payment", payment_id: paymentId },
	outcome: { type: "declined" },
});

The next call of that operation that matches gets that outcome, once:

  • provider is stripe, monri or resend, and operation is one of that provider’s, such as create_checkout_session, create_card_charge, create_refund, create_payment_session, refund, send_email or deliver_webhook (the simulator’s next post to Arky).
  • matching is { type: "any" }, { type: "to", address } for send_email, or { type: "payment", payment_id } for the Stripe and Monri operations that name a payment.
  • outcome is refused with a message, rate_limited with retry_after_seconds, unavailable, lost_response (it takes effect and the answer is cut off), delayed with delay_ms, declined for a card charge, missing_link or expired_link for list_received_attachments (the next list leaves its first attachment out, or gives every link an expiry an hour in the past), or daily_quota_exceeded or monthly_quota_exceeded for send_email, which answer Resend’s 429 with that name and send nothing. A combination that doesn’t fit is 400 GENERAL.VALIDATION_FAILED.

A store holds at most 20 open plans (409 SIMULATOR.PLAN_LIMIT), a delay is at most 30 seconds, and a plan for a provider the store hasn’t connected is 409 SIMULATOR.NOT_CONNECTED. The plan’s id is your own UUID v4, and the same create under it answers the same plan.

Real Stripe Or Monri Test Keys

The simulator’s panel isn’t Stripe’s card form. To see the real form, a test store can connect real test credentials with the calls a live store uses: Stripe test keys (sk_test_... or rk_test_... with pk_test_...), or monri in test:

await sdk.store.paymentOption.stripe.connect({
	store_id: store.id,
	id: crypto.randomUUID(),
	key: "stripe-demo",
	blocks: [],
	status: "active",
	saved_card_terms: { en: "Save this card for the renewals you agree to." },
	restricted_key: "rk_test_...",
	publishable_key: "pk_test_...",
});

These payments run in the provider’s own test mode, with the merchant’s webhook set up as on a live store (E-shop). You pay with the provider’s test cards, the checkout answer’s runs_on is provider, and the simulator’s controls don’t reach them. A test store’s email stays on arky_resend.

Going Live

Test data never moves. A site goes live on a second store, made separately with mode: "live" and set up by the same setup script with live keys:

const mode = process.env.ENV === "prod" ? "live" : "test";

const shop = await sdk.store.create({
	id: crypto.randomUUID(),
	mode,
	name: "Northwind",
	timezone: "Europe/Berlin",
	languages: ["en"],
	market: { key: "eu", currency: "eur", tax_mode: "inclusive" },
	sales_channel: { key: "web" },
	location_address: { country: "DE" },
});

if (mode === "live") {
	await sdk.notification.emailProvider.connect({
		store_id: shop.id,
		id: crypto.randomUUID(),
		name: "Resend",
		api_key: resendApiKey,
		webhook_secret: resendWebhookSecret,
	});
} else {
	await sdk.notification.emailProvider.connectArkyResend({
		store_id: shop.id,
		id: crypto.randomUUID(),
		name: "Resend",
		domains: ["northwind.example"],
	});
}
  • Arky’s address stays the same. A site’s environment names the store and its publishable key: a test store for development and preview builds, the live store for production.
  • The site’s code doesn’t change. The checkout answer’s runs_on says where a payment runs, { type: "provider" } or { type: "simulator", api_url }, and mountCheckoutAction handles both.
  • A live store needs a plan and the provider setup that Store Email and E-shop describe.

What A Test Store Doesn’t Cover

  • Moving time. There is no control that moves time, so month ends, renewals and expiry dates can’t be reached on a test store ahead of their date. A test that needs a date to pass can’t run on one.
  • Stripe’s real card form. It shows only with real Stripe test keys, not on the simulator.
  • The provider’s own acceptance. Success on the simulator proves your wiring and Arky’s rules. Try your live provider setup in the provider’s own sandbox before you launch.

A Full Run For An Agent

  1. Get an account token with test_stores and admin from a person, make the store with mode: "test" (or run the site’s setup script in a non-production environment), and connect the providers. Keep the store id and its publishable key.
  2. Put something on sale: price a product in the public package, or in another package the buyer has access to.
  3. Build the site with that publishable key, or call the storefront API with it directly.
  4. Place an order. Read payment_id from the checkout answer and play the outcome with sdk.store.simulator.payments.pay, or click the panel in a browser.
  5. Read the payment and the order, and read the receipt with sdk.store.simulator.emails.find.
  6. To test a failure, plan it with sdk.store.simulator.plannedOutcomes.create before the call it should hit.
  7. Close the store with sdk.store.requestDeletion when you are done, because it holds one of the account’s 5 places until it is gone.