// Copyright (c) 2020, JINGROW
// For license information, please see license.txt

jingrow.ui.form.on('Stripe Payment Method', {
	refresh: function (frm) {
		jingrow.dynamic_link = {
			pg: frm.pg,
			fieldname: 'name',
			pagetype: 'Stripe Payment Method',
		};
		jingrow.contacts.render_address_and_contact(frm);

		if (frm.pg.stripe_mandate_id) {
			frm.add_custom_button('Check Mandate Status', () => {
				frm.call('check_mandate_status').then((r) => {
					if (r.message) {
						jingrow.msgprint(`Mandate status: ${r.message}`);
					} else {
						jingrow.msgprint('No mandate found or status is not available.');
					}
				});
			});
		}
	},
});
