当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Crypt_Hmac类代码示例

本文整理汇总了PHP中Zend_Crypt_Hmac的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Crypt_Hmac类的具体用法?PHP Zend_Crypt_Hmac怎么用?PHP Zend_Crypt_Hmac使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Crypt_Hmac类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _signAuthenticate

 /**
  * @desc Authenticate using sha1 Merchant signature
  * @see success Action during checkout
  * @param Varien_Object $response
  */
 protected function _signAuthenticate(Varien_Object $response)
 {
     if ($this->_getConfigData('demoMode') === 'Y') {
         $secretWord = $this->_getConfigData('secret_wordt', 'adyen_hpp');
     } else {
         $secretWord = $this->_getConfigData('secret_wordp', 'adyen_hpp');
     }
     // do it like this because $_GET is converting dot to underscore
     $queryString = $_SERVER['QUERY_STRING'];
     $result = array();
     $pairs = explode("&", $queryString);
     foreach ($pairs as $pair) {
         $nv = explode("=", $pair);
         $name = urldecode($nv[0]);
         $value = urldecode($nv[1]);
         $result[$name] = $value;
     }
     // do not use merchantSig in calculation
     unset($result['merchantSig']);
     // Sort the array by key using SORT_STRING order
     ksort($result, SORT_STRING);
     $signData = implode(":", array_map(array($this, 'escapeString'), array_merge(array_keys($result), array_values($result))));
     $signMac = Zend_Crypt_Hmac::compute(pack("H*", $secretWord), 'sha256', $signData);
     $localStringToHash = base64_encode(pack('H*', $signMac));
     if (strcmp($localStringToHash, $response->getData('merchantSig')) === 0) {
         return true;
     }
     return false;
 }
开发者ID:LybeAB,项目名称:magento,代码行数:34,代码来源:Authenticate.php

示例2: _generateHmacKey

 private static function _generateHmacKey($params = null, $apiKey = null)
 {
     $logger = self::getLoggerHandler();
     $signatureData = CitrusPay_RequestData::_generateSignatureData($params, $apiKey);
     $logger->info("Signature data is " . $signatureData);
     $hmackey = Zend_Crypt_Hmac::compute($apiKey, "sha1", $signatureData);
     $logger->info("Signature Key generated is " . $hmackey);
     return $hmackey;
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:9,代码来源:CitrusPayApiResource.php

示例3: _generateAuthKey

 /**
  * Generate the mac key name. Must be the same function as used in the InsuranceFunctions.php
  *
  * @param string $requesthash Request hash of request
  */
 private function _generateAuthKey($requesthash)
 {
     $config = Zend_Registry::get('params');
     $secret = null;
     // Capture HMAC secret key
     if (isset($config->dms) && isset($config->dms->localcache) && isset($config->dms->localcache->hmacsecret)) {
         $secret = $config->dms->localcache->hmacsecret;
     }
     if ($secret == null) {
         throw new Exception('hmac secret not set');
     }
     return strtoupper(Zend_Crypt_Hmac::compute($secret, 'sha256', $requesthash));
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:18,代码来源:IndexController.php

示例4: _signAuthenticate

 /**
  * @desc Authenticate using sha1 Merchant signature
  * @see success Action during checkout
  * @param Varien_Object $response
  */
 protected function _signAuthenticate(Varien_Object $response)
 {
     if ($this->_getConfigData('demoMode') === 'Y') {
         $secretWord = $this->_getConfigData('secret_wordt', 'adyen_hpp');
     } else {
         $secretWord = $this->_getConfigData('secret_wordp', 'adyen_hpp');
     }
     $sign = $response->getData('authResult') . $response->getData('pspReference') . $response->getData('merchantReference') . $response->getData('skinCode');
     $signMac = Zend_Crypt_Hmac::compute($secretWord, 'sha1', $sign);
     $localStringToHash = base64_encode(pack('H*', $signMac));
     if (strcmp($localStringToHash, $response->getData('merchantSig')) === 0) {
         return true;
     }
     return false;
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:20,代码来源:Authenticate.php

示例5: processCashResponse

 public function processCashResponse()
 {
     $response = $_REQUEST;
     $varienObj = new Varien_Object();
     foreach ($response as $code => $value) {
         if ($code == 'amount') {
             if (is_object($value)) {
                 $value = $value->value;
             }
             $code = 'value';
         }
         $varienObj->setData($code, $value);
     }
     $pspReference = $varienObj->getData('pspReference');
     $merchantReference = $varienObj->getData('merchantReference');
     $skinCode = $varienObj->getData('skinCode');
     $paymentAmount = $varienObj->getData('paymentAmount');
     $currencyCode = $varienObj->getData('currencyCode');
     $customPaymentMethod = $varienObj->getData('c_cash');
     $paymentMethod = $varienObj->getData('paymentMethod');
     $merchantSig = $varienObj->getData('merchantSig');
     $sign = $pspReference . $merchantReference . $skinCode . $paymentAmount . $currencyCode . $customPaymentMethod . $paymentMethod;
     $secretWord = $this->_getSecretWord();
     $signMac = Zend_Crypt_Hmac::compute($secretWord, 'sha1', $sign);
     $calMerchantSig = base64_encode(pack('H*', $signMac));
     // check if signatures are the same
     if ($calMerchantSig == $merchantSig) {
         //get order && payment objects
         $order = Mage::getModel('sales/order');
         //error
         $orderExist = $this->_incrementIdExist($varienObj, $merchantReference);
         if (empty($orderExist)) {
             $this->_writeLog("unknown order : {$merchantReference}");
         } else {
             $order->loadByIncrementId($merchantReference);
             $comment = Mage::helper('adyen')->__('Adyen Cash Result URL Notification: <br /> pspReference: %s <br /> paymentMethod: %s', $pspReference, $paymentMethod);
             $status = true;
             $history = Mage::getModel('sales/order_status_history')->setStatus($status)->setComment($comment)->setEntityName("order")->setOrder($order);
             $history->save();
             return $status;
         }
     }
     return false;
 }
开发者ID:Maikel-Koek,项目名称:magento,代码行数:44,代码来源:Process.php

示例6: _signS3UploadPolicy

 /**
  * Signed S3 Upload Policy
  *
  * @param string $policy            Base64 Encoded string that is the upload policy
  * @return string                   SHA1 encoded S3 Upload Policy
  */
 protected function _signS3UploadPolicy($policy)
 {
     $hmac = Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'SHA1', $policy, Zend_Crypt_Hmac::BINARY);
     return $hmac;
 }
开发者ID:arendasistemasintegrados,项目名称:mateusleme,代码行数:11,代码来源:Windows.php

示例7: _signParameters

 /**
  * Computes the RFC 2104-compliant HMAC signature for request parameters
  *
  * This implements the Amazon Web Services signature, as per the following
  * specification:
  *
  * 1. Sort all request parameters (including <tt>SignatureVersion</tt> and
  *    excluding <tt>Signature</tt>, the value of which is being created),
  *    ignoring case.
  *
  * 2. Iterate over the sorted list and append the parameter name (in its
  *    original case) and then its value. Do not URL-encode the parameter
  *    values before constructing this string. Do not use any separator
  *    characters when appending strings.
  *
  * @param array  $parameters the parameters for which to get the signature.
  * @param string $secretKey  the secret key to use to sign the parameters.
  *
  * @return string the signed data.
  */
 protected function _signParameters(array $paramaters)
 {
     $data = "POST\n";
     $data .= $this->getEndpoint()->getHost() . "\n";
     $data .= "/\n";
     uksort($paramaters, 'strcmp');
     unset($paramaters['Signature']);
     $arrData = array();
     foreach ($paramaters as $key => $value) {
         $value = urlencode($value);
         $value = str_replace("%7E", "~", $value);
         $value = str_replace("+", "%20", $value);
         $arrData[] = urlencode($key) . '=' . $value;
     }
     $data .= implode('&', $arrData);
     // require_once 'Zend/Crypt/Hmac.php';
     $hmac = Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'SHA256', $data, Zend_Crypt_Hmac::BINARY);
     return base64_encode($hmac);
 }
开发者ID:JaroslavRamba,项目名称:ex-facebook-bundle,代码行数:39,代码来源:SimpleDb.php

示例8: _signParameters

 /**
  * Computes the RFC 2104-compliant HMAC signature for request parameters
  *
  * This implements the Amazon Web Services signature, as per the following
  * specification:
  *
  * 1. Sort all request parameters (including <tt>SignatureVersion</tt> and
  *    excluding <tt>Signature</tt>, the value of which is being created),
  *    ignoring case.
  *
  * 2. Iterate over the sorted list and append the parameter name (in its
  *    original case) and then its value. Do not URL-encode the parameter
  *    values before constructing this string. Do not use any separator
  *    characters when appending strings.
  *
  * @param  string $queue_url  Queue URL
  * @param  array  $parameters the parameters for which to get the signature.
  *
  * @return string the signed data.
  */
 protected function _signParameters($url, array &$paramaters)
 {
     $data = $this->_httpMethod . "\n";
     $data .= parse_url($url, PHP_URL_HOST) . "\n";
     $data .= '' == ($path = parse_url($url, PHP_URL_PATH)) ? '/' : $path;
     $data .= "\n";
     uksort($paramaters, 'strcmp');
     unset($paramaters['Signature']);
     $arrData = array();
     foreach ($paramaters as $key => $value) {
         $arrData[] = $key . '=' . str_replace('%7E', '~', rawurlencode($value));
     }
     $data .= implode('&', $arrData);
     $hmac = Zend_Crypt_Hmac::compute($this->_secretKey, 'SHA256', $data, Zend_Crypt_Hmac::BINARY);
     $paramaters['Signature'] = base64_encode($hmac);
     return $data;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:37,代码来源:V2.php

示例9: signParameters

 /**
  * Computes the RFC 2104-compliant HMAC signature for request parameters
  *
  * This implements the Amazon Web Services signature, as per the following
  * specification:
  *
  * 1. Sort all request parameters (including <tt>SignatureVersion</tt> and
  *    excluding <tt>Signature</tt>, the value of which is being created),
  *    ignoring case.
  *
  * 2. Iterate over the sorted list and append the parameter name (in its
  *    original case) and then its value. Do not URL-encode the parameter
  *    values before constructing this string. Do not use any separator
  *    characters when appending strings.
  *
  * @param array  $parameters the parameters for which to get the signature.
  * @param string $secretKey  the secret key to use to sign the parameters.
  *
  * @return string the signed data.
  */
 protected function signParameters(array $paramaters)
 {
     $data = "POST\n";
     $data .= $this->_getRegion() . $this->_ec2Endpoint . "\n";
     $data .= "/\n";
     uksort($paramaters, 'strcmp');
     unset($paramaters['Signature']);
     $arrData = array();
     foreach ($paramaters as $key => $value) {
         $arrData[] = $key . '=' . str_replace("%7E", "~", rawurlencode($value));
     }
     $data .= implode('&', $arrData);
     require_once 'Zend/Crypt/Hmac.php';
     $hmac = Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'SHA256', $data, Zend_Crypt_Hmac::BINARY);
     return base64_encode($hmac);
 }
开发者ID:fredcido,项目名称:cenbrap,代码行数:36,代码来源:Abstract.php

示例10: addSignature

 /**
  * Add the S3 Authorization signature to the request headers
  *
  * @param  string $method
  * @param  string $path
  * @param  array &$headers
  * @return string
  */
 protected function addSignature($method, $path, &$headers)
 {
     if (!is_array($headers)) {
         $headers = array($headers);
     }
     $type = $md5 = $date = '';
     // Search for the Content-type, Content-MD5 and Date headers
     foreach ($headers as $key => $val) {
         if (strcasecmp($key, 'content-type') == 0) {
             $type = $val;
         } else {
             if (strcasecmp($key, 'content-md5') == 0) {
                 $md5 = $val;
             } else {
                 if (strcasecmp($key, 'date') == 0) {
                     $date = $val;
                 }
             }
         }
     }
     // If we have an x-amz-date header, use that instead of the normal Date
     if (isset($headers['x-amz-date']) && isset($date)) {
         $date = '';
     }
     $sig_str = "{$method}\n{$md5}\n{$type}\n{$date}\n";
     // For x-amz- headers, combine like keys, lowercase them, sort them
     // alphabetically and remove excess spaces around values
     $amz_headers = array();
     foreach ($headers as $key => $val) {
         $key = strtolower($key);
         if (substr($key, 0, 6) == 'x-amz-') {
             if (is_array($val)) {
                 $amz_headers[$key] = $val;
             } else {
                 $amz_headers[$key][] = preg_replace('/\\s+/', ' ', $val);
             }
         }
     }
     if (!empty($amz_headers)) {
         ksort($amz_headers);
         foreach ($amz_headers as $key => $val) {
             $sig_str .= $key . ':' . implode(',', $val) . "\n";
         }
     }
     $sig_str .= '/' . parse_url($path, PHP_URL_PATH);
     if (strpos($path, '?location') !== false) {
         $sig_str .= '?location';
     } else {
         if (strpos($path, '?acl') !== false) {
             $sig_str .= '?acl';
         } else {
             if (strpos($path, '?torrent') !== false) {
                 $sig_str .= '?torrent';
             }
         }
     }
     $signature = base64_encode(Zend_Crypt_Hmac::compute($this->_getSecretKey(), 'sha1', utf8_encode($sig_str), Zend_Crypt_Hmac::BINARY));
     $headers['Authorization'] = 'AWS ' . $this->_getAccessKey() . ':' . $signature;
     return $sig_str;
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:68,代码来源:S3.php

示例11: computeSignature

 /**
  * Compute Signature for Authentication with Amazon Product Advertising Webservices
  *
  * @param  string $baseUri
  * @param  string $secretKey
  * @param  array $options
  * @return string
  */
 public static function computeSignature($baseUri, $secretKey, array $options)
 {
     // require_once "Zend/Crypt/Hmac.php";
     $signature = self::buildRawSignature($baseUri, $options);
     return base64_encode(Zend_Crypt_Hmac::compute($secretKey, 'sha256', $signature, Zend_Crypt_Hmac::BINARY));
 }
开发者ID:JaroslavRamba,项目名称:ex-facebook-bundle,代码行数:14,代码来源:Amazon.php

示例12: signParameters

 /**
  * Computes the RFC 2104-compliant HMAC signature for request parameters
  *
  * This implements the Amazon Web Services signature, as per the following
  * specification:
  *
  * 1. Sort all request parameters (including <tt>SignatureVersion</tt> and
  *    excluding <tt>Signature</tt>, the value of which is being created),
  *    ignoring case.
  *
  * 2. Iterate over the sorted list and append the parameter name (in its
  *    original case) and then its value. Do not URL-encode the parameter
  *    values before constructing this string. Do not use any separator
  *    characters when appending strings.
  *
  * @param array  $parameters the parameters for which to get the signature.
  * @param string $secretKey  the secret key to use to sign the parameters.
  *
  * @return string the signed data.
  */
 protected function signParameters(array $paramaters)
 {
     $data = '';
     uksort($paramaters, 'strcasecmp');
     unset($paramaters['Signature']);
     foreach ($paramaters as $key => $value) {
         $data .= $key . $value;
     }
     require_once 'Zend/Crypt/Hmac.php';
     $hmac = Zend_Crypt_Hmac::compute($this->getSecretKey(), 'SHA1', $data, Zend_Crypt_Hmac::BINARY);
     return base64_encode($hmac);
 }
开发者ID:jwhitcraft,项目名称:zend_service_amazon_ec2,代码行数:32,代码来源:Abstract.php

示例13: _signParameters

 /**
  * Computes the RFC 2104-compliant HMAC signature for request parameters
  *
  * This implements the Amazon Web Services signature, as per the following
  * specification:
  *
  * 1. Sort all request parameters (including <tt>SignatureVersion</tt> and
  *    excluding <tt>Signature</tt>, the value of which is being created),
  *    ignoring case.
  *
  * 2. Iterate over the sorted list and append the parameter name (in its
  *    original case) and then its value. Do not URL-encode the parameter
  *    values before constructing this string. Do not use any separator
  *    characters when appending strings.
  *
  * @param  string $queue_url  Queue URL
  * @param  array  $parameters the parameters for which to get the signature.
  *
  * @return string the signed data.
  */
 protected function _signParameters($url, array &$paramaters)
 {
     $data = '';
     uksort($paramaters, 'strcasecmp');
     unset($paramaters['Signature']);
     foreach ($paramaters as $key => $value) {
         $data .= $key . $value;
     }
     $hmac = Zend_Crypt_Hmac::compute($this->_secretKey, 'SHA1', $data, Zend_Crypt_Hmac::BINARY);
     $paramaters['Signature'] = base64_encode($hmac);
     return $data;
 }
开发者ID:schlypel,项目名称:YiiBackboneBoilerplate,代码行数:32,代码来源:V1.php

示例14: getFormFields

 public function getFormFields()
 {
     $this->_initOrder();
     $order = $this->_order;
     $realOrderId = $order->getRealOrderId();
     $orderCurrencyCode = $order->getOrderCurrencyCode();
     // check if paybymail has it's own skin
     $skinCode = trim($this->_getConfigData('skin_code', 'adyen_pay_by_mail', $order->getStoreId()));
     if ($skinCode == "") {
         // use HPP skin and HMAC
         $skinCode = trim($this->_getConfigData('skinCode', 'adyen_hpp', $order->getStoreId()));
         $secretWord = $this->_getSecretWord($order->getStoreId(), 'adyen_hpp');
     } else {
         // use paybymail skin and hmac
         $secretWord = $this->_getSecretWord($order->getStoreId(), 'adyen_pay_by_mail');
     }
     $amount = Mage::helper('adyen')->formatAmount($order->getGrandTotal(), $orderCurrencyCode);
     $merchantAccount = trim($this->_getConfigData('merchantAccount', null, $order->getStoreId()));
     $shopperEmail = $order->getCustomerEmail();
     $customerId = $order->getCustomerId();
     $shopperIP = $order->getRemoteIp();
     $browserInfo = $_SERVER['HTTP_USER_AGENT'];
     $shopperLocale = trim($this->_getConfigData('shopperlocale', null, $order->getStoreId()));
     $shopperLocale = !empty($shopperLocale) ? $shopperLocale : Mage::app()->getLocale()->getLocaleCode();
     $countryCode = trim($this->_getConfigData('countryCode', null, $order->getStoreId()));
     $countryCode = !empty($countryCode) ? $countryCode : false;
     // if directory lookup is enabled use the billingadress as countrycode
     if ($countryCode == false) {
         if (is_object($order->getBillingAddress()) && $order->getBillingAddress()->getCountry() != "") {
             $countryCode = $order->getBillingAddress()->getCountry();
         }
     }
     $adyFields = array();
     $deliveryDays = (int) $this->_getConfigData('delivery_days', 'adyen_hpp', $order->getStoreId());
     $deliveryDays = !empty($deliveryDays) ? $deliveryDays : 5;
     $adyFields['merchantAccount'] = $merchantAccount;
     $adyFields['merchantReference'] = $realOrderId;
     $adyFields['paymentAmount'] = (int) $amount;
     $adyFields['currencyCode'] = $orderCurrencyCode;
     $adyFields['shipBeforeDate'] = date("Y-m-d", mktime(date("H"), date("i"), date("s"), date("m"), date("j") + $deliveryDays, date("Y")));
     $adyFields['skinCode'] = $skinCode;
     $adyFields['shopperLocale'] = $shopperLocale;
     $adyFields['countryCode'] = $countryCode;
     //order data
     $items = $order->getAllItems();
     $shipmentAmount = number_format($order->getShippingAmount() + $order->getShippingTaxAmount(), 2, ',', ' ');
     $prodDetails = Mage::helper('adyen')->__('Shipment cost: %s %s <br />', $shipmentAmount, $orderCurrencyCode);
     $prodDetails .= Mage::helper('adyen')->__('Order rows: <br />');
     foreach ($items as $item) {
         if ($item->getParentItem()) {
             continue;
         }
         $name = $item->getName();
         $qtyOrdered = $this->_numberFormat($item->getQtyOrdered(), '0');
         $rowTotal = number_format($item->getRowTotalInclTax(), 2, ',', ' ');
         $prodDetails .= Mage::helper('adyen')->__('%s ( Qty: %s ) (Price: %s %s ) <br />', $name, $qtyOrdered, $rowTotal, $orderCurrencyCode);
     }
     $adyFields['orderData'] = base64_encode(gzencode($prodDetails));
     //depreacated by Adyen
     $sessionValidity = (int) trim($this->_getConfigData('session_validity', 'adyen_pay_by_mail', $order->getStoreId()));
     if ($sessionValidity == "") {
         $sessionValidity = 3;
     }
     $adyFields['sessionValidity'] = date("c", strtotime("+" . $sessionValidity . " days"));
     $adyFields['shopperEmail'] = $shopperEmail;
     // recurring
     $recurringType = trim($this->_getConfigData('recurringtypes', 'adyen_abstract', $order->getStoreId()));
     $adyFields['recurringContract'] = $recurringType;
     $adyFields['shopperReference'] = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId;
     //blocked methods
     $adyFields['blockedMethods'] = "";
     /*
      * This feld will be appended as-is to the return URL when the shopper completes, or abandons, the payment and
      * returns to your shop; it is typically used to transmit a session ID. This feld has a maximum of 128 characters
      * This is an optional field and not necessary by default
      */
     $adyFields['merchantReturnData'] = "";
     $openinvoiceType = $this->_getConfigData('openinvoicetypes', 'adyen_openinvoice', $order->getStoreId());
     if ($this->_code == "adyen_openinvoice" || $this->getInfoInstance()->getCcType() == "klarna" || $this->getInfoInstance()->getCcType() == "afterpay_default") {
         $adyFields['billingAddressType'] = "1";
         $adyFields['deliveryAddressType'] = "1";
         $adyFields['shopperType'] = "1";
     } else {
         $adyFields['billingAddressType'] = "";
         $adyFields['deliveryAddressType'] = "";
         $adyFields['shopperType'] = "";
     }
     //the data that needs to be signed is a concatenated string of the form data
     $sign = $adyFields['paymentAmount'] . $adyFields['currencyCode'] . $adyFields['shipBeforeDate'] . $adyFields['merchantReference'] . $adyFields['skinCode'] . $adyFields['merchantAccount'] . $adyFields['sessionValidity'] . $adyFields['shopperEmail'] . $adyFields['shopperReference'] . $adyFields['recurringContract'] . $adyFields['blockedMethods'] . $adyFields['merchantReturnData'] . $adyFields['billingAddressType'] . $adyFields['deliveryAddressType'] . $adyFields['shopperType'];
     // Sort the array by key using SORT_STRING order
     ksort($adyFields, SORT_STRING);
     // Generate the signing data string
     $signData = implode(":", array_map(array($this, 'escapeString'), array_merge(array_keys($adyFields), array_values($adyFields))));
     //Generate SHA256 HMAC encrypted merchant signature
     $signMac = Zend_Crypt_Hmac::compute(pack("H*", $secretWord), 'sha256', $signData);
     $adyFields['merchantSig'] = base64_encode(pack('H*', $signMac));
     Mage::log($adyFields, self::DEBUG_LEVEL, 'adyen_http-request.log', true);
     return $adyFields;
 }
开发者ID:LybeAB,项目名称:magento,代码行数:99,代码来源:PayByMail.php

示例15: getFormFields


//.........这里部分代码省略.........
             continue;
         }
         $name = $item->getName();
         $qtyOrdered = $this->_numberFormat($item->getQtyOrdered(), '0');
         $rowTotal = number_format($item->getRowTotalInclTax(), 2, ',', ' ');
         $prodDetails .= Mage::helper('adyen')->__('%s ( Qty: %s ) (Price: %s %s ) <br />', $name, $qtyOrdered, $rowTotal, $orderCurrencyCode);
     }
     $adyFields['orderData'] = base64_encode(gzencode($prodDetails));
     //depreacated by Adyen
     $adyFields['sessionValidity'] = date(DATE_ATOM, mktime(date("H") + 1, date("i"), date("s"), date("m"), date("j"), date("Y")));
     $adyFields['shopperEmail'] = $shopperEmail;
     // recurring
     $recurringType = trim($this->_getConfigData('recurringtypes', 'adyen_abstract'));
     // Paypal does not allow ONECLICK,RECURRING will be fixed on adyen platform but this is the quickfix for now
     if ($this->getInfoInstance()->getMethod() == "adyen_hpp_paypal" && $recurringType == 'ONECLICK,RECURRING') {
         $recurringType = "RECURRING";
     }
     if ($customerId) {
         $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
         $customerId = $customer->getData('adyen_customer_ref') ?: $customer->getData('increment_id') ?: $customerId;
     }
     $adyFields['recurringContract'] = $recurringType;
     $adyFields['shopperReference'] = !empty($customerId) ? $customerId : self::GUEST_ID . $realOrderId;
     //blocked methods
     $adyFields['blockedMethods'] = "";
     /*
      * This feld will be appended as-is to the return URL when the shopper completes, or abandons, the payment and
      * returns to your shop; it is typically used to transmit a session ID. This feld has a maximum of 128 characters
      * This is an optional field and not necessary by default
      */
     $adyFields['merchantReturnData'] = "";
     $openinvoiceType = $this->_getConfigData('openinvoicetypes', 'adyen_openinvoice');
     if ($this->_code == "adyen_openinvoice" || $this->getInfoInstance()->getCcType() == "klarna" || $this->getInfoInstance()->getCcType() == "afterpay_default") {
         $adyFields['billingAddressType'] = "1";
         $adyFields['deliveryAddressType'] = "1";
         // get shopperType setting
         $shopperType = $this->_getConfigData("shoppertype", "adyen_openinvoice");
         if ($shopperType == '1') {
             $adyFields['shopperType'] = "";
         } else {
             $adyFields['shopperType'] = "1";
         }
     } else {
         // for other payment methods like creditcard don't show avs address field in skin
         $adyFields['billingAddressType'] = "2";
         // Only set DeliveryAddressType to hidden and in request if there is a shipping address otherwise keep it empty
         $deliveryAddress = $order->getShippingAddress();
         if ($deliveryAddress != null) {
             $adyFields['deliveryAddressType'] = "2";
         } else {
             $adyFields['deliveryAddressType'] = "";
         }
         $adyFields['shopperType'] = "";
     }
     // get extra fields
     $adyFields = Mage::getModel('adyen/adyen_openinvoice')->getOptionalFormFields($adyFields, $this->_order);
     // For IDEAL add isuerId into request so bank selection is skipped
     if (strpos($this->getInfoInstance()->getCcType(), "ideal") !== false) {
         $adyFields['issuerId'] = $this->getInfoInstance()->getPoNumber();
     }
     // if option to put Return Url in request from magento is enabled add this in the request
     $returnUrlInRequest = $this->_getConfigData('return_url_in_request', 'adyen_hpp');
     if ($returnUrlInRequest) {
         $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true) . "adyen/process/success";
         $adyFields['resURL'] = $url;
     }
     $secretWord = $this->_getSecretWord();
     if ($this->_code == "adyen_openinvoice") {
         $brandCode = $this->_getConfigData('openinvoicetypes', 'adyen_openinvoice');
         $adyFields['brandCode'] = $brandCode;
     } else {
         $brandCode = $this->getInfoInstance()->getCcType();
         if ($brandCode) {
             $adyFields['brandCode'] = $brandCode;
         }
     }
     // set offset to 0
     $adyFields['offset'] = "0";
     // eventHandler to overwrite the adyFields without changing module code
     $adyFields = new Varien_Object($adyFields);
     Mage::dispatchEvent('adyen_payment_hpp_fields', array('order' => $order, 'fields' => $adyFields));
     $adyFields = $adyFields->getData();
     // Sort the array by key using SORT_STRING order
     ksort($adyFields, SORT_STRING);
     // Generate the signing data string
     $signData = implode(":", array_map(array($this, 'escapeString'), array_merge(array_keys($adyFields), array_values($adyFields))));
     $signMac = Zend_Crypt_Hmac::compute(pack("H*", $secretWord), 'sha256', $signData);
     $adyFields['merchantSig'] = base64_encode(pack('H*', $signMac));
     // pos over hpp
     //         disable this because no one using this and it will always show POS payment method
     //         $terminalcode = 'redirect';
     //         $adyFields['pos.serial_number'] = $terminalcode;
     //         // calculate signatature pos
     //         $strsign = "merchantSig:pos.serial_number|" . $adyFields['merchantSig'] . ":" . $terminalcode;
     //         $signPOS = Zend_Crypt_Hmac::compute($secretWord, 'sha1', $strsign);
     //         $adyFields['pos.sig'] = base64_encode(pack('H*', $signPOS));
     Mage::log($adyFields, self::DEBUG_LEVEL, 'adyen_http-request.log', true);
     //        print_r($adyFields);die();
     return $adyFields;
 }
开发者ID:Maikel-Koek,项目名称:magento,代码行数:101,代码来源:Hpp.php


注:本文中的Zend_Crypt_Hmac类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。