序列项 1:预期字符串,找到 OrderedDict

sequence item 1: expected string, OrderedDict found

我正在尝试执行检查,但出现错误 sequence item 1: expected string, OrderedDict found。它可以连接什么?这是文档中的功能。

https://github.com/cloudipsp/python-sdk/blob/master/cloudipsp/helpers.py#L85

def get_transaction(self, request, signature, origin):
    print(type(origin))  #dict

    data = origin.copy()
    result = None
    trans = None
    if data:
        data['signature'] = signature
        data = dict((k, v) for k, v in data.iteritems() if v not in (None, ''))
        data = OrderedDict(sorted(data.items()))

        if helper.is_valid(data, self.secret_key, self.api.api_protocol):  #sequence item 1: expected string, OrderedDict found

回溯

File "/home/m0nte-cr1st0/.virtualenvs/midgard/local/lib/python2.7/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/home/m0nte-cr1st0/.virtualenvs/midgard/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/home/m0nte-cr1st0/.virtualenvs/midgard/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/m0nte-cr1st0/.virtualenvs/midgard/local/lib/python2.7/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/m0nte-cr1st0/.virtualenvs/midgard/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  58.         return view_func(*args, **kwargs)

File "/home/m0nte-cr1st0/.virtualenvs/midgard/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/m0nte-cr1st0/.virtualenvs/midgard/local/lib/python2.7/site-packages/django/views/decorators/http.py" in inner
  40.             return func(request, *args, **kwargs)

File "/home/m0nte-cr1st0/work_projects/startapp/midgard/payments/views.py" in result
  319.     data, trans, _res = integration.get_transaction(request, signature, origin)

File "/home/m0nte-cr1st0/work_projects/startapp/midgard/fondy/integration.py" in get_transaction
  110.                 str_sign = sep.join([self.secret_key, data])

Exception Value: sequence item 1: expected string, OrderedDict found

我将数据编码为 base64 并重写了 is_valid

def get_transaction(self, request, signature, origin):
    data = origin.copy()
    result = None
    trans = None
    if data:
        data['signature'] = signature
        data = dict((k, v) for k, v in data.iteritems() if v not in (None, ''))
        data = OrderedDict(sorted(data.items()))

        if 'signature' in data:
            result_signature = data['signature']
            del data['signature']
        else:
            raise ValueError('Incorrect data')
        if 'response_signature_string' in data:
            del data['response_signature_string']

        from hashlib import sha1
        from cloudipsp.configuration import __sign_sep__ as sep

        if self.api.api_protocol == '2.0':
            import pickle
            data = pickle.dumps(origin).encode('base64', 'strict')
            str_sign = sep.join([self.secret_key, data])

            calc_sign = sha1(str_sign.encode('utf-8')).hexdigest()
        else:
            data = [secret_key]
            data.extend([str(params[key]) for key in sorted(iter(params.keys()))
                         if params[key] != '' and not params[key] is None])
        signature = sha1(sep.join(data).encode('utf-8')).hexdigest()

        if result_signature == calc_sign: