/** * @return array * @throws TpBadMethodCallException */ public function toSignedSoapRequestArray() { $this->assertConfig(); $array = $this->toSoapRequestArray(); $signature = TpDataApiSignature::compute($array, $this->_config->dataApiPassword); $signatureArray = array('signature' => $signature); $signed = array_merge($array, $signatureArray); return $signed; }
/** * @param string $operation * @param TpMerchantConfig $config * @param stdClass $data * @return TpDataApiResponse * @throws TpInvalidSignatureException */ public static function getResponse($operation, TpMerchantConfig $config, stdClass $data) { /** @var string|TpDataApiResponse $className Only class name. */ $className = preg_replace('/^get(.+)$/', 'TpDataApiGet$1Response', $operation); $fileName = $className . '.php'; TpUtils::requirePaths(array(array('dataApi', 'responses', $fileName))); $array = TpUtils::toArrayRecursive($data); $listPaths = $className::listPaths(); $flattened = TpDataApiSoapFlattener::processWithPaths($array, $listPaths); TpDataApiSignature::validate($flattened, $config->dataApiPassword); $dateTimePaths = $className::dateTimePaths(); $inflated = TpDataApiDateTimeInflater::processWithPaths($flattened, $dateTimePaths); $response = $className::createFromResponse($inflated); return $response; }
public static function compute(array $data, $password, array $arrayPaths) { $signature = new TpDataApiSignature($data, $password, $arrayPaths); return $signature->dataSignature(); }