M2_AuthorizeNet_Subscription

A class that contains all fields for an AuthorizeNet ARB Subscription.

Defined (1)

The class is defined in the following location(s).

/lib/authorize.net/lib/shared/AuthorizeNetTypes.php  
  1. class M2_AuthorizeNet_Subscription 
  2.  
  3. public $name; 
  4. public $intervalLength; 
  5. public $intervalUnit; 
  6. public $startDate; 
  7. public $totalOccurrences; 
  8. public $trialOccurrences; 
  9. public $amount; 
  10. public $trialAmount; 
  11. public $creditCardCardNumber; 
  12. public $creditCardExpirationDate; 
  13. public $creditCardCardCode; 
  14. public $bankAccountAccountType; 
  15. public $bankAccountRoutingNumber; 
  16. public $bankAccountAccountNumber; 
  17. public $bankAccountNameOnAccount; 
  18. public $bankAccountEcheckType; 
  19. public $bankAccountBankName; 
  20. public $orderInvoiceNumber; 
  21. public $orderDescription; 
  22. public $customerId; 
  23. public $customerEmail; 
  24. public $customerPhoneNumber; 
  25. public $customerFaxNumber; 
  26. public $billToFirstName; 
  27. public $billToLastName; 
  28. public $billToCompany; 
  29. public $billToAddress; 
  30. public $billToCity; 
  31. public $billToState; 
  32. public $billToZip; 
  33. public $billToCountry; 
  34. public $shipToFirstName; 
  35. public $shipToLastName; 
  36. public $shipToCompany; 
  37. public $shipToAddress; 
  38. public $shipToCity; 
  39. public $shipToState; 
  40. public $shipToZip; 
  41. public $shipToCountry; 
  42.  
  43. public function getXml() 
  44. $xml = "<subscription> 
  45. <name>{$this->name}</name> 
  46. <paymentSchedule> 
  47. <interval> 
  48. <length>{$this->intervalLength}</length> 
  49. <unit>{$this->intervalUnit}</unit> 
  50. </interval> 
  51. <startDate>{$this->startDate}</startDate> 
  52. <totalOccurrences>{$this->totalOccurrences}</totalOccurrences> 
  53. <trialOccurrences>{$this->trialOccurrences}</trialOccurrences> 
  54. </paymentSchedule> 
  55. <amount>{$this->amount}</amount> 
  56. <trialAmount>{$this->trialAmount}</trialAmount> 
  57. <payment> 
  58. <creditCard> 
  59. <cardNumber>{$this->creditCardCardNumber}</cardNumber> 
  60. <expirationDate>{$this->creditCardExpirationDate}</expirationDate> 
  61. <cardCode>{$this->creditCardCardCode}</cardCode> 
  62. </creditCard> 
  63. <bankAccount> 
  64. <accountType>{$this->bankAccountAccountType}</accountType> 
  65. <routingNumber>{$this->bankAccountRoutingNumber}</routingNumber> 
  66. <accountNumber>{$this->bankAccountAccountNumber}</accountNumber> 
  67. <nameOnAccount>{$this->bankAccountNameOnAccount}</nameOnAccount> 
  68. <echeckType>{$this->bankAccountEcheckType}</echeckType> 
  69. <bankName>{$this->bankAccountBankName}</bankName> 
  70. </bankAccount> 
  71. </payment> 
  72. <order> 
  73. <invoiceNumber>{$this->orderInvoiceNumber}</invoiceNumber> 
  74. <description>{$this->orderDescription}</description> 
  75. </order> 
  76. <customer> 
  77. <id>{$this->customerId}</id> 
  78. <email>{$this->customerEmail}</email> 
  79. <phoneNumber>{$this->customerPhoneNumber}</phoneNumber> 
  80. <faxNumber>{$this->customerFaxNumber}</faxNumber> 
  81. </customer> 
  82. <billTo> 
  83. <firstName>{$this->billToFirstName}</firstName> 
  84. <lastName>{$this->billToLastName}</lastName> 
  85. <company>{$this->billToCompany}</company> 
  86. <address>{$this->billToAddress}</address> 
  87. <city>{$this->billToCity}</city> 
  88. <state>{$this->billToState}</state> 
  89. <zip>{$this->billToZip}</zip> 
  90. <country>{$this->billToCountry}</country> 
  91. </billTo> 
  92. <shipTo> 
  93. <firstName>{$this->shipToFirstName}</firstName> 
  94. <lastName>{$this->shipToLastName}</lastName> 
  95. <company>{$this->shipToCompany}</company> 
  96. <address>{$this->shipToAddress}</address> 
  97. <city>{$this->shipToCity}</city> 
  98. <state>{$this->shipToState}</state> 
  99. <zip>{$this->shipToZip}</zip> 
  100. <country>{$this->shipToCountry}</country> 
  101. </shipTo> 
  102. </subscription>"; 
  103.  
  104. $xml_clean = ""; 
  105. // Remove any blank child elements 
  106. foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) { 
  107. if (!preg_match('/><\//', $line)) { 
  108. $xml_clean .= $line . "\n"; 
  109.  
  110. // Remove any blank parent elements 
  111. $element_removed = 1; 
  112. // Recursively repeat if a change is made 
  113. while ($element_removed) { 
  114. $element_removed = 0; 
  115. if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) { 
  116. $xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean); 
  117. $element_removed = 1; 
  118.  
  119. // Remove any blank lines 
  120. // $xml_clean = preg_replace('/\r\n[\s]+\r\n/', '', $xml_clean); 
  121. return $xml_clean;