如何从laravel 5.3中的jquery数据表导出数据?

I would want to export data from jquery datatables to PDF and CSV formats. I am following this https://datatables.net/extensions/buttons/examples/initialisation/export.html however I am unable to insert

$(document).ready(function(){
    $('#payments-table').DataTable({
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    });
}); 

properly to my working code.

<script>
    $(function() {
        $('#payments-table').DataTable({
            processing: true,
            serverSide: true,
            scrollX: true,

            ajax: '{!! route('
            HomeControllerPaymentsData ') !!}',
            columns: [{
                data: 'id',
                name: 'id'
            }, {
                data: 'name',
                name: 'name'
            }, {
                data: 'amount',
                name: 'amount'
            }, {
                data: 'trans_id',
                name: 'trans_id'
            }, {
                data: 'msisdn',
                name: 'msisdn'
            }, {
                data: 'time_paid',
                name: 'time_paid'
            }, {
                data: 'account',
                name: 'account'
            }, {
                data: 'orgaccountbalance',
                name: 'orgaccountbalance'
            }]

        });
    });
</script>

Kindly would someone help me to combine the two scripts to have the buttons appear? Thank you.