$amount = urlencode($receiverData['amount']);
    $amount_gross = $amount;
    $amount = round($amount * PAYPAL_FARE_PER, 2) + PAYPAL_FARE_FIX;
    $uniqueID = urlencode($receiverData['uniqueID']);
    $note = urlencode($receiverData['note']);
    $nvpStr .= "&L_EMAIL{$i}={$receiverEmail}&L_Amt{$i}={$amount_gross}&L_UNIQUEID{$i}={$uniqueID}&L_NOTE{$i}={$note}";
}
// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost('MassPay', $nvpStr);
//var_dump($nvpStr);
if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    //Payment is ok, now record and substract the money
    $money_class->SubtractMoney($_SESSION['user_profile']['id'], $amount_gross);
    $user_class->Record_user_log($_SESSION['user_profile']['id'], "Refund " . $amount_gross . " " . $currency . " to paypal " . $paypal_to);
    $status = 'OK';
    $money_class->RecordPaypalRefund($_SESSION['user_profile']['id'], $amount_gross, $currency, $status, $httpParsedResponseAr['CORRELATIONID']);
    //print($httpParsedResponseAr['ACK']."<br>");
    //print("ok ".$amount." ".$currency." ".$paypal_to);
    //exit('MassPay Completed Successfully: '.print_r($httpParsedResponseAr, true));
    printf("<script>document.location.href='index.php?message=PAYPAL_REFUND_OK&hash=" . $hash . "'</script>;");
} else {
    $status = 'KO ' . $httpParsedResponseAr['L_SHORTMESSAGE0'];
    $money_class->SubtractMoney($_SESSION['user_profile']['id'], $amount_gross);
    $money_class->RecordPaypalRefund($_SESSION['user_profile']['id'], $amount_gross, $currency, $status, $httpParsedResponseAr['ACK']['CORRELATIONID']);
    //exit('MassPay failed: ' . print_r($httpParsedResponseAr, true));
    //print("ERR_PAYPAL_REFUND_CONTACT_SUPPORT");
    //If an error happens, send mail to info@tuitflow.com to make the payment.
    $cabeceras = 'From: info@tuitflow.com' . "\r\n" . 'Reply-To: info@tuitflow.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    $message = 'El usuario ' . $_SESSION['user_profile']['id'] . ' ha solicitado que se envien a su cuenta de paypal: ' . $paypal_to . ' la cantidad de: ' . $amount_gross . ' ' . $currency;
    mail("*****@*****.**", "Solicitud de transferencia al usuario: " . $_SESSION['user_profile']['id'], $message, $cabeceras);
    printf("<script>document.location.href='index.php?message=PAYPAL_REFUND_OK_MANUAL&hash=" . $hash . "'</script>;");