Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Apple doesn't support passing both a currencyCode and numberStyle #37

Closed
wants to merge 4 commits into from

Conversation

johnksterling
Copy link

@johnksterling johnksterling commented Aug 23, 2016

We are running into a problem where we set the currencyCode on the balance field of a pass, but never set the numberStyle - yet the passbook python library re-injects a default numberStyle. Apple, however, doesn't support having both a numberStyle and a currency field.

There are a few ways to resolve this, but I chose to just over-ride the json generation on CurrencyField to only strip numberStyle if currencyCode is present (which looks to be almost always, unless someone explicitly deletes one of them).

Note that the proposed solution will leave 'empty' the json as-is if one of them is an empty string. I am not sure if this is the desired behavior since we don't set either to empty string - bit it would be an easy change to check json_dictionary.get('currencyCode') and json_dictionary.get('currencyCode').strip() if that was preferred.

I have tested this with a couple of version of the ios and it seems to work well. Anyone else running into this and interested in fixing it?

Closes #38

…encyCode supplied. This is needed since apple pukes if you pass both
@@ -0,0 +1 @@
{}
Copy link
Collaborator

@mbaechtold mbaechtold Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a line to the .gitignore file, so this file does is added to the git repo:

# Unit test / coverage reports
.coverage
.tox
.cache   # <--- Add this line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but unfortunately I forgot to mention that you must delete this file too.

passfile.passInformation.headerFields.append(balance_field)
passfile.passInformation.addAuxiliaryField('aux1', 'VIP Store Card', 'Famous Inc.')
pass_json = passfile.json_dict()
print(pass_json)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this line should be removed?

Copy link
Collaborator

@mbaechtold mbaechtold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, almost ready.

@@ -0,0 +1 @@
{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but unfortunately I forgot to mention that you must delete this file too.

@driskell
Copy link

@johnksterling @mbaechtold Hi guys. Did something need to happen to merge this? I can see it didn't reach the master. Thanks!

@driskell
Copy link

Would just changing CurrencyField(NumberField) to CurrencyField(Field) not suffice?

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

Successfully merging this pull request may close these issues.

passbook generates both numberStyle and currencyCode on the balance field
3 participants