我正在试图验证PayOne (https://www.payone.de/en/)上的信用卡。
我从文档According to 3.4.1 Verifying credit cards (creditcardcheck)和3.1.2 Standard parameter部分获得的params列表(您可以在这里请求它,https://www.payone.de/en/contact/)。
# build hash on server side:
import hmac
import hashlib
params = {
'aid': '123456',
'api_version': '3.12',
'mid': '123456',
'mode': 'test',
'portalid': '1234567',
'responsetype': 'JSON',
'request': 'creditcardcheck',
'storecarddata': 'yes'
}
message = ''.join([params[k] for k in sorted(params)])
return hmac.new(b'some-secret-key!', msg=message.encode('utf-8'), digestmod=hashlib.sha384).hexdigest(){ "customermessage":“处理此事务时发生错误(参数错误)”、“错误代码”:"2007“、”错误消息“:"Hash不正确”、“状态”:“错误”}
我使用python3.5和angular2。
我在这里做错了什么?
PS:
PPS:
在web接口:https://pmi.pay1.de/merchants/?navi=portal&rc=1 (Method hash calculation*: SHA2-384 (recommended method))中选择了哈希方法。

发布于 2017-01-23 11:39:12
解决方案是不带api_version参数的调用端点:
# build hash on server side:
import hmac
import hashlib
params = {
'aid': '123456',
# 'api_version': '3.12',
'mid': '123456',
'mode': 'test',
'portalid': '1234567',
'responsetype': 'JSON',
'request': 'creditcardcheck',
'storecarddata': 'yes'
}
message = ''.join([params[k] for k in sorted(params)])
return hmac.new(b'some-secret-key!', msg=message.encode('utf-8'), digestmod=hashlib.sha384).hexdigest()PS
同时,api_version作为节3.1.2 Standard parameter中的必需参数和应该在节3.1.4 Calculation of the HASH value处进行散列的参数被注意到。所以看起来像在文档中键入。
发布于 2017-01-19 14:04:24
默认情况下,payone商家帐户使用md5而不是sha384
# build hash on server side:
import hmac
import md5
import hashlib
params = {
'request': 'creditcardcheck',
'responsetype': 'JSON',
'mode': 'test',
'mid': '12345',
'aid': '54321',
'portalid': '2222222',
'encoding': 'UTF-8',
'storecarddata': 'yes',
}
message = ''.join([params[k] for k in sorted(params)])
print message
m = hashlib.md5()
m.update(message)
m.update("secretkey")
print m.hexdigest()这一产出如下:
54321UTF-812345test2222222creditcardcheckJSONyes
a435bff18234ec02a2dffa4d4850a08f然后,打开URL,并确保在URL中传递的所有参数(除了信用卡参数(和回调方法)都在散列中。在这个例子中,它是:
https://stackoverflow.com/questions/41742455
复制相似问题