private function validateMerchant(Merchant $merchant) { if (strlen($merchant->getMerchantID()) !== 9) { throw new ValidationException("Merchant.merchantID length is not 9"); } $length = preg_match('/[0-9]+/', $merchant->getMerchantID(), $matches); if ($length !== 1 || $matches[0] !== $merchant->getMerchantID()) { throw new ValidationException("Merchant.merchantID does not match format."); } if ($merchant->getSubID() > 999999 || $merchant->getSubID() < 0) { throw new ValidationException("Merchant.subID value must be between 0 and 999999."); } if (strlen($merchant->getMerchantReturnURL()) > 512) { throw new ValidationException("Merchant.merchantReturnURL length is to large."); } }
private function serializeMerchant(DOMElement $element, Merchant $merchant, $withUrl = false) { $element->appendChild(new DOMElement("merchantID", $merchant->getMerchantID())); $element->appendChild(new DOMElement("subID", $merchant->getSubID())); if ($withUrl) { $element->appendChild(new DOMElement("merchantReturnURL", $merchant->getMerchantReturnURL())); } }