Skip to content

Commit

Permalink
Merge pull request #80 from paypay/fix/check_orderItems
Browse files Browse the repository at this point in the history
Check if data has "orderItems" when create QR code
  • Loading branch information
chao-chang-paypay committed Mar 31, 2022
2 parents c77a0d0 + 76ba96c commit 7074930
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions paypayopa/resources/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,20 @@ def create_qr_code(self, data=None, **kwargs):
if "currency" not in data["amount"]:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for currency")
for item in data["orderItems"]:
if "name" not in item:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem Name")
if "quantity" not in item:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem quantity")
if "amount" not in item["unitPrice"]:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem.amount.unitPrice")
if "currency" not in item["unitPrice"]:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem.amount.currency")
if "orderItems" in data:
for item in data["orderItems"]:
if "name" not in item:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem Name")
if "quantity" not in item:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem quantity")
if "amount" not in item["unitPrice"]:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem.amount.unitPrice")
if "currency" not in item["unitPrice"]:
raise ValueError("\x1b[31m MISSING REQUEST PARAMS"
" \x1b[0m for orderItem.amount.currency")
return self.post_url(url, data, api_id=API_NAMES.CREATE_QRCODE, **kwargs)

def get_payment_details(self, id, **kwargs):
Expand Down

0 comments on commit 7074930

Please sign in to comment.