Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Maximum tender amount off by an order of magnitude in Money model? Results in deserialization of legitimate response throwing a ValueError #69

Closed
sherbondy opened this issue Aug 6, 2018 · 1 comment

Comments

@sherbondy
Copy link

sherbondy commented Aug 6, 2018

Hi there,

We ran into a funny issue where it looks like somebody specified the maximum possible "tendered" amount for a fake/test cash transaction of: 999,999,999 cents, corresponding to $9,999,999.99

This value came through in the buyer_tendered_money TenderCashDetails field.

The outcome was a ValueError thrown inside the SquareConnectAPI money.py model:
https://github.com/square/connect-python-sdk/blob/master/squareconnect/models/money.py#L75

if amount > 99999999:
    raise ValueError("Invalid value for `amount`, must be a value less than or equal to `99999999`")

This value, 99,999,999, seems to be off by a digit from the actual maximum allowable value (999,999,999) inside the Square Point of Sale app, resulting in a "legitimate" tender value from the Connect API v2 endpoint yielding an exception during deserialization.

I'm guessing this issue is upstream in the underlying swagger spec that generates the Python SDK. So this problem may be present in all instances of the Connect SDK. Looks like somebody just mis-typed the constant here for the maximum valid Money model value in the spec?

Anyway, this was problematic for us because this single illegitimate amount raised an exception, yielding a deserialization failure for a whole page of otherwise legitimate transaction results.

Long live languages that support underscores in numeric literals!
Added to Python in 3.6 FWIW, but again, guessing a deficit of Swagger / the underlying spec caused this problem.

@ssung88
Copy link
Contributor

ssung88 commented Oct 15, 2018

Hello sherbondy, the latest python SDK has the constraint removed. Thank you for bringing this to our attention.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants