@zimezone/z-command 1.1.1 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/README.md +13 -1
  2. package/dist/cli.js +1 -1
  3. package/dist/commands/init.d.ts.map +1 -1
  4. package/dist/commands/init.js +42 -10
  5. package/dist/commands/init.js.map +1 -1
  6. package/dist/platforms.d.ts.map +1 -1
  7. package/dist/platforms.js +11 -1
  8. package/dist/platforms.js.map +1 -1
  9. package/dist/types.d.ts +2 -0
  10. package/dist/types.d.ts.map +1 -1
  11. package/package.json +8 -3
  12. package/templates.zip +0 -0
  13. package/templates/agents/accessibility-expert.agent.md +0 -56
  14. package/templates/agents/ai-engineer.agent.md +0 -61
  15. package/templates/agents/angular-architect.agent.md +0 -49
  16. package/templates/agents/api-designer.agent.md +0 -40
  17. package/templates/agents/api-documenter.agent.md +0 -161
  18. package/templates/agents/architect-review.agent.md +0 -146
  19. package/templates/agents/arm-cortex-expert.agent.md +0 -288
  20. package/templates/agents/azure-infra-engineer.agent.md +0 -57
  21. package/templates/agents/backend-architect.agent.md +0 -309
  22. package/templates/agents/backend-developer.agent.md +0 -61
  23. package/templates/agents/backend-security-coder.agent.md +0 -152
  24. package/templates/agents/bash-pro.agent.md +0 -285
  25. package/templates/agents/blockchain-developer.agent.md +0 -57
  26. package/templates/agents/build-engineer.agent.md +0 -56
  27. package/templates/agents/business-analyst.agent.md +0 -47
  28. package/templates/agents/c-pro.agent.md +0 -35
  29. package/templates/agents/c4-code.agent.md +0 -320
  30. package/templates/agents/c4-component.agent.md +0 -227
  31. package/templates/agents/c4-container.agent.md +0 -248
  32. package/templates/agents/c4-context.agent.md +0 -235
  33. package/templates/agents/cli-developer.agent.md +0 -57
  34. package/templates/agents/cloud-architect.agent.md +0 -56
  35. package/templates/agents/code-architect.agent.md +0 -63
  36. package/templates/agents/code-reviewer.agent.md +0 -49
  37. package/templates/agents/competitive-analyst.agent.md +0 -48
  38. package/templates/agents/conductor-validator.agent.md +0 -245
  39. package/templates/agents/context-manager.agent.md +0 -55
  40. package/templates/agents/cpp-pro.agent.md +0 -59
  41. package/templates/agents/csharp-developer.agent.md +0 -57
  42. package/templates/agents/csharp-pro.agent.md +0 -38
  43. package/templates/agents/customer-support.agent.md +0 -148
  44. package/templates/agents/data-engineer.agent.md +0 -55
  45. package/templates/agents/data-researcher.agent.md +0 -55
  46. package/templates/agents/data-scientist.agent.md +0 -56
  47. package/templates/agents/database-admin.agent.md +0 -142
  48. package/templates/agents/database-administrator.agent.md +0 -50
  49. package/templates/agents/database-architect.agent.md +0 -238
  50. package/templates/agents/database-optimizer.agent.md +0 -144
  51. package/templates/agents/debugger.agent.md +0 -30
  52. package/templates/agents/deployment-engineer.agent.md +0 -0
  53. package/templates/agents/devops-engineer.agent.md +0 -59
  54. package/templates/agents/devops-troubleshooter.agent.md +0 -138
  55. package/templates/agents/django-developer.agent.md +0 -50
  56. package/templates/agents/django-pro.agent.md +0 -159
  57. package/templates/agents/docs-architect.agent.md +0 -77
  58. package/templates/agents/documentation-engineer.agent.md +0 -57
  59. package/templates/agents/dotnet-architect.agent.md +0 -175
  60. package/templates/agents/dx-optimizer.agent.md +0 -63
  61. package/templates/agents/electron-pro.agent.md +0 -56
  62. package/templates/agents/elixir-pro.agent.md +0 -38
  63. package/templates/agents/embedded-systems.agent.md +0 -55
  64. package/templates/agents/error-detective.agent.md +0 -32
  65. package/templates/agents/event-sourcing-architect.agent.md +0 -42
  66. package/templates/agents/fastapi-pro.agent.md +0 -171
  67. package/templates/agents/fintech-engineer.agent.md +0 -57
  68. package/templates/agents/firmware-analyst.agent.md +0 -330
  69. package/templates/agents/flutter-expert.agent.md +0 -50
  70. package/templates/agents/frontend-developer.agent.md +0 -59
  71. package/templates/agents/frontend-security-coder.agent.md +0 -149
  72. package/templates/agents/fullstack-developer.agent.md +0 -46
  73. package/templates/agents/git-workflow-manager.agent.md +0 -57
  74. package/templates/agents/golang-pro.agent.md +0 -50
  75. package/templates/agents/graphql-architect.agent.md +0 -48
  76. package/templates/agents/haskell-pro.agent.md +0 -37
  77. package/templates/agents/hr-pro.agent.md +0 -105
  78. package/templates/agents/incident-responder.agent.md +0 -190
  79. package/templates/agents/ios-developer.agent.md +0 -198
  80. package/templates/agents/iot-engineer.agent.md +0 -56
  81. package/templates/agents/java-architect.agent.md +0 -48
  82. package/templates/agents/java-pro.agent.md +0 -156
  83. package/templates/agents/javascript-pro.agent.md +0 -35
  84. package/templates/agents/julia-pro.agent.md +0 -187
  85. package/templates/agents/kotlin-specialist.agent.md +0 -50
  86. package/templates/agents/laravel-specialist.agent.md +0 -50
  87. package/templates/agents/legacy-modernizer.agent.md +0 -56
  88. package/templates/agents/legal-advisor.agent.md +0 -49
  89. package/templates/agents/llm-architect.agent.md +0 -58
  90. package/templates/agents/malware-analyst.agent.md +0 -272
  91. package/templates/agents/mcp-developer.agent.md +0 -54
  92. package/templates/agents/mermaid-expert.agent.md +0 -39
  93. package/templates/agents/microservices-architect.agent.md +0 -47
  94. package/templates/agents/minecraft-bukkit-pro.agent.md +0 -104
  95. package/templates/agents/ml-engineer.agent.md +0 -56
  96. package/templates/agents/mlops-engineer.agent.md +0 -56
  97. package/templates/agents/mobile-developer.agent.md +0 -45
  98. package/templates/agents/mobile-security-coder.agent.md +0 -163
  99. package/templates/agents/monorepo-architect.agent.md +0 -44
  100. package/templates/agents/multi-agent-coordinator.agent.md +0 -55
  101. package/templates/agents/network-engineer.agent.md +0 -57
  102. package/templates/agents/nextjs-developer.agent.md +0 -48
  103. package/templates/agents/nlp-engineer.agent.md +0 -58
  104. package/templates/agents/observability-engineer.agent.md +0 -228
  105. package/templates/agents/payment-integration.agent.md +0 -56
  106. package/templates/agents/performance-engineer.agent.md +0 -167
  107. package/templates/agents/performance-optimizer.agent.md +0 -57
  108. package/templates/agents/php-pro.agent.md +0 -43
  109. package/templates/agents/platform-engineer.agent.md +0 -57
  110. package/templates/agents/posix-shell-pro.agent.md +0 -284
  111. package/templates/agents/postgres-pro.agent.md +0 -58
  112. package/templates/agents/product-manager.agent.md +0 -55
  113. package/templates/agents/project-manager.agent.md +0 -57
  114. package/templates/agents/prompt-engineer.agent.md +0 -58
  115. package/templates/agents/python-pro.agent.md +0 -48
  116. package/templates/agents/quant-analyst.agent.md +0 -32
  117. package/templates/agents/rails-expert.agent.md +0 -50
  118. package/templates/agents/react-specialist.agent.md +0 -49
  119. package/templates/agents/refactoring-specialist.agent.md +0 -56
  120. package/templates/agents/reference-builder.agent.md +0 -167
  121. package/templates/agents/research-analyst.agent.md +0 -63
  122. package/templates/agents/reverse-engineer.agent.md +0 -202
  123. package/templates/agents/risk-manager.agent.md +0 -41
  124. package/templates/agents/ruby-pro.agent.md +0 -35
  125. package/templates/agents/rust-pro.agent.md +0 -156
  126. package/templates/agents/sales-automator.agent.md +0 -35
  127. package/templates/agents/scala-pro.agent.md +0 -60
  128. package/templates/agents/scrum-master.agent.md +0 -54
  129. package/templates/agents/search-specialist.agent.md +0 -59
  130. package/templates/agents/security-analyst.agent.md +0 -57
  131. package/templates/agents/security-auditor.agent.md +0 -138
  132. package/templates/agents/security-engineer.agent.md +0 -57
  133. package/templates/agents/seo-authority-builder.agent.md +0 -116
  134. package/templates/agents/seo-cannibalization-detector.agent.md +0 -103
  135. package/templates/agents/seo-content-auditor.agent.md +0 -63
  136. package/templates/agents/seo-content-planner.agent.md +0 -88
  137. package/templates/agents/seo-content-refresher.agent.md +0 -98
  138. package/templates/agents/seo-content-writer.agent.md +0 -76
  139. package/templates/agents/seo-keyword-strategist.agent.md +0 -75
  140. package/templates/agents/seo-meta-optimizer.agent.md +0 -72
  141. package/templates/agents/seo-snippet-hunter.agent.md +0 -94
  142. package/templates/agents/seo-specialist.agent.md +0 -57
  143. package/templates/agents/seo-structure-architect.agent.md +0 -88
  144. package/templates/agents/service-mesh-expert.agent.md +0 -41
  145. package/templates/agents/sql-pro.agent.md +0 -146
  146. package/templates/agents/sre-engineer.agent.md +0 -58
  147. package/templates/agents/swift-expert.agent.md +0 -49
  148. package/templates/agents/task-distributor.agent.md +0 -47
  149. package/templates/agents/tdd-orchestrator.agent.md +0 -183
  150. package/templates/agents/technical-writer.agent.md +0 -48
  151. package/templates/agents/temporal-python-pro.agent.md +0 -349
  152. package/templates/agents/terraform-engineer.agent.md +0 -57
  153. package/templates/agents/terraform-specialist.agent.md +0 -137
  154. package/templates/agents/test-automator.agent.md +0 -203
  155. package/templates/agents/test-engineer.agent.md +0 -55
  156. package/templates/agents/threat-modeling-expert.agent.md +0 -44
  157. package/templates/agents/trend-analyst.agent.md +0 -47
  158. package/templates/agents/tutorial-engineer.agent.md +0 -118
  159. package/templates/agents/typescript-pro.agent.md +0 -48
  160. package/templates/agents/ui-designer.agent.md +0 -48
  161. package/templates/agents/ui-ux-designer.agent.md +0 -188
  162. package/templates/agents/ui-visual-validator.agent.md +0 -192
  163. package/templates/agents/ux-researcher.agent.md +0 -48
  164. package/templates/agents/vector-database-engineer.agent.md +0 -43
  165. package/templates/agents/vue-expert.agent.md +0 -48
  166. package/templates/agents/websocket-engineer.agent.md +0 -49
  167. package/templates/agents/workflow-orchestrator.agent.md +0 -48
  168. package/templates/skills/angular-migration/SKILL.md +0 -410
  169. package/templates/skills/api-design-principles/SKILL.md +0 -528
  170. package/templates/skills/api-design-principles/assets/api-design-checklist.md +0 -155
  171. package/templates/skills/api-design-principles/assets/rest-api-template.py +0 -182
  172. package/templates/skills/api-design-principles/references/graphql-schema-design.md +0 -583
  173. package/templates/skills/api-design-principles/references/rest-best-practices.md +0 -408
  174. package/templates/skills/architecture-decision-records/SKILL.md +0 -428
  175. package/templates/skills/architecture-patterns/SKILL.md +0 -494
  176. package/templates/skills/async-python-patterns/SKILL.md +0 -694
  177. package/templates/skills/auth-implementation-patterns/SKILL.md +0 -634
  178. package/templates/skills/changelog-automation/SKILL.md +0 -552
  179. package/templates/skills/code-review/SKILL.md +0 -62
  180. package/templates/skills/code-review-excellence/SKILL.md +0 -520
  181. package/templates/skills/competitive-landscape/SKILL.md +0 -479
  182. package/templates/skills/context-driven-development/SKILL.md +0 -385
  183. package/templates/skills/cost-optimization/SKILL.md +0 -274
  184. package/templates/skills/cqrs-implementation/SKILL.md +0 -554
  185. package/templates/skills/data-quality-frameworks/SKILL.md +0 -587
  186. package/templates/skills/data-storytelling/SKILL.md +0 -453
  187. package/templates/skills/database-migration/SKILL.md +0 -424
  188. package/templates/skills/dbt-transformation-patterns/SKILL.md +0 -561
  189. package/templates/skills/debugging-strategies/SKILL.md +0 -527
  190. package/templates/skills/defi-protocol-templates/SKILL.md +0 -454
  191. package/templates/skills/dependency-upgrade/SKILL.md +0 -409
  192. package/templates/skills/deployment-pipeline-design/SKILL.md +0 -359
  193. package/templates/skills/distributed-tracing/SKILL.md +0 -438
  194. package/templates/skills/dotnet-backend-patterns/SKILL.md +0 -815
  195. package/templates/skills/dotnet-backend-patterns/assets/repository-template.cs +0 -523
  196. package/templates/skills/dotnet-backend-patterns/assets/service-template.cs +0 -336
  197. package/templates/skills/dotnet-backend-patterns/references/dapper-patterns.md +0 -544
  198. package/templates/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +0 -355
  199. package/templates/skills/e2e-testing-patterns/SKILL.md +0 -547
  200. package/templates/skills/employment-contract-templates/SKILL.md +0 -507
  201. package/templates/skills/error-handling-patterns/SKILL.md +0 -636
  202. package/templates/skills/event-store-design/SKILL.md +0 -437
  203. package/templates/skills/fastapi-templates/SKILL.md +0 -567
  204. package/templates/skills/git-advanced-workflows/SKILL.md +0 -400
  205. package/templates/skills/github-actions-templates/SKILL.md +0 -333
  206. package/templates/skills/go-concurrency-patterns/SKILL.md +0 -655
  207. package/templates/skills/grafana-dashboards/SKILL.md +0 -369
  208. package/templates/skills/helm-chart-scaffolding/SKILL.md +0 -544
  209. package/templates/skills/helm-chart-scaffolding/assets/Chart.yaml.template +0 -42
  210. package/templates/skills/helm-chart-scaffolding/assets/values.yaml.template +0 -185
  211. package/templates/skills/helm-chart-scaffolding/references/chart-structure.md +0 -500
  212. package/templates/skills/helm-chart-scaffolding/scripts/validate-chart.sh +0 -244
  213. package/templates/skills/javascript-testing-patterns/SKILL.md +0 -1025
  214. package/templates/skills/langchain-architecture/SKILL.md +0 -338
  215. package/templates/skills/llm-evaluation/SKILL.md +0 -471
  216. package/templates/skills/microservices-patterns/SKILL.md +0 -595
  217. package/templates/skills/modern-javascript-patterns/SKILL.md +0 -911
  218. package/templates/skills/monorepo-management/SKILL.md +0 -622
  219. package/templates/skills/nextjs-app-router-patterns/SKILL.md +0 -544
  220. package/templates/skills/nodejs-backend-patterns/SKILL.md +0 -1020
  221. package/templates/skills/nx-workspace-patterns/SKILL.md +0 -452
  222. package/templates/skills/openapi-spec-generation/SKILL.md +0 -1028
  223. package/templates/skills/paypal-integration/SKILL.md +0 -467
  224. package/templates/skills/pci-compliance/SKILL.md +0 -466
  225. package/templates/skills/postgresql/SKILL.md +0 -204
  226. package/templates/skills/projection-patterns/SKILL.md +0 -490
  227. package/templates/skills/prometheus-configuration/SKILL.md +0 -392
  228. package/templates/skills/prompt-engineering-patterns/SKILL.md +0 -201
  229. package/templates/skills/prompt-engineering-patterns/assets/few-shot-examples.json +0 -106
  230. package/templates/skills/prompt-engineering-patterns/assets/prompt-template-library.md +0 -246
  231. package/templates/skills/prompt-engineering-patterns/references/chain-of-thought.md +0 -399
  232. package/templates/skills/prompt-engineering-patterns/references/few-shot-learning.md +0 -369
  233. package/templates/skills/prompt-engineering-patterns/references/prompt-optimization.md +0 -414
  234. package/templates/skills/prompt-engineering-patterns/references/prompt-templates.md +0 -470
  235. package/templates/skills/prompt-engineering-patterns/references/system-prompts.md +0 -189
  236. package/templates/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +0 -279
  237. package/templates/skills/python-packaging/SKILL.md +0 -870
  238. package/templates/skills/python-performance-optimization/SKILL.md +0 -869
  239. package/templates/skills/python-testing-patterns/SKILL.md +0 -907
  240. package/templates/skills/rag-implementation/SKILL.md +0 -403
  241. package/templates/skills/react-modernization/SKILL.md +0 -513
  242. package/templates/skills/react-native-architecture/SKILL.md +0 -671
  243. package/templates/skills/react-state-management/SKILL.md +0 -429
  244. package/templates/skills/risk-metrics-calculation/SKILL.md +0 -555
  245. package/templates/skills/rust-async-patterns/SKILL.md +0 -517
  246. package/templates/skills/secrets-management/SKILL.md +0 -346
  247. package/templates/skills/security-requirement-extraction/SKILL.md +0 -677
  248. package/templates/skills/security-review/SKILL.md +0 -78
  249. package/templates/skills/shellcheck-configuration/SKILL.md +0 -454
  250. package/templates/skills/similarity-search-patterns/SKILL.md +0 -558
  251. package/templates/skills/slo-implementation/SKILL.md +0 -329
  252. package/templates/skills/sql-optimization-patterns/SKILL.md +0 -493
  253. package/templates/skills/stripe-integration/SKILL.md +0 -442
  254. package/templates/skills/systematic-debugging/SKILL.md +0 -57
  255. package/templates/skills/tailwind-design-system/SKILL.md +0 -666
  256. package/templates/skills/temporal-python-testing/SKILL.md +0 -158
  257. package/templates/skills/temporal-python-testing/resources/integration-testing.md +0 -455
  258. package/templates/skills/temporal-python-testing/resources/local-setup.md +0 -553
  259. package/templates/skills/temporal-python-testing/resources/replay-testing.md +0 -462
  260. package/templates/skills/temporal-python-testing/resources/unit-testing.md +0 -328
  261. package/templates/skills/terraform-module-library/SKILL.md +0 -249
  262. package/templates/skills/terraform-module-library/references/aws-modules.md +0 -63
  263. package/templates/skills/test-driven-development/SKILL.md +0 -46
  264. package/templates/skills/threat-mitigation-mapping/SKILL.md +0 -745
  265. package/templates/skills/track-management/SKILL.md +0 -593
  266. package/templates/skills/typescript-advanced-types/SKILL.md +0 -717
  267. package/templates/skills/ui-ux-pro-max/SKILL.md +0 -352
  268. package/templates/skills/ui-ux-pro-max/data/charts.csv +0 -26
  269. package/templates/skills/ui-ux-pro-max/data/colors.csv +0 -97
  270. package/templates/skills/ui-ux-pro-max/data/icons.csv +0 -101
  271. package/templates/skills/ui-ux-pro-max/data/landing.csv +0 -31
  272. package/templates/skills/ui-ux-pro-max/data/products.csv +0 -97
  273. package/templates/skills/ui-ux-pro-max/data/prompts.csv +0 -24
  274. package/templates/skills/ui-ux-pro-max/data/react-performance.csv +0 -45
  275. package/templates/skills/ui-ux-pro-max/data/styles.csv +0 -59
  276. package/templates/skills/ui-ux-pro-max/data/typography.csv +0 -58
  277. package/templates/skills/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
  278. package/templates/skills/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
  279. package/templates/skills/ui-ux-pro-max/data/web-interface.csv +0 -31
  280. package/templates/skills/ui-ux-pro-max/scripts/core.py +0 -258
  281. package/templates/skills/ui-ux-pro-max/scripts/design_system.py +0 -547
  282. package/templates/skills/ui-ux-pro-max/scripts/search.py +0 -76
  283. package/templates/skills/uv-package-manager/SKILL.md +0 -831
  284. package/templates/skills/vector-index-tuning/SKILL.md +0 -521
  285. package/templates/skills/wcag-audit-patterns/SKILL.md +0 -555
  286. package/templates/skills/workflow-orchestration-patterns/SKILL.md +0 -316
  287. package/templates/skills/workflow-patterns/SKILL.md +0 -623
  288. package/templates/skills/writing-plans/SKILL.md +0 -64
@@ -1,442 +0,0 @@
1
- ---
2
- name: stripe-integration
3
- description: Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.
4
- ---
5
-
6
- # Stripe Integration
7
-
8
- Master Stripe payment processing integration for robust, PCI-compliant payment flows including checkout, subscriptions, webhooks, and refunds.
9
-
10
- ## When to Use This Skill
11
-
12
- - Implementing payment processing in web/mobile applications
13
- - Setting up subscription billing systems
14
- - Handling one-time payments and recurring charges
15
- - Processing refunds and disputes
16
- - Managing customer payment methods
17
- - Implementing SCA (Strong Customer Authentication) for European payments
18
- - Building marketplace payment flows with Stripe Connect
19
-
20
- ## Core Concepts
21
-
22
- ### 1. Payment Flows
23
- **Checkout Session (Hosted)**
24
- - Stripe-hosted payment page
25
- - Minimal PCI compliance burden
26
- - Fastest implementation
27
- - Supports one-time and recurring payments
28
-
29
- **Payment Intents (Custom UI)**
30
- - Full control over payment UI
31
- - Requires Stripe.js for PCI compliance
32
- - More complex implementation
33
- - Better customization options
34
-
35
- **Setup Intents (Save Payment Methods)**
36
- - Collect payment method without charging
37
- - Used for subscriptions and future payments
38
- - Requires customer confirmation
39
-
40
- ### 2. Webhooks
41
- **Critical Events:**
42
- - `payment_intent.succeeded`: Payment completed
43
- - `payment_intent.payment_failed`: Payment failed
44
- - `customer.subscription.updated`: Subscription changed
45
- - `customer.subscription.deleted`: Subscription canceled
46
- - `charge.refunded`: Refund processed
47
- - `invoice.payment_succeeded`: Subscription payment successful
48
-
49
- ### 3. Subscriptions
50
- **Components:**
51
- - **Product**: What you're selling
52
- - **Price**: How much and how often
53
- - **Subscription**: Customer's recurring payment
54
- - **Invoice**: Generated for each billing cycle
55
-
56
- ### 4. Customer Management
57
- - Create and manage customer records
58
- - Store multiple payment methods
59
- - Track customer metadata
60
- - Manage billing details
61
-
62
- ## Quick Start
63
-
64
- ```python
65
- import stripe
66
-
67
- stripe.api_key = "sk_test_..."
68
-
69
- # Create a checkout session
70
- session = stripe.checkout.Session.create(
71
- payment_method_types=['card'],
72
- line_items=[{
73
- 'price_data': {
74
- 'currency': 'usd',
75
- 'product_data': {
76
- 'name': 'Premium Subscription',
77
- },
78
- 'unit_amount': 2000, # $20.00
79
- 'recurring': {
80
- 'interval': 'month',
81
- },
82
- },
83
- 'quantity': 1,
84
- }],
85
- mode='subscription',
86
- success_url='https://yourdomain.com/success?session_id={CHECKOUT_SESSION_ID}',
87
- cancel_url='https://yourdomain.com/cancel',
88
- )
89
-
90
- # Redirect user to session.url
91
- print(session.url)
92
- ```
93
-
94
- ## Payment Implementation Patterns
95
-
96
- ### Pattern 1: One-Time Payment (Hosted Checkout)
97
- ```python
98
- def create_checkout_session(amount, currency='usd'):
99
- """Create a one-time payment checkout session."""
100
- try:
101
- session = stripe.checkout.Session.create(
102
- payment_method_types=['card'],
103
- line_items=[{
104
- 'price_data': {
105
- 'currency': currency,
106
- 'product_data': {
107
- 'name': 'Purchase',
108
- 'images': ['https://example.com/product.jpg'],
109
- },
110
- 'unit_amount': amount, # Amount in cents
111
- },
112
- 'quantity': 1,
113
- }],
114
- mode='payment',
115
- success_url='https://yourdomain.com/success?session_id={CHECKOUT_SESSION_ID}',
116
- cancel_url='https://yourdomain.com/cancel',
117
- metadata={
118
- 'order_id': 'order_123',
119
- 'user_id': 'user_456'
120
- }
121
- )
122
- return session
123
- except stripe.error.StripeError as e:
124
- # Handle error
125
- print(f"Stripe error: {e.user_message}")
126
- raise
127
- ```
128
-
129
- ### Pattern 2: Custom Payment Intent Flow
130
- ```python
131
- def create_payment_intent(amount, currency='usd', customer_id=None):
132
- """Create a payment intent for custom checkout UI."""
133
- intent = stripe.PaymentIntent.create(
134
- amount=amount,
135
- currency=currency,
136
- customer=customer_id,
137
- automatic_payment_methods={
138
- 'enabled': True,
139
- },
140
- metadata={
141
- 'integration_check': 'accept_a_payment'
142
- }
143
- )
144
- return intent.client_secret # Send to frontend
145
-
146
- # Frontend (JavaScript)
147
- """
148
- const stripe = Stripe('pk_test_...');
149
- const elements = stripe.elements();
150
- const cardElement = elements.create('card');
151
- cardElement.mount('#card-element');
152
-
153
- const {error, paymentIntent} = await stripe.confirmCardPayment(
154
- clientSecret,
155
- {
156
- payment_method: {
157
- card: cardElement,
158
- billing_details: {
159
- name: 'Customer Name'
160
- }
161
- }
162
- }
163
- );
164
-
165
- if (error) {
166
- // Handle error
167
- } else if (paymentIntent.status === 'succeeded') {
168
- // Payment successful
169
- }
170
- """
171
- ```
172
-
173
- ### Pattern 3: Subscription Creation
174
- ```python
175
- def create_subscription(customer_id, price_id):
176
- """Create a subscription for a customer."""
177
- try:
178
- subscription = stripe.Subscription.create(
179
- customer=customer_id,
180
- items=[{'price': price_id}],
181
- payment_behavior='default_incomplete',
182
- payment_settings={'save_default_payment_method': 'on_subscription'},
183
- expand=['latest_invoice.payment_intent'],
184
- )
185
-
186
- return {
187
- 'subscription_id': subscription.id,
188
- 'client_secret': subscription.latest_invoice.payment_intent.client_secret
189
- }
190
- except stripe.error.StripeError as e:
191
- print(f"Subscription creation failed: {e}")
192
- raise
193
- ```
194
-
195
- ### Pattern 4: Customer Portal
196
- ```python
197
- def create_customer_portal_session(customer_id):
198
- """Create a portal session for customers to manage subscriptions."""
199
- session = stripe.billing_portal.Session.create(
200
- customer=customer_id,
201
- return_url='https://yourdomain.com/account',
202
- )
203
- return session.url # Redirect customer here
204
- ```
205
-
206
- ## Webhook Handling
207
-
208
- ### Secure Webhook Endpoint
209
- ```python
210
- from flask import Flask, request
211
- import stripe
212
-
213
- app = Flask(__name__)
214
-
215
- endpoint_secret = 'whsec_...'
216
-
217
- @app.route('/webhook', methods=['POST'])
218
- def webhook():
219
- payload = request.data
220
- sig_header = request.headers.get('Stripe-Signature')
221
-
222
- try:
223
- event = stripe.Webhook.construct_event(
224
- payload, sig_header, endpoint_secret
225
- )
226
- except ValueError:
227
- # Invalid payload
228
- return 'Invalid payload', 400
229
- except stripe.error.SignatureVerificationError:
230
- # Invalid signature
231
- return 'Invalid signature', 400
232
-
233
- # Handle the event
234
- if event['type'] == 'payment_intent.succeeded':
235
- payment_intent = event['data']['object']
236
- handle_successful_payment(payment_intent)
237
- elif event['type'] == 'payment_intent.payment_failed':
238
- payment_intent = event['data']['object']
239
- handle_failed_payment(payment_intent)
240
- elif event['type'] == 'customer.subscription.deleted':
241
- subscription = event['data']['object']
242
- handle_subscription_canceled(subscription)
243
-
244
- return 'Success', 200
245
-
246
- def handle_successful_payment(payment_intent):
247
- """Process successful payment."""
248
- customer_id = payment_intent.get('customer')
249
- amount = payment_intent['amount']
250
- metadata = payment_intent.get('metadata', {})
251
-
252
- # Update your database
253
- # Send confirmation email
254
- # Fulfill order
255
- print(f"Payment succeeded: {payment_intent['id']}")
256
-
257
- def handle_failed_payment(payment_intent):
258
- """Handle failed payment."""
259
- error = payment_intent.get('last_payment_error', {})
260
- print(f"Payment failed: {error.get('message')}")
261
- # Notify customer
262
- # Update order status
263
-
264
- def handle_subscription_canceled(subscription):
265
- """Handle subscription cancellation."""
266
- customer_id = subscription['customer']
267
- # Update user access
268
- # Send cancellation email
269
- print(f"Subscription canceled: {subscription['id']}")
270
- ```
271
-
272
- ### Webhook Best Practices
273
- ```python
274
- import hashlib
275
- import hmac
276
-
277
- def verify_webhook_signature(payload, signature, secret):
278
- """Manually verify webhook signature."""
279
- expected_sig = hmac.new(
280
- secret.encode('utf-8'),
281
- payload,
282
- hashlib.sha256
283
- ).hexdigest()
284
-
285
- return hmac.compare_digest(signature, expected_sig)
286
-
287
- def handle_webhook_idempotently(event_id, handler):
288
- """Ensure webhook is processed exactly once."""
289
- # Check if event already processed
290
- if is_event_processed(event_id):
291
- return
292
-
293
- # Process event
294
- try:
295
- handler()
296
- mark_event_processed(event_id)
297
- except Exception as e:
298
- log_error(e)
299
- # Stripe will retry failed webhooks
300
- raise
301
- ```
302
-
303
- ## Customer Management
304
-
305
- ```python
306
- def create_customer(email, name, payment_method_id=None):
307
- """Create a Stripe customer."""
308
- customer = stripe.Customer.create(
309
- email=email,
310
- name=name,
311
- payment_method=payment_method_id,
312
- invoice_settings={
313
- 'default_payment_method': payment_method_id
314
- } if payment_method_id else None,
315
- metadata={
316
- 'user_id': '12345'
317
- }
318
- )
319
- return customer
320
-
321
- def attach_payment_method(customer_id, payment_method_id):
322
- """Attach a payment method to a customer."""
323
- stripe.PaymentMethod.attach(
324
- payment_method_id,
325
- customer=customer_id
326
- )
327
-
328
- # Set as default
329
- stripe.Customer.modify(
330
- customer_id,
331
- invoice_settings={
332
- 'default_payment_method': payment_method_id
333
- }
334
- )
335
-
336
- def list_customer_payment_methods(customer_id):
337
- """List all payment methods for a customer."""
338
- payment_methods = stripe.PaymentMethod.list(
339
- customer=customer_id,
340
- type='card'
341
- )
342
- return payment_methods.data
343
- ```
344
-
345
- ## Refund Handling
346
-
347
- ```python
348
- def create_refund(payment_intent_id, amount=None, reason=None):
349
- """Create a refund."""
350
- refund_params = {
351
- 'payment_intent': payment_intent_id
352
- }
353
-
354
- if amount:
355
- refund_params['amount'] = amount # Partial refund
356
-
357
- if reason:
358
- refund_params['reason'] = reason # 'duplicate', 'fraudulent', 'requested_by_customer'
359
-
360
- refund = stripe.Refund.create(**refund_params)
361
- return refund
362
-
363
- def handle_dispute(charge_id, evidence):
364
- """Update dispute with evidence."""
365
- stripe.Dispute.modify(
366
- charge_id,
367
- evidence={
368
- 'customer_name': evidence.get('customer_name'),
369
- 'customer_email_address': evidence.get('customer_email'),
370
- 'shipping_documentation': evidence.get('shipping_proof'),
371
- 'customer_communication': evidence.get('communication'),
372
- }
373
- )
374
- ```
375
-
376
- ## Testing
377
-
378
- ```python
379
- # Use test mode keys
380
- stripe.api_key = "sk_test_..."
381
-
382
- # Test card numbers
383
- TEST_CARDS = {
384
- 'success': '4242424242424242',
385
- 'declined': '4000000000000002',
386
- '3d_secure': '4000002500003155',
387
- 'insufficient_funds': '4000000000009995'
388
- }
389
-
390
- def test_payment_flow():
391
- """Test complete payment flow."""
392
- # Create test customer
393
- customer = stripe.Customer.create(
394
- email="test@example.com"
395
- )
396
-
397
- # Create payment intent
398
- intent = stripe.PaymentIntent.create(
399
- amount=1000,
400
- currency='usd',
401
- customer=customer.id,
402
- payment_method_types=['card']
403
- )
404
-
405
- # Confirm with test card
406
- confirmed = stripe.PaymentIntent.confirm(
407
- intent.id,
408
- payment_method='pm_card_visa' # Test payment method
409
- )
410
-
411
- assert confirmed.status == 'succeeded'
412
- ```
413
-
414
- ## Resources
415
-
416
- - **references/checkout-flows.md**: Detailed checkout implementation
417
- - **references/webhook-handling.md**: Webhook security and processing
418
- - **references/subscription-management.md**: Subscription lifecycle
419
- - **references/customer-management.md**: Customer and payment method handling
420
- - **references/invoice-generation.md**: Invoicing and billing
421
- - **assets/stripe-client.py**: Production-ready Stripe client wrapper
422
- - **assets/webhook-handler.py**: Complete webhook processor
423
- - **assets/checkout-config.json**: Checkout configuration templates
424
-
425
- ## Best Practices
426
-
427
- 1. **Always Use Webhooks**: Don't rely solely on client-side confirmation
428
- 2. **Idempotency**: Handle webhook events idempotently
429
- 3. **Error Handling**: Gracefully handle all Stripe errors
430
- 4. **Test Mode**: Thoroughly test with test keys before production
431
- 5. **Metadata**: Use metadata to link Stripe objects to your database
432
- 6. **Monitoring**: Track payment success rates and errors
433
- 7. **PCI Compliance**: Never handle raw card data on your server
434
- 8. **SCA Ready**: Implement 3D Secure for European payments
435
-
436
- ## Common Pitfalls
437
-
438
- - **Not Verifying Webhooks**: Always verify webhook signatures
439
- - **Missing Webhook Events**: Handle all relevant webhook events
440
- - **Hardcoded Amounts**: Use cents/smallest currency unit
441
- - **No Retry Logic**: Implement retries for API calls
442
- - **Ignoring Test Mode**: Test all edge cases with test cards
@@ -1,57 +0,0 @@
1
- ---
2
- name: systematic-debugging
3
- description: 4-phase root cause debugging process. Use when fixing bugs or investigating issues.
4
- license: MIT
5
- ---
6
-
7
- # Systematic Debugging
8
-
9
- A structured approach to finding and fixing bugs.
10
-
11
- ## Phase 1: Reproduce
12
-
13
- - Confirm the bug exists
14
- - Document exact steps to reproduce
15
- - Identify the expected vs actual behavior
16
- - Create a minimal test case
17
-
18
- ## Phase 2: Isolate
19
-
20
- - Narrow down the problem area
21
- - Use binary search to find the failing component
22
- - Add logging or breakpoints strategically
23
- - Check recent changes that might have caused the issue
24
-
25
- ## Phase 3: Identify Root Cause
26
-
27
- - Don't just fix symptoms
28
- - Trace the issue to its origin
29
- - Understand WHY it's happening
30
- - Consider related areas that might be affected
31
-
32
- ## Phase 4: Fix and Verify
33
-
34
- - Make the minimal fix required
35
- - Add a regression test
36
- - Verify the fix doesn't break other functionality
37
- - Document the fix for future reference
38
-
39
- ## Techniques
40
-
41
- ### Root Cause Tracing
42
-
43
- - Follow the data flow backwards
44
- - Check all inputs and outputs
45
- - Verify assumptions at each step
46
-
47
- ### Defense in Depth
48
-
49
- - Add validation at multiple layers
50
- - Fail fast with clear error messages
51
- - Log important state changes
52
-
53
- ### Condition-Based Waiting
54
-
55
- - Avoid arbitrary sleep/delays
56
- - Wait for specific conditions
57
- - Use timeouts with clear error messages