-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all testing done at pe and bug fixing
- Loading branch information
Sameer Chauhan
committed
Dec 27, 2022
1 parent
6eb945c
commit 05fe118
Showing
8 changed files
with
86 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
razorpay_payment_links_integration/customizations/payment_entry.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 34 additions & 26 deletions
60
razorpay_payment_links_integration/public/js/payment_entry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,50 @@ | ||
frappe.ui.form.on("Payment Entry", { | ||
refresh: function(frm) { | ||
if(frm.doc.razorpay_payment_link){ | ||
refresh: function (frm) { | ||
if (frm.doc.razorpay_payment_link) { | ||
frm.add_custom_button(__('Resend Notification'), () => { | ||
frappe.call({ | ||
method: "razorpay_payment_links_integration.controller.resend_notification", | ||
args: {"paymentLinkId": frm.doc.razorpay_payment_link}, | ||
callback: function(r) { | ||
args: { "paymentLinkId": frm.doc.razorpay_payment_link }, | ||
callback: function (r) { | ||
console.log(r); | ||
} | ||
}); | ||
}) | ||
} | ||
}, | ||
mode_of_payment (frm) { | ||
if (frm.doc.mode_of_payment!="Razorpay Payment Link") { | ||
frm.add_custom_button(__("Create payment Link ") ,()=> { | ||
frappe.call({ | ||
method:"razorpay_payment_links_integration.controller.create_payment_link", | ||
args:{ | ||
doc: frm.doc | ||
}, | ||
callback: function(r) { | ||
console.log(r); | ||
if (!frm.doc.__islocal && frm.doc.mode_of_payment == "Razorpay Payment Link" && !frm.doc.razorpay_payment_link) { | ||
frm.add_custom_button(__("Create payment Link "), () => { | ||
if (!frm.doc.paid_amount) { | ||
frm.get_field('paid_amount').input.focus() | ||
frappe.throw(__('Please enter Paid Amount to send payment link!')) | ||
} | ||
if (!frm.doc.contact_person) { | ||
frm.get_field('contact_person').input.focus() | ||
frappe.throw(__('Please select Contact to send payment link!')) | ||
} | ||
|
||
frappe.call({ | ||
method: "razorpay_payment_links_integration.controller.create_payment_link", | ||
args: { | ||
doc: frm.doc | ||
}, | ||
callback: function (r) { | ||
console.log(r); | ||
frm.refresh(); | ||
} | ||
}) | ||
|
||
}) | ||
|
||
} | ||
}, | ||
razorpay_payment_status(frm) { | ||
if (razorpay_payment_status=="Paid") { | ||
frm.save('Submit'); | ||
// } else if (razorpay_payment_status=="Cancelled") { | ||
// frm.save('Cancel'); | ||
// } else if (razorpay_payment_status=="Expired") { | ||
// frm.save('Cancel'); | ||
// } | ||
} | ||
before_submit: function (frm) { | ||
if (frm.doc.razorpay_payment_link && frm.doc.razorpay_payment_status != "Paid") { | ||
frappe.warn('Are you sure you want to proceed?', | ||
'Payment Entry documents are supposed to be auto-submitted when the Payment confirmation is received from the Razorpay.', | ||
() => { | ||
// action to perform if Continue is selected | ||
}, | ||
'Continue', | ||
true // Sets dialog as minimizable | ||
) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 15 additions & 2 deletions
17
...zorpay_payment_links_integration/doctype/razorpay_payment_links/razorpay_payment_links.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
# Copyright (c) 2022, Sameer Chauhan and contributors | ||
# For license information, please see license.txt | ||
|
||
# import frappe | ||
import frappe | ||
from frappe.model.document import Document | ||
|
||
class RazorpayPaymentLinks(Document): | ||
pass | ||
def on_update(self): | ||
if(self.get('payment_for')): | ||
if(self.get('status') == "Paid"): | ||
try: | ||
pe_doc = frappe.get_doc('Payment Entry', self.get('payment_for')) | ||
if(pe_doc.razorpay_payment_status != "Paid" and pe_doc.docstatus != 1): | ||
pe_doc.razorpay_payment_status = "Paid" | ||
pe_doc.docstatus = 1 | ||
pe_doc.save(ignore_permissions=True) | ||
except: | ||
frappe.log_error('Razorpay Payment entry submit failed', 'Razorpay Payment entry submit failed') | ||
else: | ||
frappe.db.set_value('Payment Entry', self.get('payment_for'), 'razorpay_payment_status', self.status) | ||
|