Appointments+ with myCred use the credits for booking lessons

hi
i have a problem with this code :
i put it in the Appointments.php

/**
* Make checks on submitted fields and save appointment
* @return json object
*/
function post_confirmation() {

//test

add_filter ('app_pre_confirmation_reply','myCred_check') ;
// Check if the user has balance, if he has go ahead and do nothing.
function myCred_check($ret)
{
$script = "" ;
if ( function_exists( 'mycred' ) ){
global $wp, $current_user;
$mycred = mycred();
$current_user = wp_get_current_user();
$balance = round($mycred->get_users_balance( $current_user->ID ));
// If no balance then throw alert and hide the confirm button
if ( $balance <= 0 ) {
$script = <<< myCredCode
<script type="text/javascript">
jQuery(document).ready(function($)
{
alert("We cannot confirm this lesson as you have no credits remaining. Please buy additional credits before scheduling a lesson");
jQuery( ".appointments-confirmation-button" ).hide() ;
})
</script>
myCredCode;
}
}
$ret['service'] .=$script ;
return $ret ;
}

// Once the appointment is confirmed, then process the myCreds.
add_filter('app_post_confirmation_status', 'confirm_manual_payments',10,5);
function confirm_manual_payments($status, $price, $service, $worker, $user_id) {
if("pending" === $status || "confirmed" === $status) :
global $wp, $current_user;
$mycred = mycred();
$current_user = wp_get_current_user();
$balance = round($mycred->get_users_balance( $current_user->ID ));

if ( $balance > 0 ) {
$mycred->add_creds('appointment', $current_user->ID, -1, '1 %plural% deduction for Appointment Booking');
}
// If he somehow hacked around the front end and got through, then put his appointment as pending and get admin to take a look
else{
$status = "pending" ;
}
endif ;
return $status;
}

//test

its not working right

the main idea is that the students buy the lessons with credits
i use this code but somehow its not working .
maybe u see what i can't see here .