当前位置: 首页 > Skill >

Alipay

Alipay

Alipay

实现网页和移动端支付宝集成,具备签名请求安全、网关对齐和生产就绪的支付操作能力。

1.0.0 2026.11.06 803
获取Skill文件查看使用说明
类 别:PHP 支付宝接口对接教程 作 者:周辰 许可证: 更新时间:2026.11.06
本文目录展开

Setup

On first use, read setup.md and confirm platform, PSP, and release target before making code changes.

When to Use

User needs Alipay in checkout, subscriptions, or cross-border wallet flows. Agent handles architecture decisions, signing strategy, gateway integration, rollout validation, and post-launch operations.

Architecture

Memory lives in ~/alipay/. See memory-template.md for setup and status fields.

~/alipay/
|-- memory.md                 # Project snapshot, risk status, and rollout state
|-- implementations.md        # Selected approach and platform notes
|-- validation-log.md         # Test evidence and environment results
`-- incidents.md              # Failed payments, root causes, and fixes

Quick Reference

Use the smallest relevant file for the current task.

Topic File
Setup flow setup.md
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: ALIPAY_APP_ID
  • CLI tools for diagnostics: curl, jq
  • Access to Alipay merchant console and target PSP account

Never ask users to paste private keys, full signed payloads, or PSP secrets into chat.

Data Storage

Local notes stay under ~/alipay/:

  • 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 mobile checkout conversion
  • Faster repeat purchases
  • Lower payment friction for domestic and cross-border users
  • Fewer payment failures

Then choose one primary path:

  • Web or H5 checkout with Alipay gateway redirect flow
  • In-app checkout with Alipay SDK handoff
  • PSP-mediated integration path

Do not mix paths in one patch unless the user asks for a migration plan.

2. Require Merchant and Environment Prerequisites

Before implementation, confirm:

  • Alipay app id exists for the correct account
  • Gateway keys and certificates match the environment
  • Notify and return URLs are configured and reachable
  • Test and production credentials are separated

If prerequisites are missing, pause coding and produce a concrete prerequisite checklist.

3. Enforce Server Truth for Amounts and Currency

Amounts and currency must match across:

  • Client payment request payload
  • Server-side order totals
  • Alipay authorization and capture calls

Never trust client totals for final charge amount.

4. Make Signing and Callback Verification Explicit

Treat signing and verification as required controls:

  • Sign outgoing requests with the approved key strategy
  • Verify callback signatures before changing order state
  • Reject unsigned or invalid callbacks deterministically

Never mark a payment successful before signature checks pass.

5. Keep Payment Payload Handling Minimal and Auditable

Treat Alipay payloads as sensitive:

  • Forward payload only to backend or PSP
  • Persist metadata only (request id, status, amount, currency)
  • Never store raw signed payloads in logs, notes, or screenshots

6. Build Idempotent and Recoverable Payment Steps

Require idempotency and reconciliation for all critical calls:

  • Authorization request
  • Capture request
  • Refund or close operations

Every retried request must reuse stable idempotency keys to prevent duplicates.

7. Separate Test and Production Release Gates

Do not recommend production rollout until all gates pass:

  • Test success, decline, cancellation, and timeout paths are covered
  • Device and browser matrix is complete for supported audience
  • Fallback card or alternative checkout works when Alipay is unavailable
  • Failure observability and alerts are active

Common Traps

  • Shipping test gateway config to production -> live checkout failures
  • Skipping callback signature verification -> fraudulent or duplicated state transitions
  • Mismatching charset or signing parameters -> request rejection at gateway
  • Trusting client totals -> mismatch between authorized and captured amounts
  • 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://openapi.alipay.com/gateway.do Signed payment requests and metadata Production Alipay gateway operations
https://openapi-sandbox.dl.alipaydev.com/gateway.do Signed payment requests and metadata Sandbox validation and integration testing
https://global.alipay.com Documentation and account console traffic Merchant setup and operational reference

No other data should be sent externally unless the selected PSP requires it.

Security & Privacy

Data that leaves your machine:

  • Alipay request payloads needed for wallet flow
  • Payment metadata and signed requests sent to configured PSP or backend

Data that stays local:

  • Integration notes and rollout state under ~/alipay/
  • Validation evidence and failure logs without raw signed payloads

This skill does NOT:

  • Store raw signed request payloads in memory files
  • Skip mandatory merchant and callback verification requirements
  • Enable production release without explicit readiness checks

Trust

Alipay integrations depend on Alipay 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
  • billing - Billing models, reconciliation, and payment lifecycle decisions
  • api - Reliable backend API contracts and failure-safe integrations
  • auth - Authentication and session hardening in transaction flows
  • android - Android checkout implementation and runtime troubleshooting patterns

Feedback

  • If useful: clawhub star alipay
  • Stay updated: clawhub sync

相关文章

更多
ThinkPHP隐藏入口文件后处理支付宝回调含问号URL的方法

在ThinkPHP中设置URL_MODEL=2以隐藏index.php时,支付宝等第三方接口返回的含问号(?)参数的URL会被框架错误转换导致无法访问。由于控制器内动态修改C('URL_MODEL')无效且会触发404,需在入口文件App::run()执行前,通过判断REQUEST_URI包含特定路径来临时将URL_MODEL设为1,从而兼容此类特殊请求,同时保持其他页面使用友好的伪静态URL。

2026.11.15 786
PHP服务端集成支付宝APP支付全流程及常见坑点解析

本文详细记录了在PHP后端集成支付宝APP支付接口的完整流程,涵盖应用创建、SDK下载及核心代码实现。针对开发中常见的40001签名无效及HTTPS双向认证导致$_POST为空等棘手问题,提供了具体的排查思路与解决方案,帮助开发者快速避坑并成功完成支付功能对接。

2026.01.29 786
PHP接入支付宝接口及ThinkPHP集成详解

本文详细记录了PHP接入支付宝接口的完整流程,涵盖从应用创建、SDK下载与配置到核心文件解析。针对ThinkPHP 3.2.3框架环境,提供了将支付宝类库嵌入项目的具体步骤,包括命名空间调整、控制器新建及参数配置,帮助开发者快速实现简单的支付功能。

2026.10.11 762
PHP App支付宝异步回调验签与订单处理详解

本文详细解析PHP环境下支付宝App支付的异步通知(回调)处理流程。重点涵盖回调地址配置、使用rsaCheckV1进行签名验证的注意事项,包括公钥来源及方法差异。同时介绍如何接收POST参数并校验订单金额、商家编号等关键信息,结合TP5框架演示基于数据库事务的库存扣减与订单状态更新逻辑,确保支付数据的最终一致性。

2026.03.21 386
PHP实现支付宝与微信支付异步回调处理及重复通知解决

在开发PHP版支付宝和微信支付接口时,常遇到异步回调频繁触发导致数据重复入库的问题。根本原因在于未正确返回服务器要求的确认字符:支付宝需输出“success”,微信需返回XML格式的SUCCESS响应。本文整理了两家官方文档关于notify_url的特性要求,并提供代码示例说明如何正确处理验签、业务逻辑及最终的状态返回,以停止支付平台的重复通知机制。

2026.01.28 328
ThinkPHP对接支付宝即时到账异步回调与调试示例

本文介绍在ThinkPHP框架中处理支付宝即时到账接口异步通知回调的具体实现。重点讲解如何通过配置notify_url接收支付宝服务器推送的支付结果,并强调必须使用异步通知而非跳转回调以确保订单状态准确更新。针对异步环境无法直接打印输出的调试难题,提供利用file_put_contents生成log.txt文件记录执行流程和数据的方法,帮助开发者快速定位问题。

2025.09.17 322
Skill 文件
  • SKILL.md
    • Setup
    • When to Use
    • Architecture
    • Quick Reference
    • Requirements
    • Data Storage
    • Core Rules
      • 1. Confirm Business Goal Before Choosing Integration Path
      • 2. Require Merchant and Environment Prerequisites
      • 3. Enforce Server Truth for Amounts and Currency
      • 4. Make Signing and Callback Verification Explicit
      • 5. Keep Payment Payload Handling Minimal and Auditable
      • 6. Build Idempotent and Recoverable Payment Steps
      • 7. Separate Test and Production Release Gates
    • Common Traps
    • External Endpoints
    • Security & Privacy
    • Trust
    • Related Skills
    • Feedback
  • 项目或源文件

相关 Skill

更多
service-qa-coach service-qa-coach Review support quality for chat, email, phone, social DM, or marketplace service teams. Use when a team needs a QA scorecard, failure-mode analysis, coaching plan, calibration checklist, or service-improvement brief without live ticketing, CRM, or contact-center system access.
高中数学作业批改助手 高中数学作业批改助手 >图片识别 直接读取学生手写作答照片,识别公式、符号、步骤 🧮 自动推导 根据题目自动生成参考答案和评分细则,无需教师预设 📊 逐步给分 每个关键步骤独立评分,体现过程分 📝 结构化报告 输出含识别内容、参考答案、逐步评分、改进建议的完整报告 🗂 批量批改 支持一次性批改多道题,最终汇总得分表
Vibration Analysis Vibration Analysis 分析来自CMS趋势、RMS/峰值、频谱及SCADA报警的风机传动链(主轴、齿轮箱、发电机)振动数据。
Traditional Bone Tool Making Basics Traditional Bone Tool Making Basics Use when you need custom, durable, repairable tools like awls, needles, scrapers, harpoons, or fishing hooks made from local animal bones or antlers and comm...
音频混音工具 音频混音工具 名称:Sound Mixing Tool(标识 sound-mixing-tool) 短简介(≤60字):音乐/音效响度精确对齐 + 融合混音工作流:用 ffmpeg 两段式 loudnorm 把多组素材 LUFS 偏差压到 <0.10,再最小干预融合、导出可进引擎的独立分轨。 标签/关键词:音频混音 响度匹配 LUFS ffmpeg 游戏音频 音效设计 Wwise FMOD 分轨导出 后期处理 触发词:混音 · 响度匹配 · LUFS 对齐 · MIX 版本 · 音乐音效分轨 · 融合 · 不打架 · 不能盖住 适用场景 :游戏音频集成、影视短视频配乐、播客后期