billTo = new AuthorizeNetAddress; $this->payment = new AuthorizeNetPayment; } } /** * A class that contains all fields for a CIM Payment Type. * * @package AuthorizeNet * @subpackage AuthorizeNetCIM */ class AuthorizeNetPayment { public $creditCard; public $bankAccount; public function __construct() { $this->creditCard = new AuthorizeNetCreditCard; $this->bankAccount = new AuthorizeNetBankAccount; } } /** * A class that contains all fields for a CIM Transaction. * * @package AuthorizeNet * @subpackage AuthorizeNetCIM */ class AuthorizeNetTransaction { public $amount; public $tax; public $shipping; public $duty; public $lineItems = array(); public $customerProfileId; public $customerPaymentProfileId; public $customerShippingAddressId; public $creditCardNumberMasked; public $bankRoutingNumberMasked; public $bankAccountNumberMasked; public $order; public $taxExempt; public $recurringBilling; public $cardCode; public $splitTenderId; public $approvalCode; public $transId; public function __construct() { $this->tax = (object)array(); $this->tax->amount = ""; $this->tax->name = ""; $this->tax->description = ""; $this->shipping = (object)array(); $this->shipping->amount = ""; $this->shipping->name = ""; $this->shipping->description = ""; $this->duty = (object)array(); $this->duty->amount = ""; $this->duty->name = ""; $this->duty->description = ""; // line items $this->order = (object)array(); $this->order->invoiceNumber = ""; $this->order->description = ""; $this->order->purchaseOrderNumber = ""; } } /** * A class that contains all fields for a CIM Transaction Line Item. * * @package AuthorizeNet * @subpackage AuthorizeNetCIM */ class AuthorizeNetLineItem { public $itemId; public $name; public $description; public $quantity; public $unitPrice; public $taxable; } /** * A class that contains all fields for a CIM Credit Card. * * @package AuthorizeNet * @subpackage AuthorizeNetCIM */ class AuthorizeNetCreditCard { public $cardNumber; public $expirationDate; public $cardCode; } /** * A class that contains all fields for a CIM Bank Account. * * @package AuthorizeNet * @subpackage AuthorizeNetCIM */ class AuthorizeNetBankAccount { public $accountType; public $routingNumber; public $accountNumber; public $nameOnAccount; public $echeckType; public $bankName; } /** * A class that contains all fields for an AuthorizeNet ARB Subscription. * * @package AuthorizeNet * @subpackage AuthorizeNetARB */ class AuthorizeNet_Subscription { public $name; public $intervalLength; public $intervalUnit; public $startDate; public $totalOccurrences; public $trialOccurrences; public $amount; public $trialAmount; public $creditCardCardNumber; public $creditCardExpirationDate; public $creditCardCardCode; public $bankAccountAccountType; public $bankAccountRoutingNumber; public $bankAccountAccountNumber; public $bankAccountNameOnAccount; public $bankAccountEcheckType; public $bankAccountBankName; public $orderInvoiceNumber; public $orderDescription; public $customerId; public $customerEmail; public $customerPhoneNumber; public $customerFaxNumber; public $billToFirstName; public $billToLastName; public $billToCompany; public $billToAddress; public $billToCity; public $billToState; public $billToZip; public $billToCountry; public $shipToFirstName; public $shipToLastName; public $shipToCompany; public $shipToAddress; public $shipToCity; public $shipToState; public $shipToZip; public $shipToCountry; public function getXml() { $xml = " {$this->name} {$this->intervalLength} {$this->intervalUnit} {$this->startDate} {$this->totalOccurrences} {$this->trialOccurrences} {$this->amount} {$this->trialAmount} {$this->creditCardCardNumber} {$this->creditCardExpirationDate} {$this->creditCardCardCode} {$this->bankAccountAccountType} {$this->bankAccountRoutingNumber} {$this->bankAccountAccountNumber} {$this->bankAccountNameOnAccount} {$this->bankAccountEcheckType} {$this->bankAccountBankName} {$this->orderInvoiceNumber} {$this->orderDescription} {$this->customerId} {$this->customerEmail} {$this->customerPhoneNumber} {$this->customerFaxNumber} {$this->billToFirstName} {$this->billToLastName} {$this->billToCompany}
{$this->billToAddress}
{$this->billToCity} {$this->billToState} {$this->billToZip} {$this->billToCountry}
{$this->shipToFirstName} {$this->shipToLastName} {$this->shipToCompany}
{$this->shipToAddress}
{$this->shipToCity} {$this->shipToState} {$this->shipToZip} {$this->shipToCountry}
"; $xml_clean = ""; // Remove any blank child elements foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) { if (!preg_match('/><\//', $line)) { $xml_clean .= $line . "\n"; } } // Remove any blank parent elements $element_removed = 1; // Recursively repeat if a change is made while ($element_removed) { $element_removed = 0; if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) { $xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean); $element_removed = 1; } } // Remove any blank lines // $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean); return $xml_clean; } } /** * A class that contains all fields for an AuthorizeNet ARB SubscriptionList. * * @package AuthorizeNet * @subpackage AuthorizeNetARB */ class AuthorizeNetGetSubscriptionList { public $searchType; public $sorting; public $paging; public function getXml() { $emptyString = ""; $sortingXml = (is_null($this->sorting)) ? $emptyString : $this->sorting->getXml(); $pagingXml = (is_null($this->paging)) ? $emptyString : $this->paging->getXml(); $xml = " {$this->searchType}" .$sortingXml .$pagingXml ; $xml_clean = ""; // Remove any blank child elements foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) { if (!preg_match('/><\//', $line)) { $xml_clean .= $line . "\n"; } } // Remove any blank parent elements $element_removed = 1; // Recursively repeat if a change is made while ($element_removed) { $element_removed = 0; if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) { $xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean); $element_removed = 1; } } // Remove any blank lines // $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean); return $xml_clean; } } class AuthorizeNetSubscriptionListPaging { public $limit; public $offset; public function getXml() { $xml = " {$this->limit} {$this->offset} "; return $xml; } } class AuthorizeNetSubscriptionListSorting { public $orderBy; public $orderDescending; public function getXml() { $xml = " {$this->orderBy} {$this->orderDescending} "; return $xml; } }