Feat(booking-job): Loop detect payment merchant
All checks were successful
ktm-booking-bot/ktm-booking-bot/pipeline/head This commit looks good
All checks were successful
ktm-booking-bot/ktm-booking-bot/pipeline/head This commit looks good
This commit is contained in:
@@ -322,29 +322,37 @@ func chooseAndMakePayment(timerCtx context.Context, creditCardType, creditCard,
|
||||
log.Println("Waiting for payment gateway to load.")
|
||||
time.Sleep(time.Second * 5)
|
||||
|
||||
for _, currPage := range browser.MustPages() {
|
||||
currPage.MustWaitLoad()
|
||||
foundPage := false
|
||||
|
||||
var currTitle string
|
||||
err := rod.Try(func() {
|
||||
currTitle = currPage.Timeout(100 * time.Millisecond).MustElement("title").MustText()
|
||||
})
|
||||
if err != nil {
|
||||
currTitle = ""
|
||||
for !foundPage {
|
||||
for _, currPage := range browser.MustPages() {
|
||||
currPage.MustWaitLoad()
|
||||
|
||||
var currTitle string
|
||||
err := rod.Try(func() {
|
||||
currTitle = currPage.Timeout(100 * time.Millisecond).MustElement("title").MustText()
|
||||
})
|
||||
if err != nil {
|
||||
currTitle = ""
|
||||
}
|
||||
|
||||
if strings.Contains(currTitle, "Payment Acceptance") {
|
||||
log.Println("Page found.")
|
||||
foundPage = true
|
||||
page = currPage
|
||||
}
|
||||
}
|
||||
|
||||
if strings.Contains(currTitle, "Payment Acceptance") {
|
||||
page = currPage
|
||||
// Exits if context cancelled
|
||||
select {
|
||||
case <-timerCtx.Done():
|
||||
browser.MustClose()
|
||||
cancelRefresh()
|
||||
return false
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// Exits if context cancelled
|
||||
select {
|
||||
case <-timerCtx.Done():
|
||||
browser.MustClose()
|
||||
cancelRefresh()
|
||||
return false
|
||||
default:
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
expiryMonth := strings.Split(creditCardExpiry, "/")[0]
|
||||
|
||||
Reference in New Issue
Block a user