mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-04 21:04:37 +08:00
<!-- Make sure you've read the CONTRIBUTING.md guidelines: https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md --> Adds payment docs and code examples to docs. <img width="261" height="284" alt="image" src="https://github.com/user-attachments/assets/66e3f12c-48a3-4408-9ada-927f71427945" /> <img width="1042" height="900" alt="image" src="https://github.com/user-attachments/assets/b478b8cf-b925-41c8-a800-a7dcb7bc9986" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Added comprehensive Payments app guide covering Stripe integration, subscriptions, and one-time purchases * Included extensive, multi-language code examples for payment workflows (JavaScript/TypeScript and Python) * Added examples for checkout flows, item management, consuming credits, listing products, and granting products * Integrated the Payments examples into the central examples collection and updated docs navigation to include the Payments guide <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { CodeExample } from '../lib/code-examples';
|
|
import { apiKeysExamples } from './api-keys';
|
|
import { paymentsExamples } from './payments';
|
|
import { setupExamples } from './setup';
|
|
import { viteExamples } from './vite-example';
|
|
|
|
const allExamples: Record<string, Record<string, Record<string, CodeExample[]>>> = {
|
|
'setup': setupExamples,
|
|
'apps': {...apiKeysExamples, ...paymentsExamples },
|
|
'getting-started': viteExamples,
|
|
// Add more sections here as needed:
|
|
// 'auth': authExamples,
|
|
// 'customization': customizationExamples,
|
|
};
|
|
|
|
export function getExample(documentPath: string, exampleName: string): CodeExample[] | undefined {
|
|
const [section, ...rest] = documentPath.split('/');
|
|
const subsection = rest.join('/');
|
|
return allExamples[section]?.[subsection]?.[exampleName];
|
|
}
|
|
|
|
export function getDocumentExamples(documentPath: string): Record<string, CodeExample[]> | undefined {
|
|
const [section, ...rest] = documentPath.split('/');
|
|
const subsection = rest.join('/');
|
|
return allExamples[section]?.[subsection];
|
|
}
|
|
|