Skip to content

tsinglinrain/WeChatPay_to_Notion

Repository files navigation

WeChatPay_to_Notion

Static Badge Static Badge Static Badge Static Badge Static Badge Static Badge

[English] | [中文(繁體)]

Bill2Notion_zh_cn
Bill2Notion_zh_cn
导入效果静态图
visualization_static
项目具体偏向代码的流程图
Bill_to_Notion_excalidraw

其他说明

寻找相关记账的模板,配合使用效果更佳哦。

没有使用WeChat Pay以及Alipay的官方API)微信支付和支付宝官方API仅仅对商户开放使用,普通人目前无法使用。
详情点击:
简介-接口规则 | 微信支付商户平台文档中心
查询账单接口 - 支付宝文档中心 (alipay.com)

灵感来源于少数派这篇文章,感谢少数派提供的思路。

快速开始

wechatpay_bill aliapy_bill
  • 拷贝示例数据库,建议duplicate账单导入Notion模板,熟悉之后可自行修改

  • 内部集成认证流程设置

    Notion Integration

    可以参考官方文档Internal integration auth flow set-up

    键入https://www.notion.so/profile/integrations

    Notion_Integration_step1 Notion_Integration_step2 Notion_Integration_step3 Notion_Integration_step4 Notion_Integration_step5 Notion_Integration_step6 Notion_Integration_step7 Notion_Integration_step8
  • 下载本项目

  • 安装所需库

    pip install -r requirements.txt
  • 新版本配置方式(推荐): 使用环境变量配置

    本项目现在支持环境变量配置,更适合Docker部署:

    # 1. 复制环境变量模板文件
    cp .env.template .env
    
    # 2. 编辑 .env 文件,填入您的配置信息
    # [email protected]
    # EMAIL_PASSWORD=your_email_password
    # EMAIL_IMAP_URL=imap.example.com
    # NOTION_DATABASE_ID=your_notion_database_id
    # NOTION_TOKEN=your_notion_token
    database_id details
    https://www.notion.so/tsinglin/68111a1sssssss487a884cafcd5333310c?v=3d0c405e7cae405599aed2fe0f5233cc
    
    database_id: 68111a1sssssss487a884cafcd5333310c
    
  • 账单发送到邮箱后,会有消息告知密码。请复制此密码,自己邮箱发送密码给自己格式必须如下

    wechatpay解压密码110110
    alipay解压密码110110
    
    格式具体示例 Notion_Integration_step8

    即自己发给自己且标题必须形为alipay解压密码123456或者wechatpay解压密码123456,原因是代码规定如此,改了必报错。

    def get_passwd(self):
      # 检查邮件发件邮箱是否是自己的邮箱
      flag = False
      if self.from_addr == self.username:
          print("Subject,from get_passwd:", self.subject)
          if self.payment_platform == "alipay":
              if re.match("^alipay解压密码[0-9]{6}$", self.subject):
                  print("Subject:", self.subject)
                  self.paswd = self.subject[-6:]
                  print("Password:", self.paswd)
                  flag = True
          elif self.payment_platform == "wechatpay":
              if re.match("^wechatpay解压密码[0-9]{6}$", self.subject):
                  print("Subject:", self.subject)
                  self.paswd = self.subject[-6:]
                  print("Password:", self.paswd)
                  flag = True
      return flag

运行

本地Python运行

  • 运行main.py

    python main.py

Docker运行(暂时没有上线)

  • 使用 docker compose(推荐)

    # 1. 确保已配置 .env 文件
    cp .env.template .env
    # 编辑 .env 文件填入配置信息
    
    # 2. 构建并运行
    docker compose up --build
  • 直接使用 Docker

    # 构建镜像
    docker build -t wechatpay-to-notion .
    
    # 运行容器
    docker run --rm \
      -e EMAIL_USERNAME="[email protected]" \
      -e EMAIL_PASSWORD="your_email_password" \
      -e EMAIL_IMAP_URL="imap.example.com" \
      -e NOTION_DATABASE_ID="your_notion_database_id" \
      -e NOTION_TOKEN="your_notion_token" \
      -v $(pwd)/attachment:/app/attachment \
      -v $(pwd)/bill_csv_raw:/app/bill_csv_raw \
      wechatpay-to-notion

自定义

pass

下一步计划

  • Linux环境下自动化

  • 导入成功后邮件返回提醒

  • 可以设置每月自动导出提醒

Star History

Star History Chart

About

Notion API记账|将导出的微信支付宝付款账单再次导入至Notion(注意:没有使用WeChat Pay, Alipay官方API)

Topics

Resources

License

Stars

Watchers

Forks

Languages