Code Monkey home page Code Monkey logo

Comments (4)

fzlee avatar fzlee commented on August 17, 2024

问题的直接原因是python2里面的str类型格式化unicode时出错了。

你可否执行以下逻辑并且附上结果?

import json
from flask import Flask
from flask import request
app = Flask(__name__)


@app.route('/', methods=["GET", "POST"])
def hello_world():
    data = request.form.to_dict()
    signature = data.pop("sign")

    print(json.dumps(data))
    print(signature)

    alipay.verify_wap_notify(data, signature)
    return 'Hello, World!'

from alipay.

fzlee avatar fzlee commented on August 17, 2024

0.6.6已经修复了这个问题,麻烦你帮忙验证一下吧。

from alipay.

openpython avatar openpython commented on August 17, 2024

你好,出现了新的错误,ValueError: RSA key format is not supported,我使用的是RSA2,按alipay doc的openssl教程生成的rsa_private_key.pem、rsa_public_key.pem 并上传至服务器的/home/alipay_cert/目录下。
alipay_wap = AliPay(appid="2017*********", app_notify_url='http://pay.****.com/alipay/mobile_notify_result/', app_private_key_path="/home/alipay_cert/rsa_private_key.pem", app_alipay_public_key_path="/home/alipay_cert/alipay_public_key_sha256.pem",sign_type="RSA2")
错误如下:

Traceback (most recent call last):
File "/var/www/pay..com/wsgi.py", line 9, in application
return app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "/var/www/pay.
.com/views/merchant.py", line 235, in alipay_mobile_notify_result
success = alipay_wap.verify_wap_notify(data, signature)
File "/usr/local/lib/python2.7/dist-packages/alipay/init.py", line 221, in verify_wap_notify
return self.verify_app_notify(data, signature)
File "/usr/local/lib/python2.7/dist-packages/alipay/init.py", line 218, in verify_app_notify
return self._verify_data(data, signature, self.__app_alipay_public_key_path)
File "/usr/local/lib/python2.7/dist-packages/alipay/init.py", line 248, in _verify_data
return self._verify(message, signature, alipay_public_key_path)
File "/usr/local/lib/python2.7/dist-packages/alipay/init.py", line 229, in _verify
key = RSA.importKey(fp.read())
File "/usr/local/lib/python2.7/dist-packages/Crypto/PublicKey/RSA.py", line 682, in importKey
raise ValueError("RSA key format is not supported")
ValueError: RSA key format is not supported

from alipay.

openpython avatar openpython commented on August 17, 2024

已搞定

from alipay.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.