Upgraded the autopay functions and finished up the iframe.
This commit is contained in:
@@ -97,6 +97,31 @@ def get_collect_checkout_url(invoice):
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def crystalclear_webhook():
|
||||
data = frappe.local.form_dict
|
||||
|
||||
# Validate success
|
||||
if data.get("response") != "1":
|
||||
return "ignored"
|
||||
|
||||
invoice = data.get("orderid")
|
||||
amount = data.get("amount")
|
||||
transaction_id = data.get("transactionid")
|
||||
|
||||
# Prevent duplicates
|
||||
if frappe.db.exists("Payment Entry", {"reference_no": transaction_id}):
|
||||
return "duplicate"
|
||||
|
||||
create_payment_entry(
|
||||
invoice=invoice,
|
||||
amount=amount,
|
||||
transaction_id=transaction_id
|
||||
)
|
||||
|
||||
return "ok"
|
||||
|
||||
|
||||
def create_payment_entry(invoice, amount, transaction_id=None):
|
||||
inv = frappe.get_doc("Sales Invoice", invoice)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user