支付宝农产品收购(付款即开票) · 通知与测试
17 拉取通知
拉取支付宝推来的订单状态变更、供应商(农户确认合作)变更通知;只返回属于你的。
地址
POST https://openapi.kailingteck.com/api/v1/alipay-agri/notify/pull对应支付宝接口:无(开灵API中台自有接口)
鉴权、外壳、预检(dry_run)、错误码见 调用约定。
请求参数
字段名照支付宝官方文档;中台在你没传时补的值写在「默认」里。不符合官方要求的参数中台直接拦下(CYT_40001),不会发给支付宝。
| 字段 | 类型 | 必填 | 长度 | 说明 |
|---|---|---|---|---|
| after_id | Number | 可选 | 上次拿到的最大 notify_id,首次传 0 默认:0 | |
| limit | Number | 可选 | 1~100,超过 100 按 100 默认:50 |
返回 data
支付宝返回的业务字段原样保留;中台另补的字段已注明。
items[]:notify_id、kind(order / supplier)、msg_method、received_at、verified(验签是否通过)、biz(支付宝消息原文解析结果,含 tax_no)next_after_id / has_more:下次从哪接着拉、还有没有
注意
- 通知只用来「早知道」,以 11 查询结果为准;拉不到也不影响流程。
- 归属规则:按凭据(appKey)归属,即你这把凭据经中台建的供应商、下的订单;别的凭据的通知拉不到。一把凭据下有多家收购商时,按 biz.tax_no 分拣。
实测示例
脚本 17_notify_pull.py(Python 3.6+ 标准库,公共模块 kl_agri.py)。以下运行记录是测试环境实跑的请求和返回,个人信息已脱敏。
#!/usr/bin/env python3
"""17 拉取通知:订单状态变更、农户确认合作。after_id 记在本地,下次接着拉。"""
import sys
from kl_agri import *
after = int(arg(1, "KL_AFTER_ID", "notify_after_id", "0"))
resp, ok_ = run("17_notify_pull", "notify/pull", {"after_id": after, "limit": 50})
if ok_:
for it in resp["data"]["items"]:
b = it["biz"]
print(it["notify_id"], it["kind"], b.get("order_status") or b.get("confirmation_status"), b.get("outer_order_id") or b.get("outer_supplier_id"))
state_set(notify_after_id=resp["data"]["next_after_id"])
17_notify_pull(异常分支) · 2026-10-25 · HTTP 200 · 通过
请求体
{
"after_id": 0,
"limit": 50
}返回
{
"code": "CYT_00000",
"msg": "success",
"data": {
"items": [
{
"notify_id": 117,
"kind": "supplier",
"msg_method": "alipay.commerce.ec.recyclinginvoice.companysupplier.notify",
"alipay_notify_id": "sbx02013441500631153933",
"env": "sandbox",
"received_at": "2026-10-25 16:24:06",
"verified": true,
"biz": {
"outer_supplier_id": "KLAGRIFARMER26102512240637228",
"supplier_id": "2026102655781135967218174991",
"tax_no": "91110108MA01AGRP8X",
"confirmation_status": "CONFIRMED"
}
},
{
"notify_id": 118,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx34216817972175148603",
"env": "sandbox",
"received_at": "2026-10-25 16:24:06",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240651483",
"order_id": "2026102629783220338950807601",
"order_status": "WAIT_CONFIRM",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": ""
}
},
{
"notify_id": 119,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx32879686217264032729",
"env": "sandbox",
"received_at": "2026-10-25 16:24:06",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240651483",
"order_id": "2026102629783220338950807601",
"order_status": "SUCCESS",
"blue_invoice_status": "INVOICE_SUCCESS",
"red_invoice_status": "",
"pay_status": "PAY_SUCCESS",
"invoice_no": "26333842846494017587"
}
},
{
"notify_id": 120,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx91091008318759007411",
"env": "sandbox",
"received_at": "2026-10-25 16:24:06",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240651483",
"order_id": "2026102629783220338950807601",
"order_status": "SUCCESS",
"blue_invoice_status": "INVOICE_SUCCESS",
"red_invoice_status": "INVOICE_SUCCESS",
"pay_status": "PAY_SUCCESS",
"invoice_no": "26333842846494017587"
}
},
{
"notify_id": 121,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx03404044724338377262",
"env": "sandbox",
"received_at": "2026-10-25 16:24:06",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240685794",
"order_id": "2026102680507294560612811264",
"order_status": "WAIT_CONFIRM",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": ""
}
},
{
"notify_id": 122,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx91985479091118639814",
"env": "sandbox",
"received_at": "2026-10-25 16:24:06",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240685794",
"order_id": "2026102680507294560612811264",
"order_status": "CANCEL",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": ""
}
},
{
"notify_id": 123,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx76430585327629036294",
"env": "sandbox",
"received_at": "2026-10-25 16:24:06",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240696719",
"order_id": "2026102692501199469198203394",
"order_status": "WAIT_CONFIRM",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": ""
}
},
{
"notify_id": 124,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx06752857956242484117",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240696719",
"order_id": "2026102692501199469198203394",
"order_status": "WAIT_PAY",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": "PAY_CANCELED"
}
},
{
"notify_id": 125,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx76623475113221731993",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240696719",
"order_id": "2026102692501199469198203394",
"order_status": "SUCCESS",
"blue_invoice_status": "INVOICE_SUCCESS",
"red_invoice_status": "",
"pay_status": "PAY_SUCCESS",
"invoice_no": "26333471249031884031"
}
},
{
"notify_id": 126,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx32264652894569671532",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240711889",
"order_id": "2026102630913024454462983170",
"order_status": "WAIT_CONFIRM",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": ""
}
},
{
"notify_id": 127,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx14649947156572031498",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240711889",
"order_id": "2026102630913024454462983170",
"order_status": "SUCCESS",
"blue_invoice_status": "INVOICE_FAILED_RETRYABLE",
"red_invoice_status": "",
"pay_status": "PAY_SUCCESS"
}
},
{
"notify_id": 128,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx56599373923407606216",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240711889",
"order_id": "2026102630913024454462983170",
"order_status": "SUCCESS",
"blue_invoice_status": "INVOICE_SUCCESS",
"red_invoice_status": "",
"pay_status": "PAY_SUCCESS",
"invoice_no": "26337454898033797946"
}
},
{
"notify_id": 129,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx59484076437871891931",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240732129",
"order_id": "2026102619941073854692987061",
"order_status": "WAIT_CONFIRM",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": ""
}
},
{
"notify_id": 130,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx29444196707518071138",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240732129",
"order_id": "2026102619941073854692987061",
"order_status": "WAIT_AUDIT",
"blue_invoice_status": "",
"red_invoice_status": "",
"pay_status": ""
}
},
{
"notify_id": 131,
"kind": "order",
"msg_method": "alipay.commerce.ec.recyclinginvoice.order.notify",
"alipay_notify_id": "sbx68713820314008181113",
"env": "sandbox",
"received_at": "2026-10-25 16:24:07",
"verified": true,
"biz": {
"tax_no": "91110108MA01AGRP8X",
"product_id": "2024120022147211",
"outer_order_id": "KLAGRIPO26102512240732129",
"order_id": "2026102619941073854692987061",
"order_status": "SUCCESS",
"blue_invoice_status": "INVOICE_SUCCESS",
"red_invoice_status": "",
"pay_status": "PAY_SUCCESS",
"invoice_no": "26331071282413534136"
}
}
],
"next_after_id": 131,
"has_more": false
}
}