feat: payment through payments app

This commit is contained in:
Jannat Patel
2024-09-19 12:46:56 +05:30
parent 3cda563583
commit cef4b70182
3 changed files with 49 additions and 21 deletions

View File

@@ -164,6 +164,9 @@ class LMSBatch(Document):
_("Row #{0} Date cannot be outside the batch duration.").format(schedule.idx)
)
def on_payment_authorized(self, payment_status):
print(payment_status)
@frappe.whitelist()
def remove_student(student, batch_name):

36
lms/lms/payments.py Normal file
View File

@@ -0,0 +1,36 @@
import frappe
from payments.utils import get_payment_gateway_controller
def get_payment_gateway():
return "Razorpay"
def get_controller(payment_gateway):
return get_payment_gateway_controller(payment_gateway)
def validate_currency(payment_gateway, currency):
controller = get_controller(payment_gateway)
controller().validate_transaction_currency(currency)
@frappe.whitelist()
def get_payment_link(doctype, docname, amount, currency, billing_name):
payment_gateway = get_payment_gateway()
payment_details = {
"amount": amount,
"title": f"Payment for {doctype} {docname}",
"description": f"{billing_name}'s payment for {doctype} {docname}",
"reference_doctype": doctype,
"reference_docname": docname,
"payer_email": frappe.session.user,
"payer_name": billing_name,
"order_id": docname,
"currency": currency,
"payment_gateway": payment_gateway,
}
controller = get_controller(payment_gateway)
url = controller().get_payment_url(**payment_details)
return url