<?php

if (isset($_POST['phone']) && $_POST['phone']) {
    $success = MailerHelper::mail('*****@*****.**', 'New request to join whatsapp group', $_POST['phone'] . ' requested to join the Tiferes Rachamim WhatsApp group.');
    echo json_encode(['successful' => $success]);
} else {
    echo json_encode(['successful' => false]);
}
 private function emailReceipt($info)
 {
     $padLength = 35;
     $body = '';
     if ($info['success']) {
         $body .= $info['message'] . "\n\n";
         $body .= str_pad("Confirmation Number: ", $padLength) . $info['confirmationNumber'] . "\n";
         $body .= str_pad("Name: ", $padLength) . ucwords(ucwords($info['fname'] . ' ' . $info['lname'])) . "\n";
         $body .= str_pad("Amount: ", $padLength) . $info['resultAmount'] . "\n";
         $body .= str_pad("Date: ", $padLength) . $info['clientTransDate'] . "\n";
         $body .= str_pad("Authorization Code: ", $padLength) . $info['authCode'] . "\n";
         $body .= str_pad("Payment Type: ", $padLength) . ucwords(ucwords($info['paymentType'])) . "\n";
         $body .= str_pad("Card Type: ", $padLength) . ucwords(ucwords($info['cardType'])) . "\n";
         $body .= str_pad("Last 4 of Account Number: ", $padLength) . $info['last4'] . "\n";
     }
     if (isset($info['subscription'])) {
         $body .= "\n\nYou have agreed to recurring charges on a monthly basis. You may call Laibie at (347) 403-1660 to cancel the ";
         $body .= "recurring charges at any time. Please review the information below and contact Laibie immediately if ";
         $body .= "the information is incorrect.\n\n";
         $body .= str_pad("Recurring Subscription ID: ", $padLength) . $info['braintreeSubscriptionId'] . "\n";
         $body .= str_pad("Recurring Amount: ", $padLength) . $info['price'] . "\n";
         $body .= str_pad("Recurring Day of Month: ", $padLength) . $info['billingDayOfMonth'] . "\n";
         $body .= str_pad("Recurring Subscription Status: ", $padLength) . ucwords(ucwords($info['status'])) . "\n";
     }
     if (strlen($body) <= 0) {
         MysqlAccess::log("Attempted to email empty text to " . $info['email']);
         return;
     }
     MailerHelper::mail($info['email'], $info['header'], $body);
 }