Skip to content

Commit b03a434

Browse files
default to debit at the door if no payment card
1 parent d7013ed commit b03a434

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

pizzapi/order.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,35 @@ def validate(self):
8888
return response['Status'] != -1
8989

9090
# TODO: Actually test this
91-
def place(self, card):
91+
def place(self, card=False):
9292
self.pay_with(card)
9393
response = self._send(self.urls.place_url(), False)
9494
return response
9595

9696
# TODO: Add self.price() and update whenever called and items were changed
97-
def pay_with(self, card):
97+
def pay_with(self, card=False):
9898
"""Use this instead of self.place when testing"""
9999
# get the price to check that everything worked okay
100100
response = self._send(self.urls.price_url(), True)
101101

102102
if response['Status'] == -1:
103103
raise Exception('get price failed: %r' % response)
104-
self.credit_card = card
105-
self.data['Payments'] = [
106-
{
107-
'Type': 'CreditCard',
108-
'Expiration': self.credit_card.expiration,
109-
'Amount': self.data['Amounts'].get('Customer', 0),
110-
'CardType': self.credit_card.card_type,
111-
'Number': int(self.credit_card.number),
112-
'SecurityCode': int(self.credit_card.cvv),
113-
'PostalCode': int(self.credit_card.zip)
114-
}
115-
]
104+
105+
if card == False:
106+
self.data['Payments'] = [
107+
{
108+
'Type': 'DebitDoor',
109+
}
110+
]
111+
else:
112+
self.data['Payments'] = [
113+
{
114+
'Type': 'CreditCard',
115+
'Expiration': self.credit_card.expiration,
116+
'Amount': self.data['Amounts'].get('Customer', 0),
117+
'CardType': self.credit_card.card_type,
118+
'Number': int(self.credit_card.number),
119+
'SecurityCode': int(self.credit_card.cvv),
120+
'PostalCode': int(self.credit_card.zip)
121+
}
122+
]

0 commit comments

Comments
 (0)