feat: payment through payments app
This commit is contained in:
@@ -167,7 +167,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { Input, Button, createResource } from 'frappe-ui'
|
||||
import { Input, Button, createResource, call } from 'frappe-ui'
|
||||
import { reactive, inject, onMounted, ref } from 'vue'
|
||||
import Link from '@/components/Controls/Link.vue'
|
||||
import NotPermitted from '@/components/NotPermitted.vue'
|
||||
@@ -250,26 +250,15 @@ const paymentOptions = createResource({
|
||||
})
|
||||
|
||||
const generatePaymentLink = () => {
|
||||
paymentOptions.submit(
|
||||
{},
|
||||
{
|
||||
validate(params) {
|
||||
return validateAddress()
|
||||
},
|
||||
onSuccess(data) {
|
||||
data.handler = (response) => {
|
||||
let doctype = props.type == 'course' ? 'LMS Course' : 'LMS Batch'
|
||||
let docname = props.name
|
||||
handleSuccess(response, doctype, docname, data.order_id)
|
||||
}
|
||||
let rzp1 = new Razorpay(data)
|
||||
rzp1.open()
|
||||
},
|
||||
onError(err) {
|
||||
showError(err)
|
||||
},
|
||||
}
|
||||
)
|
||||
call('lms.lms.payments.get_payment_link', {
|
||||
doctype: props.type == 'course' ? 'LMS Course' : 'LMS Batch',
|
||||
docname: props.name,
|
||||
amount: orderSummary.data.amount,
|
||||
currency: orderSummary.data.currency,
|
||||
billing_name: billingDetails.billing_name,
|
||||
}).then((data) => {
|
||||
window.location.href = data
|
||||
})
|
||||
}
|
||||
|
||||
const paymentResource = createResource({
|
||||
|
||||
@@ -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
36
lms/lms/payments.py
Normal 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
|
||||
Reference in New Issue
Block a user