Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bank_integration/bank_integration/api/bank_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ def logout(self):
pass

def setup_browser(self):
self.br = webdriver.Chrome(options=self.get_options(), port=12345)
self.br = webdriver.Chrome(options=self.get_options())

def get_options(self):
options = Options()
options.add_argument("window-size=990,1200")
if not frappe.conf.developer_mode:
options.add_argument("--headless")
options.add_experimental_option("w3c", False)

return options

Expand Down
14 changes: 6 additions & 8 deletions bank_integration/bank_integration/api/hdfc_bank_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from bank_integration.bank_integration.api.bank_api import BankAPI, AnyEC

# Selenium imports
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import (
Expand All @@ -37,8 +36,6 @@ def login(self):
cust_id = self.get_element("fldLoginUserId")
cust_id.send_keys(self.username, Keys.ENTER)

pass_input = self.get_element("fldPassword")

try:
secure_access_cb = self.get_element(
"chkrsastu", "id", timeout=2, throw=False
Expand All @@ -56,14 +53,15 @@ def login(self):
"HDFC Netbanking is asking for a CAPTCHA, which we don't currently support. Exiting."
)

pass_input.send_keys(self.password, Keys.ENTER)
self.get_element("fldPassword").send_keys(self.password, Keys.ENTER)

self.wait_until(
AnyEC(
EC.visibility_of_element_located(
(
By.XPATH,
"//td/span[text()[contains(.,'The Customer ID/IPIN (Password) is invalid.')]]",
# Message has changed on incorrect password
"//td/span[text()[contains(.,'Your ID and IPIN do not match. Please try again')]]",
)
),
EC.visibility_of_element_located((By.NAME, "fldOldPass")),
Expand All @@ -74,6 +72,7 @@ def login(self):
throw="ignore",
)

# Todo: don't think _found_element as an attribute works anymore in 4+ selenium
if not self.br._found_element:
self.handle_login_error()

Expand All @@ -94,8 +93,9 @@ def login(self):
self.process_otp()
elif "fldAnswer" == self.br._found_element[-1]:
self.process_security_questions()

else:
self.login_success()
self.logged_in = True

def process_otp(self):
mobile_no = email_id = None
Expand Down Expand Up @@ -219,8 +219,6 @@ def handle_login_error(self):
self.throw(alert)

def login_success(self):
self.logged_in = 1

if self.doctype == "Bank Integration Settings":
self.show_msg("Credentials verified successfully!")
self.emit_js("setTimeout(() => {frappe.hide_msgprint()}, 2000);")
Expand Down
22 changes: 18 additions & 4 deletions bank_integration/bank_integration/api/payments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@
import frappe
from bank_integration.bank_integration.api import get_bank_api


@frappe.whitelist()
def make_payment(docname, uid, data):
doctype = "Payment Entry"
data = frappe._dict(json.loads(data))

bi_name = frappe.db.get_value('Bank Account', {'account': data.from_account}, 'name')
bi = frappe.get_doc('Bank Integration Settings', bi_name)
bi_name = frappe.db.get_value(
"Bank Account", {"account": data.from_account}, "name"
)
bi = frappe.get_doc("Bank Integration Settings", bi_name)
data.from_account = bi.bank_account_no

bank = get_bank_api(bi.bank_name, bi.username, bi.get_password(), doctype="Payment Entry", docname=docname,
uid=uid, data=data)
bank = get_bank_api(
bi.bank_name,
bi.username,
bi.get_password(),
doctype=doctype,
docname=docname,
uid=uid,
data=data,
)

if bank.logged_in:
bank.login_success()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
frappe
selenium==3.141.0
selenium==4.7.2
pandas==1.5.0