Sign up customer for autopay? feature when manual payment is ran. Version 1
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user