1
0
Fork 0

hswaw/voucherchecker: detect when voucher is in cart

Change-Id: Iac9a58c14b9d4faba5df0a945dd93ad269992c33
master
q3k 2019-10-25 19:55:05 +02:00
parent 3502c0d840
commit da67c6d3e9
1 changed files with 6 additions and 0 deletions

View File

@ -32,6 +32,7 @@ const (
statusInvalid
statusUnused
statusUsed
statusCart
)
func (v voucherstatus) String() string {
@ -42,6 +43,8 @@ func (v voucherstatus) String() string {
return "UNUSED"
case statusUsed:
return "USED"
case statusCart:
return "INCART"
}
return "UNKNOWN"
}
@ -218,6 +221,9 @@ func (s *service) getStatus(ctx context.Context, voucher string) voucherstatus {
if strings.Contains(string(data), "You entered a voucher code that allows you ") {
return statusUnused
}
if strings.Contains(string(data), "voucher code is currently locked") {
return statusCart
}
glog.Errorf("Unexpected result for %s", voucher)
glog.Infof("%s", data)