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: order initialization should have a credit_card arg #22

Closed
peterskipper opened this issue Jan 26, 2018 · 4 comments
Closed

BUG: order initialization should have a credit_card arg #22

peterskipper opened this issue Jan 26, 2018 · 4 comments

Comments

@peterskipper
Copy link

The README example(s) order.pay_with(card) and order.place(card) do not currently work because an order object expects to have a credit_card attribute. The function signature for order should have a credit_card attribute set to None:

def init(self, store, customer, address, credit_card=None, country=COUNTRY_USA):

And then the pay_with method should check if self.credit_card is None

I can contribute a fix if you'd like!

@aluttik
Copy link
Collaborator

aluttik commented Jan 30, 2018

Sure that'd be great, thanks

@ggrammar
Copy link
Owner

ggrammar commented Feb 6, 2018

@peterskipper Hey, Peter! I pulled in a commit yesterday that fixes this. See here.

Rather than initialize the Order object with a card (I don't think you need it to call pay_with), I just modified the calls that use credit_card to use the card object that the caller passes in.

I'm going to close this issue out - let me know if you have any objections.

@ggrammar ggrammar closed this as completed Feb 6, 2018
@peterskipper
Copy link
Author

Thanks for responding! I'm a little bit concerned, though I may not understand the fix. It looks like pay_with uses card=False by default, and that in turn causes a 'Cash' payment to be sent? Won't that cause me to accidentally order a pizza with cash when I'm just testing my code out with pay_with?

@ggrammar
Copy link
Owner

ggrammar commented Feb 6, 2018

@peterskipper Excellent question! pay_with and place use two distinct (but similar-looking) URL endpoints.

You can see the actual endpoints in the urls module here. There's one API for getting a price for the order, and then another one for actually placing it. So, you could repeatedly price your order as you add toppings etc, and then place it once you've confirmed your price looks as intended.

Actually, our current request to the price_url doesn't even use the card object you pass in - I'm not sure why this is. Maybe the price changes if you order by card vs cash? I'll add this to my to-do list for next time I order pizza. The Order._send method posts the entire self.data dictionary, so it seems like the API does require that Payments dict to be populated in Order.pay_with.

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

No branches or pull requests

3 participants