django-oscar / django-oscar-docdata

Docdata Payments Gateway integration for django-oscar
Apache License 2.0
22 stars 11 forks source link

NotImplementedError: Received unknown reply from DocData. Remote Payment not created. #38

Closed jedie closed 5 years ago

jedie commented 5 years ago

I'm playing a little around and have create a not unique order_id but that's not the point ;)

With the non-unique ID i ran into NotImplementedError:

   File "/usr/local/lib/python3.6/site-packages/oscar_docdata/gateway.py", line 345, in create
     raise NotImplementedError('Received unknown reply from DocData. Remote Payment not created.')
NotImplementedError: Received unknown reply from DocData. Remote Payment not created.

The suds message is:

MESSAGE: b'<?xml version=\'1.0\' encoding=\'UTF-8\'?><createErrors>Merchant order reference is not unique.</createErrors></S:Body></S:Envelope>'

Has createError changes to createErrors ?!?

The code part is:

        # Parse the reply
        if hasattr(reply, 'createSuccess'):
            order_key = str(reply['createSuccess']['key'])
            return CreateReply(order_id, order_key)
        elif hasattr(reply, 'createError'):
            error = reply.createError.error
            log_docdata_error(error, "DocdataClient: failed to create payment for order %s", order_id)
            raise DocdataCreateError(error._code, error.value)
        else:
            raise NotImplementedError('Received unknown reply from DocData. Remote Payment not created.')

So: hasattr(reply, 'createError') must be just changed to hasattr(reply, 'createErrors') ?!?

maerteijn commented 5 years ago

Version 1.2: https://github.com/django-oscar/django-oscar-docdata/blob/22675e3b90f0045cd5fe570559ca52f5fff7a82f/tests/testdata/xsd1-1_2.xsd#L1626

Version 1.3: https://github.com/django-oscar/django-oscar-docdata/blob/master/tests/testdata/xsd1-1_3.xsd#L2467

So yes, it looks like your proposed change is correct.