iyzico / iyzipay-python

iyzipay api python client
MIT License
86 stars 35 forks source link

Unicode issues #20

Closed BodhiSukha closed 7 years ago

BodhiSukha commented 8 years ago

In our tests, API returns encode/decode errors for the unicode objects when the object contains non ascii chars like 'ÖöŞşÇçİıĞğÜü', however it works fine with unicode objects when chars are in ascii range.

All of the test files here on github uses typed str objects, so they pass. However if you make an API call using a unicode object, for example if you change the address as such: u'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1' it fails while building the pki string (because there are direct string casts like str(value)). It only fails when the object contains none ascii chars.

We tried converting unicode objects to str before passing them to API (encoding utf-8), but we still get encode/decode errors because of the multiple casts.

In any case, nearly all of the big Python frameworks (like Django) rely on unicode and for a good reason. I believe it would be a much better practice if the API would work with unicode objects without a problem.

Please let us know If you think this error is on our part, if not, can you please add coverage for unicode objects. This problem keeps us stuck.

Looking forward to your guidance. Thank you.


To reproduce the problem

address = dict([('address', u'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1')])

  • Additionally you can convert other strings to unicode as well, to see that it works if the string doesn't contains none-ascii char.
yyenigun commented 7 years ago

We tested with this address using Python 2.7.10 and it contains none ascii character '¢'. It will work when you encode it to 'utf-8' as below:

'registrationAddress': u'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. ¢ No:1'.encode('utf-8'),

sotuzun commented 7 years ago

I am closing it. @BodhiSukha please reopen it if you reproduce the problem.

duraiganesh0 commented 4 years ago

Hi, @sotuzun I am trying to integrate iyzico with opened that runs on python 2.7. I am facing the same error while passing non=ascii chars. Tired this as well 'registrationAddress': u'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. ¢ No:1'.encode('utf-8'), @yyenigun's solution is also not working for me