Added some fail safes for inconsequential errors.

This commit is contained in:
Ty Reynolds
2026-05-27 13:19:12 -04:00
parent 8c4f1f753e
commit 7789d13584

View File

@@ -157,6 +157,17 @@ Response:
if success == "1": 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": if payment_type == "check":
mode_of_payment = "ACH" mode_of_payment = "ACH"
else: else:
@@ -175,6 +186,8 @@ Response:
"duplicate": True "duplicate": True
} }
try:
create_payment_entry( create_payment_entry(
invoice=invoice, invoice=invoice,
amount=payload["amount"], amount=payload["amount"],
@@ -182,6 +195,15 @@ Response:
mode_of_payment=mode_of_payment mode_of_payment=mode_of_payment
) )
frappe.db.commit()
except Exception:
frappe.log_error(
frappe.get_traceback(),
"PAYMENT ENTRY FAILURE AFTER SUCCESSFUL CHARGE"
)
return { return {
"success": True, "success": True,
"transaction_id": transaction_id "transaction_id": transaction_id
@@ -379,6 +401,17 @@ Response:
)[0] )[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( existing_pe = frappe.db.exists(
"Payment Entry", "Payment Entry",
{"reference_no": transaction_id} {"reference_no": transaction_id}
@@ -386,6 +419,8 @@ Response:
if not existing_pe: if not existing_pe:
try:
create_payment_entry( create_payment_entry(
invoice=invoice, invoice=invoice,
amount=inv.outstanding_amount, amount=inv.outstanding_amount,
@@ -393,9 +428,20 @@ Response:
mode_of_payment="Credit Card" 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 # Save AutoPay info locally
if save_autopay and vault_id: if save_autopay and vault_id:
try:
customer.custom_auto_pay_id = ( customer.custom_auto_pay_id = (
vault_id vault_id
) )
@@ -435,6 +481,13 @@ vault_id={vault_id}
"AUTOPAY DEBUG - SAVE COMPLETE" "AUTOPAY DEBUG - SAVE COMPLETE"
) )
except Exception:
frappe.log_error(
frappe.get_traceback(),
"AUTOPAY CUSTOMER SAVE FAILED"
)
return { return {
"success": True, "success": True,
"transaction_id": transaction_id, "transaction_id": transaction_id,
@@ -551,6 +604,8 @@ def save_to_autopay(
or "duplicate" in message.lower() or "duplicate" in message.lower()
): ):
try:
cust.custom_auto_pay_id = ( cust.custom_auto_pay_id = (
returned_vault_id returned_vault_id
) )
@@ -577,6 +632,13 @@ def save_to_autopay(
frappe.db.commit() frappe.db.commit()
except Exception:
frappe.log_error(
frappe.get_traceback(),
"AUTOPAY CUSTOMER SAVE FAILED"
)
return { return {
"success": True, "success": True,
"vault_id": returned_vault_id "vault_id": returned_vault_id
@@ -606,6 +668,8 @@ def crystalclear_webhook():
else: else:
mode_of_payment = "Credit Card" mode_of_payment = "Credit Card"
try:
create_payment_entry( create_payment_entry(
invoice=invoice, invoice=invoice,
amount=amount, amount=amount,
@@ -613,6 +677,15 @@ def crystalclear_webhook():
mode_of_payment=mode_of_payment mode_of_payment=mode_of_payment
) )
frappe.db.commit()
except Exception:
frappe.log_error(
frappe.get_traceback(),
"WEBHOOK PAYMENT ENTRY FAILURE"
)
return "ok" return "ok"