fix: reload current pos doc after updating the information via callback
diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py
index dced7b0..d33b0a7 100644
--- a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py
+++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_connector.py
@@ -18,10 +18,7 @@
def authenticate(self):
"""
- To make Mpesa API calls, you will need to authenticate your app. This method is used to fetch the access token
- required by Mpesa. Mpesa supports client_credentials grant type. To authorize your API calls to Mpesa,
- you will need a Basic Auth over HTTPS authorization token. The Basic Auth string is a base64 encoded string
- of your app's client key and client secret.
+ This method is used to fetch the access token required by Mpesa.
Returns:
access_token (str): This token is to be used with the Bearer header for further API calls to Mpesa.
diff --git a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py
index 9d34a54..1d318bb 100644
--- a/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py
+++ b/erpnext/erpnext_integrations/doctype/mpesa_settings/mpesa_settings.py
@@ -43,8 +43,7 @@
self.handle_api_response("ConversationID", payload, response)
def handle_api_response(self, global_id, request_dict, response):
- """Response received from API calls returns a global identifier for each transaction,
- this code is returned during the callback"""
+ """Response received from API calls returns a global identifier for each transaction, this code is returned during the callback."""
# check error response
if getattr(response, "requestId"):
req_name = getattr(response, "requestId")
@@ -91,7 +90,7 @@
@frappe.whitelist(allow_guest=True)
def verify_transaction(**kwargs):
- """ Verify the transaction result received via callback from stk """
+ """Verify the transaction result received via callback from stk."""
transaction_response = frappe._dict(kwargs["Body"]["stkCallback"])
frappe.logger().debug(transaction_response)
@@ -139,8 +138,7 @@
@frappe.whitelist(allow_guest=True)
def process_balance_info(**kwargs):
- """Process and store account balance information received via callback
- from the account balance API call."""
+ """Process and store account balance information received via callback from the account balance API call."""
account_balance_response = frappe._dict(kwargs["Result"])
conversation_id = getattr(account_balance_response, "ConversationID", "")
@@ -164,7 +162,7 @@
request.handle_success(account_balance_response)
frappe.publish_realtime("refresh_mpesa_dashboard")
- except:
+ except Exception:
request.handle_failure(account_balance_response)
frappe.log_error(title=_("Mpesa Account Balance Processing Error"), message=account_balance_response)
else:
@@ -172,7 +170,7 @@
def convert_to_json(balance_info):
"""
- Convert string to json
+ Convert string to json.
e.g: '''Working Account|KES|481000.00|481000.00|0.00|0.00'''
=> {'Working Account': {'current_balance': '481000.00',
@@ -192,7 +190,7 @@
return dumps(balance_dict)
def fetch_param_value(response, key, key_field):
- """Fetch the specified key from list of dictionary. Key is identified via the key field"""
+ """Fetch the specified key from list of dictionary. Key is identified via the key field."""
for param in response:
if param[key_field] == key:
return param["Value"]
\ No newline at end of file
diff --git a/erpnext/selling/page/point_of_sale/pos_payment.js b/erpnext/selling/page/point_of_sale/pos_payment.js
index 2053903..ec886d7 100644
--- a/erpnext/selling/page/point_of_sale/pos_payment.js
+++ b/erpnext/selling/page/point_of_sale/pos_payment.js
@@ -176,6 +176,7 @@
frappe.realtime.on("process_phone_payment", function(data) {
frappe.dom.unfreeze();
+ cur_frm.reload_doc();
let message = data["ResultDesc"];
let title = __("Payment Failed");