/** * @inheritdoc */ public function fillPaymentFormDataset(Dataset $dataset, Transaction $transaction) { // add some common fields $dataset->setParam('action', 'gaf')->setParam('ver', 4)->setParam('datetime', date("YmdHis")); // convert amount into cents $amount = (int) ($transaction->getSum() * 100); // add transaction information /** @noinspection SpellCheckingInspection */ $dataset->setParam('id', $this->getConfParam('id'))->setParam('ecuno', $transaction->getTransactionId())->setParam('eamount', $amount)->setParam('cur', $transaction->getCurrency())->setParam('lang', $this->getLanguageCode($transaction->getLanguage()))->setParam('charEncoding', $this->getConfParam('charEncoding', 'UTF-8'))->setParam('feedBackUrl', $this->getReturnUrl())->setParam('delivery', $this->getConfParam('delivery', 'S')); if (intval($ecuno = $dataset->getParam('ecuno', 0)) < 100000) { $dataset->setParam('ecuno', $ecuno + 100000000); // add 100 000 000 } $this->addMacSignature($dataset); }
/** * This reorders parameters and removes the ones that are not set (empty values are allowed) * * @param Dataset $dataset * @param string $service What service parameters to return (array key) * @return array * @throws \dlds\payment\Exception */ public function getNormalizedMacParams(Dataset $dataset, $service) { $params = $this->getParamMacOrderDefinition(); if (!isset($params[$service])) { throw new Exception("Cannot normalize MAC params, unknown service: {$service}"); } $currentOrder = $params[$service]; $normalizedMacParams = array(); // reorder mac params foreach ($currentOrder as $param) { if ($dataset->offsetExists($param)) { $normalizedMacParams[$param] = $dataset->getParam($param); } } return $normalizedMacParams; }
/** * Generates a MAC key that corresponds to the parameter set specified by the first parameter. * * @param Dataset $dataset * @param string $requestType Key of 'mac param order definition' array * @return string */ private function generateMacKey(Dataset $dataset, $requestType) { $macDefinition = $this->getParamMacOrderDefinition(); $hashFunction = $this->getConfParam('hash_function', self::DEFAULT_HASH_FUNCTION); $macKey = ''; foreach ($macDefinition[$requestType] as $param) { $macKey .= sprintf('%s&', $dataset->hasParam($param) ? $dataset->getParam($param) : null); } $macKey .= $this->getConfParam('MAC_SECRET') . '&'; $macKey = \strtoupper($hashFunction($macKey)); return $macKey; }
/** * This can be overridden by child classes of iPizza if necessary */ public function addCommonParams(Dataset $dataset) { $dataset->setParam('VK_SERVICE', $this->getConfParam('VK_SERVICE', '1001'))->setParam('VK_VERSION', '008')->setParam('VK_SND_ID', $this->getConfParam('VK_SND_ID'))->setParam('VK_ACC', $this->getConfParam('VK_ACC'))->setParam('VK_NAME', $this->getConfParam('VK_NAME'))->setParam('VK_RETURN', $this->getReturnUrl())->setParam('VK_CANCEL', $this->getCancelUrl()); }