var dataTable; $(document).ready(function () { loadUnpaidLotsDataTable(); }); function loadUnpaidLotsDataTable() { dataTable = $('#tblUnpaidLots').DataTable({ ajax: { url: '/api/lots/won/unpaid', dataSrc: '', }, columns: [ { data: 'name', render: function (data, type, row) { return '' + data + ''; }, width: '15%', }, { data: 'highest_bid_amount' }, { data: 'auction_start_time', render: function (data) { return formatDateTime(data); }, }, { data: 'auction_duration' }, { data: 'id', render: function (data, type, row) { return `
View
`; }, width: '15%', }, ], responsive: true, searching: false, paging: false, info: false, language: { emptyTable: 'No lot has been won till yet..', }, }); // Handle click on Pay Now button $('#tblUnpaidLots').on('click', '.payment-button', function () { var lotId = $(this).data('lot-id'); var highestBidAmount = $(this).data('highest-bid-amount'); $('#paymentModal').modal('show'); $('#paymentModal').find('.payment-option').data('lot-id', lotId); $('#paymentModal') .find('.payment-option') .data('highest-bid-amount', highestBidAmount); }); // Handle click on payment option $('.payment-option').click(function () { var paymentType = $(this).data('payment'); var lotId = $(this).data('lot-id'); var highestBidAmount = $(this).data('highest-bid-amount'); $('#paymentModal').modal('hide'); payWithPaymentType(paymentType, lotId, highestBidAmount); }); function payWithPaymentType(paymentType, lotId, highestBidAmount) { console.log( 'Processing payment with ' + paymentType + ' for lot ID ' + lotId + ' with highest bid amount ' + highestBidAmount ); window.location.href = `/payment/request/${paymentType}/?lot_id=${lotId}&amount=${highestBidAmount}`; } }