| 12345678910111213141516171819202122 |
- import unittest
- class TestAlipayIntegration(unittest.TestCase):
- """
- {'charset': 'UTF-8', 'biz_content': '{"consume_amount":"0.50","notify_reason":"COLLECT","account_id":"2088480767913636","user_id":"2088351626760143","pay_no":"20260423110070100006200010873232","employee_id":"2300063243895143","consume_type":"TRANSFER","enterprise_id":"2088480767913636","peer_pay_amount":"0.50","notify_msg":"账单归集","gmt_biz_create":"2026-04-23 11:47:03"}', 'utc_timestamp': '1776916024296', 'sign': 'b0g4sUINZZ9VIjqQJUzB6LE4kYuB9BzbHNpkhHgBgNGhV9hjaYEApZlUFlIGYM6thHJAvcnqS8e7hgMj1zno+6ian4hSTn22vurE6IoSWd8ILPKsGn4WSBzJW5jEhvpKFsNOLE+Epl2WYOhiRQ2IOXDDZt/SNO33xlVZSavI8NhdXtWv6NL7/7amVRO1yf4SJPVJoTpVzHg39MwWfIUUu7ueIB9HVcH9az1NAxLwJzKOm5qoMI5J4Jy1IQigyt8MZDLkAucG33D8R3MRd3SULFM3f9ebVRCWYjfCVfyXyNBDY1F14GAZokh+fW7EvnCR/BLykNC9hJN5y32r0NeStw==', 'app_id': '2021005122654283', 'version': '1.1', 'sign_type': 'RSA2', 'notify_id': '2026042300262114704018926600109168', 'msg_method': 'alipay.commerce.ec.consume.change.notify'}
-
- """
- def test_alipay_sign(self):
- from fastapi.datastructures import FormData
- from app.plugin.module_payment.notification.schemas import parse_alipay_notify_form_data
- from app.plugin.module_payment.notification.service import NotificationService
- from_data = FormData([('charset', 'UTF-8'), ('biz_content', '{"account_id":"2088480767913636","action":"ENTERPRISE_AUTH","enterprise_id":"2088480767913636","out_biz_no":"1244338814273589248","change_time":"2026-04-22 14:40:35"}'), ('utc_timestamp', '1776840036107'), ('sign', 'DijKN7XmItCs8OF2UYDNpKFsK6HHViMrUmFyUYj7Xvk+Xjakq7q0wMohfV19dHUPr7ttqt7E3ajlsXUzf4f2J23eWZThs3PG/6DsNraqpVDWYpZCywLglpiTMG9QApRvNtO+dhCtRsgR+sjNgmlk1fVG11Q2pnEwBPhuMEk8PYKygOlN17imW+eIVt3QeFZD5M/NVH3CKGL3QuFuaA/6iA3KIobdXRvuwwej/E4D9lQznq2cF6pO0fE3r+Ae6d0y0DonVqKItUYsSKKq7NfHWykLV003SKbFh7u83tVMmVEiaj8VxpiHyb13+d2U4w9mfrA3q19uhJLW8PDwZojDmQ=='), ('app_id', '2021005122654283'), ('version', '1.1'), ('sign_type', 'RSA2'), ('notify_id', '2026042200262144035056476562005865'), ('msg_method', 'alipay.commerce.ec.enterprise.change.notify')])
- notify_data = parse_alipay_notify_form_data(from_data)
- print(notify_data)
- NotificationService.verify_sign(notify_data)
- if __name__ == "__main__":
- unittest.main()
- # uv run pytest .\tests\test_alipay_sign.py -v -s
|