工具用于调用支付宝接口验证银行卡号(如6250505005050505)有效性,并返回其银行卡信息如发卡行。

    1. # -*-coding:utf-8-*-
    2. # @auth ivan
    3. # @time 20190128 15:44
    4. # @goal run 014.Test_CardBinCheck
    5. import requests
    6. sess = requests.session()
    7. url = "https://ccdcapi.alipay.com/validateAndCacheCardInfo.json?_input_charset=utf-8&cardNo=X-X&cardBinCheck=true"
    8. p = sess.get(url.replace("X-X", "6250505005050505"))
    9. print(p.content)
    10. b'{"cardType":"CC","bank":"GCB","key":"1544449879161-9023-11.145.199.41-706583656","messages":[],"validated":true,"stat":"ok"}'
    11. p = sess.get(url.replace("X-X", "1500676767676767"))
    12. print(p.content)
    13. b'{"messages":[{"errorCodes":"CARD_BIN_NOT_MATCH","name":"cardNo"}],"validated":false,"stat":"ok","key":"1500676767676767"}'