Sign up customer for autopay? feature when manual payment is ran. Version 1

This commit is contained in:
Ty Reynolds
2026-03-19 08:24:28 -04:00
parent 4e5b4e0a41
commit bddbb35541
2 changed files with 88 additions and 7 deletions

View File

@@ -225,15 +225,43 @@ function run_token_payment(frm, token, dialog) {
token: token
},
callback(r) {
if (r.message?.success) {
if (r.message?.success) {
frappe.confirm(
"Payment successful. Save this card for AutoPay?",
() => {
// YES → save to vault
frappe.call({
method: "ns_app.api.payments.save_to_autopay",
args: {
customer: frm.doc.customer,
token: token
},
callback(res) {
if (res.message?.success) {
frappe.show_alert({
message: "AutoPay enabled",
indicator: "green"
});
} else {
frappe.msgprint(res.message?.error || "Failed to save AutoPay");
}
}
});
},
() => {
// NO
frappe.show_alert({
message: "Payment completed (not saved)",
indicator: "blue"
});
}
);
dialog.hide();
frm.reload_doc();
frappe.show_alert({
message: "Payment successful",
indicator: "green"
});
} else {
}
else {
frappe.msgprint(r.message?.error || "Payment failed");
}
}