Added some fail safes for inconsequential errors.
This commit is contained in:
@@ -157,6 +157,17 @@ Response:
|
||||
|
||||
if success == "1":
|
||||
|
||||
frappe.log_error(
|
||||
f"""
|
||||
PAYMENT SUCCESS FAILSAFE
|
||||
|
||||
Invoice: {invoice}
|
||||
Transaction ID: {transaction_id}
|
||||
Amount: {payload['amount']}
|
||||
""",
|
||||
"PAYMENT SUCCESS FAILSAFE"
|
||||
)
|
||||
|
||||
if payment_type == "check":
|
||||
mode_of_payment = "ACH"
|
||||
else:
|
||||
@@ -175,6 +186,8 @@ Response:
|
||||
"duplicate": True
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
create_payment_entry(
|
||||
invoice=invoice,
|
||||
amount=payload["amount"],
|
||||
@@ -182,6 +195,15 @@ Response:
|
||||
mode_of_payment=mode_of_payment
|
||||
)
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
except Exception:
|
||||
|
||||
frappe.log_error(
|
||||
frappe.get_traceback(),
|
||||
"PAYMENT ENTRY FAILURE AFTER SUCCESSFUL CHARGE"
|
||||
)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"transaction_id": transaction_id
|
||||
@@ -379,6 +401,17 @@ Response:
|
||||
)[0]
|
||||
}
|
||||
|
||||
frappe.log_error(
|
||||
f"""
|
||||
PAYMENT SUCCESS FAILSAFE
|
||||
|
||||
Invoice: {invoice}
|
||||
Transaction ID: {transaction_id}
|
||||
Amount: {inv.outstanding_amount}
|
||||
""",
|
||||
"PAYMENT SUCCESS FAILSAFE"
|
||||
)
|
||||
|
||||
existing_pe = frappe.db.exists(
|
||||
"Payment Entry",
|
||||
{"reference_no": transaction_id}
|
||||
@@ -386,6 +419,8 @@ Response:
|
||||
|
||||
if not existing_pe:
|
||||
|
||||
try:
|
||||
|
||||
create_payment_entry(
|
||||
invoice=invoice,
|
||||
amount=inv.outstanding_amount,
|
||||
@@ -393,9 +428,20 @@ Response:
|
||||
mode_of_payment="Credit Card"
|
||||
)
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
except Exception:
|
||||
|
||||
frappe.log_error(
|
||||
frappe.get_traceback(),
|
||||
"PAYMENT ENTRY FAILURE AFTER SUCCESSFUL CHARGE"
|
||||
)
|
||||
|
||||
# Save AutoPay info locally
|
||||
if save_autopay and vault_id:
|
||||
|
||||
try:
|
||||
|
||||
customer.custom_auto_pay_id = (
|
||||
vault_id
|
||||
)
|
||||
@@ -435,6 +481,13 @@ vault_id={vault_id}
|
||||
"AUTOPAY DEBUG - SAVE COMPLETE"
|
||||
)
|
||||
|
||||
except Exception:
|
||||
|
||||
frappe.log_error(
|
||||
frappe.get_traceback(),
|
||||
"AUTOPAY CUSTOMER SAVE FAILED"
|
||||
)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"transaction_id": transaction_id,
|
||||
@@ -551,6 +604,8 @@ def save_to_autopay(
|
||||
or "duplicate" in message.lower()
|
||||
):
|
||||
|
||||
try:
|
||||
|
||||
cust.custom_auto_pay_id = (
|
||||
returned_vault_id
|
||||
)
|
||||
@@ -577,6 +632,13 @@ def save_to_autopay(
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
except Exception:
|
||||
|
||||
frappe.log_error(
|
||||
frappe.get_traceback(),
|
||||
"AUTOPAY CUSTOMER SAVE FAILED"
|
||||
)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"vault_id": returned_vault_id
|
||||
@@ -606,6 +668,8 @@ def crystalclear_webhook():
|
||||
else:
|
||||
mode_of_payment = "Credit Card"
|
||||
|
||||
try:
|
||||
|
||||
create_payment_entry(
|
||||
invoice=invoice,
|
||||
amount=amount,
|
||||
@@ -613,6 +677,15 @@ def crystalclear_webhook():
|
||||
mode_of_payment=mode_of_payment
|
||||
)
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
except Exception:
|
||||
|
||||
frappe.log_error(
|
||||
frappe.get_traceback(),
|
||||
"WEBHOOK PAYMENT ENTRY FAILURE"
|
||||
)
|
||||
|
||||
return "ok"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user