Ignore permissions for insert new payment entry not working

Hi dear ,

iam facing error in this line pe.insert(ignore_permissions=True) , i want guest to insert payment entry this is for payment gateway purpose.

    sales_invoice = "SINV-00055"
    doc = frappe.get_doc('Sales Invoice', sales_invoice)
    pe = frappe.new_doc("Payment Entry")
    pe.flags.ignore_permissions = True
    pe.payment_type = "Receive"
    pe.posting_date = doc.posting_date
    pe.mode_of_payment = "Credit Card"
    pe.paid_to = frappe.db.get_value("Mode of Payment Account", {"parent": "Credit Card"}, "default_account")
    pe.party_type = "Customer"
    pe.party = doc.customer
    pe.paid_amount = doc.outstanding_amount
    pe.allocate_payment_amount = 1
    pe.letter_head = doc.get("letter_head")
    pe.received_amount = doc.outstanding_amount
    pe.append("references", {
        'reference_doctype': "Sales Invoice",
        'reference_name': doc.name,
        "due_date": doc.posting_date,
        'total_amount': doc.outstanding_amount,
        'outstanding_amount': 0,
        'allocated_amount': doc.outstanding_amount
    pe.reference_no = "123123"
    pe.reference_date = frappe.utils.today()
    # frappe.db.commit()
    # pe_doc = frappe.get_doc('Payment Entry', pe.name)
    # pe_doc.submit()
    # frappe.db.commit()
    return pe.name

thanks in advance
best regards,

Can you post the error that you are getting?


Dear @bghayad

thank you , there are no error shown even in console for that i debugging with return string value before and after the statement

thanks in advance

So what the problem do you face?


dear @bghayad ,

this line not working if i am as Guest (not logged in)
after login its work (payment inserted as draft)

so i think the functionality of ignore_permissions not correctly working i need to allow guest to insert this payment

thanks ,

Please can you post a picture to see from where it is not working and from where it is not working?
For example: if you try to do it from website (please show the page and the button that you click) and the screen that you can insert from it the payment using this script that you wrote.


Dear @bghayad ,

here you are ,
as Guest

as Administrator

the console only shown css and js path error

thanks in advance .

As guest:
Where is the page? Please display it completely and let us see where the guest is pressing to run your code that is calling:


Dear @bghayad ,

the function is under www folder is payment.py

you can just create new page under www folder and try to create payment when guest visit your page , and share the code if its work !

thanks in advance

Nothing worked for me until I used set_user(“Administrator”)