Merge pull request #2156 from raizasafeel/fix/payment-gateway

fix(payment gateway): add delete functionality and field details
This commit is contained in:
Jannat Patel
2026-03-04 11:01:38 +05:30
committed by GitHub
4 changed files with 52 additions and 14 deletions

View File

@@ -131,7 +131,7 @@ watch(newGateway, () => {
let fields = gatewayFields.data || []
arrangeFields(fields)
newGatewayFields.value = makeSections(fields)
prepareGatewayData()
prepareGatewayData(fields)
})
})
@@ -209,13 +209,11 @@ const allGatewayOptions = computed(() => {
return options.map((gateway: string) => ({ label: gateway, value: gateway }))
})
const prepareGatewayData = () => {
const prepareGatewayData = (fields: any[]) => {
newGatewayData.value = {}
if (newGatewayFields.value.length) {
newGatewayFields.value.forEach((field: any) => {
newGatewayData.value[field.fieldname] = field.default || ''
})
}
fields.forEach((field: any) => {
newGatewayData.value[field.name] = field.default || ''
})
}
const makeSections = (fields: any[]) => {

View File

@@ -88,6 +88,7 @@
import {
Badge,
Button,
call,
createListResource,
FeatherIcon,
ListView,
@@ -97,10 +98,12 @@ import {
ListRow,
ListRowItem,
ListSelectBanner,
toast,
} from 'frappe-ui'
import { computed, ref } from 'vue'
import { Plus, Trash2 } from 'lucide-vue-next'
import PaymentGatewayDetails from '@/components/Settings/PaymentGatewayDetails.vue'
import { cleanError } from '@/utils'
const showForm = ref(false)
const currentGateway = ref(null)
@@ -128,6 +131,23 @@ const openForm = (gatewayID) => {
showForm.value = true
}
const removeAccount = (selections, unselectAll) => {
call('lms.lms.api.delete_documents', {
doctype: 'Payment Gateway',
documents: Array.from(selections),
})
.then(() => {
paymentGateways.reload()
toast.success(__('Payment gateways deleted successfully'))
unselectAll()
})
.catch((err) => {
toast.error(
cleanError(err.messages[0]) || __('Error deleting payment gateways')
)
})
}
const columns = computed(() => {
return [
{

View File

@@ -20,6 +20,7 @@
:doctype="field.doctype"
:label="__(field.label)"
:description="__(field.description)"
:required="field.reqd"
/>
<div v-else-if="field.type == 'Code'">
@@ -115,6 +116,7 @@
:rows="field.rows"
:options="field.options"
:description="field.description"
:required="field.reqd"
placeholder=""
/>
</div>

View File

@@ -702,7 +702,13 @@ def save_certificate_details(
@frappe.whitelist()
def delete_documents(doctype: str, documents: list):
frappe.only_for("Moderator")
meta = frappe.get_meta(doctype)
non_lms_allowed = ["Payment Gateway", "Email Template"]
if meta.module != "LMS" and doctype not in non_lms_allowed:
frappe.throw(_("Deletion not allowed for {0}").format(doctype))
for doc in documents:
if not isinstance(doc, str) or not doc.strip():
frappe.throw(_("Invalid document name"))
frappe.delete_doc(doctype, doc)
@@ -751,13 +757,25 @@ def get_transformed_fields(meta: list, data: dict = None):
else:
fieldtype = row.fieldtype
transformed_fields.append(
{
"label": row.label,
"name": row.fieldname,
"type": fieldtype,
}
)
field = {
"label": row.label,
"name": row.fieldname,
"type": fieldtype,
}
if row.reqd:
field["reqd"] = 1
if row.options:
field["options"] = row.options
if row.default:
field["default"] = row.default
if row.description:
field["description"] = row.description
transformed_fields.append(field)
return transformed_fields