Setup
On first use, read setup.md and confirm platform, PSP, and release target before making code changes.
When to Use
User needs Apple Pay for checkout, subscriptions, or wallet-first conversion improvements. Agent handles architecture choice, merchant setup, token safety, launch validation, and post-launch operations.
Architecture
Memory lives in ~/apple-pay/. See memory-template.md for setup and status fields.
CODEBLOCK0
Quick Reference
Use the smallest relevant file for the current task.
| Topic | File |
|---|
| Setup flow | INLINECODE3 |
| Memory template |
memory-template.md |
| Implementation plan |
implementation-playbook.md |
| Validation matrix |
validation-checklist.md |
| Failure recovery |
failure-handling.md |
| Release and operations |
launch-playbook.md |
| Recurring and subscription flows |
recurring-payments.md |
Requirements
- - Environment variable: INLINECODE10
- CLI tools for diagnostics:
curl, INLINECODE12 - Access to Apple merchant account assets for the target environment
Never ask users to paste private keys or full certificate private material into chat.
Data Storage
Local notes stay under ~/apple-pay/:
- - memory file for current state and integration decisions
- validation log file for test outcomes and evidence
- incidents file for failure signatures and mitigations
Core Rules
1. Confirm Business Goal Before Choosing Integration Path
Start by identifying the target outcome:
- - Higher checkout conversion
- Faster repeat purchases
- Cleaner mobile payment UX
- Lower payment failures
Then choose one primary path:
- - Web with Apple Pay JS and merchant session backend
- Native iOS with PassKit
- PSP-mediated integration (for example Stripe, Adyen, Braintree)
Do not mix paths in one patch unless user asks for a migration plan.
2. Require Merchant and Domain Prerequisites
Before implementation, confirm:
- - Merchant ID exists and matches target environment
- Payment processing certificate exists and is valid
- Domain association file is hosted and reachable for web
- Sandbox and production credentials are separated
If any prerequisite is missing, pause coding and produce a concrete prerequisite checklist.
3. Enforce Server Truth for Amounts and Currency
Amounts and currency must match across:
- - Client request payload
- Server-side cart or order totals
- PSP authorization and capture calls
Never trust client totals for final charge amount.
4. Keep Token Handling Minimal and Auditable
Treat Apple Pay payment tokens as sensitive:
- - Forward token payload only to backend or PSP
- Persist metadata only (request id, status, amount, currency)
- Never store raw token payload in logs, notes, or screenshots
5. Build Idempotent and Recoverable Payment Steps
Require idempotency and reconciliation for all critical calls:
- - Authorization request
- Capture request
- Refund or void operations
Every retried request must reuse stable idempotency keys to prevent duplicates.
6. Separate Sandbox and Production Release Gates
Do not recommend production rollout until all gates pass:
- - Sandbox success, decline, cancellation, and timeout paths are tested
- Device and browser matrix is complete for supported audience
- Fallback card or alternative checkout works when Apple Pay is unavailable
- Failure observability and alerts are active
7. Include Support and Incident Paths in Every Delivery
For each implementation, include:
- - What customer sees on success and failure
- Which errors are recoverable vs terminal
- What support team should do first for each failure class
- Rollback or kill-switch decision point
Prefer stable payment reliability over feature breadth.
Common Traps
- - Running merchant validation from the client -> exposes sensitive flow and fails reviews
- Trusting client-side totals -> mismatch between authorized and captured amounts
- Reusing sandbox credentials in production -> live checkout failures at launch
- Treating simulator-only tests as release evidence -> real devices still fail
- Missing idempotency on retries -> duplicate charges and refund overhead
- Launching without fallback checkout -> conversion loss when wallet is unavailable
External Endpoints
| Endpoint | Data Sent | Purpose |
|---|
| https://apple-pay-gateway.apple.com | Merchant validation request payload | Establish merchant session for Apple Pay on the web |
| https://apple-pay-gateway-cert.apple.com |
Merchant validation request payload (sandbox/cert path) | Validate merchant sessions in non-production environments |
| https://appleid.apple.com | Account and merchant auth metadata | Apple account and merchant identity operations |
No other data should be sent externally unless the selected PSP requires it.
Security & Privacy
Data that leaves your machine:
- - Merchant validation requests to Apple endpoints
- Payment tokens sent to the configured PSP or backend
Data that stays local:
- - Integration notes and rollout state under INLINECODE14
- Validation evidence and failure logs without raw tokens
This skill does NOT:
- - Store raw payment tokens in memory files
- Skip mandatory Apple merchant requirements
- Enable production release without explicit readiness checks
Trust
Apple Pay integrations depend on Apple infrastructure and the chosen PSP.
Only install and run this skill if you trust those services and your payment backend.
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
payments - General payment design and checkout decision frameworks - INLINECODE17 - Apple ecosystem account and operational workflows
- INLINECODE18 - iOS implementation and device-level debugging patterns
- INLINECODE19 - Authentication and session hardening in transaction flows
- INLINECODE20 - Reliable backend API contracts and failure-safe integrations
Feedback
- - If useful: INLINECODE21
- Stay updated: INLINECODE22
设置
首次使用时,请先阅读 setup.md,并在进行代码修改前确认平台、支付服务提供商(PSP)和发布目标。
使用场景
用户需要通过 Apple Pay 完成结账、订阅或钱包优先的转化优化。智能体负责处理架构选择、商户配置、令牌安全、上线验证以及上线后的运营工作。
架构
记忆文件存放在 ~/apple-pay/ 目录下。有关设置和状态字段,请参阅 memory-template.md。
~/apple-pay/
|-- memory.md # 项目快照、风险状态和发布状态
|-- implementations.md # 所选方案和平台说明
|-- validation-log.md # 测试证据和环境结果
-- incidents.md # 支付失败、根本原因和修复方案
快速参考
根据当前任务使用最小的相关文件。
memory-template.md |
| 实施方案 | implementation-playbook.md |
| 验证矩阵 | validation-checklist.md |
| 故障恢复 | failure-handling.md |
| 发布与运营 | launch-playbook.md |
| 循环支付与订阅流程 | recurring-payments.md |
要求
- - 环境变量:APPLEPAYMERCHANT_ID
- 诊断用 CLI 工具:curl、jq
- 目标环境的 Apple 商户账户资产访问权限
切勿要求用户将私钥或完整的证书私密材料粘贴到聊天中。
数据存储
本地笔记保存在 ~/apple-pay/ 目录下:
- - 记忆文件:记录当前状态和集成决策
- 验证日志文件:记录测试结果和证据
- 事件文件:记录失败特征和缓解措施
核心规则
1. 在选择集成路径前确认业务目标
首先确定目标成果:
- - 提高结账转化率
- 加快重复购买速度
- 优化移动支付用户体验
- 降低支付失败率
然后选择一条主要路径:
- - 使用 Apple Pay JS 和商户会话后端的 Web 方案
- 使用 PassKit 的原生 iOS 方案
- 通过 PSP 中介集成(例如 Stripe、Adyen、Braintree)
除非用户要求迁移计划,否则不要在一个补丁中混合使用多种路径。
2. 要求满足商户和域名前置条件
在实施前,确认:
- - 商户 ID 存在且与目标环境匹配
- 支付处理证书存在且有效
- Web 端域名关联文件已托管并可访问
- 沙箱和生产环境凭据已分离
如果缺少任何前置条件,暂停编码并生成具体的前置条件检查清单。
3. 强制服务器端确认金额和货币
金额和货币必须在以下方面保持一致:
- - 客户端请求负载
- 服务器端购物车或订单总额
- PSP 授权和捕获调用
切勿信任客户端提供的最终扣款金额。
4. 保持令牌处理最小化且可审计
将 Apple Pay 支付令牌视为敏感信息:
- - 仅将令牌负载转发到后端或 PSP
- 仅持久化元数据(请求 ID、状态、金额、货币)
- 切勿在日志、笔记或截图中存储原始令牌负载
5. 构建幂等且可恢复的支付步骤
要求所有关键调用具备幂等性和对账能力:
每次重试请求必须使用稳定的幂等键,以防止重复操作。
6. 分离沙箱和生产环境发布关卡
在所有关卡通过前,不建议进行生产环境发布:
- - 沙箱环境下的成功、拒绝、取消和超时路径均已测试
- 目标受众的设备与浏览器矩阵已完整覆盖
- Apple Pay 不可用时,备用卡或替代结账方式正常工作
- 故障可观测性和告警已启用
7. 每次交付都包含支持和事件处理路径
对于每次实施,需包含:
- - 客户在成功和失败时看到的内容
- 哪些错误可恢复,哪些为终端错误
- 针对每类故障,支持团队应首先采取的措施
- 回滚或终止开关的决策点
优先保证稳定的支付可靠性,而非功能广度。
常见陷阱
- - 从客户端运行商户验证 → 暴露敏感流程并导致审核失败
- 信任客户端总额 → 授权金额与捕获金额不匹配
- 在生产环境复用沙箱凭据 → 上线时实时结账失败
- 仅将模拟器测试视为发布证据 → 真实设备仍会失败
- 重试时缺少幂等性 → 重复扣款和退款开销
- 未设置备用结账方式即上线 → 钱包不可用时转化率下降
外部端点
| 端点 | 发送的数据 | 目的 |
|---|
| https://apple-pay-gateway.apple.com | 商户验证请求负载 | 为 Web 端 Apple Pay 建立商户会话 |
| https://apple-pay-gateway-cert.apple.com |
商户验证请求负载(沙箱/证书路径) | 在非生产环境中验证商户会话 |
| https://appleid.apple.com | 账户和商户认证元数据 | Apple 账户和商户身份操作 |
除非所选 PSP 要求,否则不应向外部发送其他数据。
安全与隐私
离开您机器的数据:
- - 向 Apple 端点发送的商户验证请求
- 发送到已配置 PSP 或后端的支付令牌
留在本地的数据:
- - ~/apple-pay/ 目录下的集成笔记和发布状态
- 不含原始令牌的验证证据和故障日志
本技能不会:
- - 在记忆文件中存储原始支付令牌
- 跳过强制性的 Apple 商户要求
- 在未通过明确就绪检查的情况下启用生产环境发布
信任
Apple Pay 集成依赖于 Apple 基础设施和所选 PSP。
仅当您信任这些服务及您的支付后端时,才安装并运行本技能。
相关技能
如果用户确认,使用 clawhub install 安装:
- - payments - 通用支付设计和结账决策框架
- app-store-connect - Apple 生态系统账户和运营工作流
- ios - iOS 实现和设备级调试模式
- auth - 交易流程中的身份验证和会话加固
- api - 可靠的后端 API 契约和故障安全集成
反馈
- - 如有帮助:clawhub star apple-pay
- 保持更新:clawhub sync