public function buildMerchants($xml) { $merchants = new Merchants(); $merchants->setPageOffset((string) $xml->PageOffset); $merchants->setTotalCount((string) $xml->TotalCount); // merchant $merchantArray = array(); foreach ($xml->Merchant as $merchant) { $tmpMerchant = new Merchant(); $tmpMerchant->setId((string) $merchant->Id); $tmpMerchant->setName((string) $merchant->Name); $tmpMerchant->setWebsiteUrl((string) $merchant->WebsiteUrl); $tmpMerchant->setPhoneNumber((string) $merchant->PhoneNumber); $tmpMerchant->setCategory((string) $merchant->Category); $tmpLocation = new Location(); $location = $merchant->Location; $tmpLocation->setName((string) $location->Name); $tmpLocation->setDistance((string) $location->Distance); $tmpLocation->setDistanceUnit((string) $location->DistanceUnit); $tmpAddress = new Address(); $address = $location->Address; $tmpAddress->setLine1((string) $address->Line1); $tmpAddress->setLine2((string) $address->Line2); $tmpAddress->setCity((string) $address->City); $tmpAddress->setPostalCode((string) $address->PostCode); $tmpCountry = new Country(); $tmpCountry->setName((string) $address->Country->Name); $tmpCountry->setCode((string) $address->Country->Code); $tmpCountrySubdivision = new CountrySubdivision(); $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name); $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code); $tmpAddress->setCountry($tmpCountry); $tmpAddress->setCountrySubdivision($tmpCountrySubdivision); $tmpPoint = new Point(); $point = $location->Point; $tmpPoint->setLatitude((string) $point->Latitude); $tmpPoint->setLongitude((string) $point->Longitude); // ACCEPTANCE FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES> //$tmpAcceptance = new Acceptance(); //$acceptance = $merchant->Acceptance; // FEATURES FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES> //$tmpFeatures = new Features(); //$features = $merchant->Features; $tmpLocation->setPoint($tmpPoint); $tmpLocation->setAddress($tmpAddress); $tmpMerchant->setLocation($tmpLocation); array_push($merchantArray, $tmpMerchant); } $merchants->setMerchant($merchantArray); return $merchants; }
function Emails($transaction = false, $dump = false) { if ($transaction) { global $_CONF; loadclass('Transactions'); loadclass('Sites'); loadclass('Merchants'); loadclass('MerchantAccounts'); loadclass('Customers'); loadclass('EmailSettings'); $customer = new Customers($transaction->transactionCustomerID); $merchant = new Merchants($transaction->transactionMerchantID); //if(!($_CONF[mail_enabled]!='FALSE' && $merchant->merchantEmailSending==1)) return false; $merchantaccount = new MerchantAccounts($merchant->merchantMerchantAccountID); $site = new Sites($transaction->transactionSiteID); $order = unserialize($customer->customerOrderObject); $emailSettings = new EmailSettings($merchant->merchantEmailSettingID); $smarty = new Smarty(); $smarty->assign($transaction->getValues()); $smarty->assign($customer->getValues()); $smarty->assign($merchant->getValues()); $smarty->assign($merchantaccount->getValues()); $smarty->assign($emailSettings->getValues()); $smarty->assign($site->getValues()); $smarty->assign($order); $smarty->assign('Order', $order); if (!empty($emailSettings->emailFromEmail)) { $from = "{$emailSettings->emailCompanyName} <{$emailSettings->emailFromEmail}>"; } $recipients[] = $customer->customerEmail; if ($site->siteEmailSendCustomerService) { $recipients[] = $site->siteCustomerSupportEmail; } if ($site->siteEmailSendAdditionalRecipients) { $recipients[] = $site->siteEmailAdditionalRecipients; } $smarty->assign('mheaders', $emailSettings->emailHeaders); $emails_dir = $_CONF[root_dir] . $_CONF[emails_dir]; if (is_dir($emails_dir . "/merchant_emails/" . $merchant->getID())) { $emails_dir = $emails_dir . "/merchant_emails/" . $merchant->getID() . "/"; } switch ($transaction->transactionType) { case 'rebill': if ($transaction->transactionStatus == 'approved' || $transaction->transactionStatus == 'test' && $transaction->transactionReturnNumber == 'AUTH_TESTCARD_APP') { $subject = $emailSettings->emailPaymentSubject; $smarty->assign('msubject', $subject); if (!$site->siteRebillEmailTemplate) { $site->siteRebillEmailTemplate = $_CONF[emails_rebill]; } $out = $smarty->fetch($emails_dir . $site->siteRebillEmailTemplate); } else { return false; // $out=$smarty->fetch($_CONF[root_dir].$_CONF[emails_dir].$_CONF[emails_rebill]); } break; case 'sale': if ($transaction->transactionStatus == 'approved' || $transaction->transactionStatus == 'test' && $transaction->transactionReturnNumber == 'AUTH_TESTCARD_APP') { $subject = $emailSettings->emailPaymentSubject; $smarty->assign('msubject', $subject); if (!$site->sitePaymentEmailTemplate) { $site->sitePaymentEmailTemplate = $_CONF[emails_payment]; } $out = $smarty->fetch($emails_dir . $site->sitePaymentEmailTemplate); } else { return false; //$out=$smarty->fetch($_CONF[root_dir].$_CONF[emails_dir].$_CONF[emails_payment]); } break; case 'chargeback': $out = $smarty->fetch($emails_dir . $_CONF[emails_chargeback]); break; case 'refund': $out = $smarty->fetch($emails_dir . $_CONF[emails_refund]); break; case 'reversal': $out = $smarty->fetch($emails_dir . $_CONF[emails_reversal]); break; } $body = $smarty->getSmartyVar('capture.body'); $subject = $smarty->getSmartyVar('capture.subject'); $headers = array(); if ($add_h = explode("\n", $smarty->getSmartyVar('capture.headers'))) { $headers = array_merge($headers, $add_h); } if ($dump) { mydump($body); mydump($subject); mydump($headers); mydump($recipients); exit; } if ($_CONF[mail_enabled] != 'FALSE' && $merchant->merchantEmailSending == 1) { return pmail($recipients, $body, $subject, $headers, $from); } } }