protected function _ConstructPostData($postData) { $currency = GetDefaultCurrency(); $currencycode = strtolower($currency['currencycode']); switch ($postData['cctype']) { case 'VISA': $cctype = '001'; break; case 'MC': $cctype = '002'; break; case 'AMEX': $cctype = '003'; break; case 'DISCOVER': $cctype = '004'; break; case 'DINERS': $cctype = '005'; break; default: $cctype = '000'; break; } $amount = $this->GetGatewayAmount(); $billingDetails = $this->GetBillingDetails(); $timestamp = getmicrotime(); $transactionid = $this->GetCombinedOrderId(); $signatureData = getMerchantID() . $amount . $currencycode . $timestamp . 'sale'; $cybersourcePost['merchantID'] = getMerchantID(); $cybersourcePost['billTo_firstName'] = htmlentities($billingDetails['ordbillfirstname']); $cybersourcePost['billTo_lastName'] = $billingDetails['ordbilllastname']; $cybersourcePost['billTo_street1'] = $billingDetails['ordbillstreet1']; $cybersourcePost['billTo_city'] = $billingDetails['ordbillsuburb']; $cybersourcePost['billTo_state'] = $billingDetails['ordbillstate']; $cybersourcePost['billTo_postalCode'] = $billingDetails['ordbillzip']; $cybersourcePost['billTo_country'] = $billingDetails['ordbillcountry']; $cybersourcePost['billTo_email'] = $billingDetails['ordbillemail']; $cybersourcePost['card_cardType'] = $cctype; $cybersourcePost['card_accountNumber'] = $postData['ccno']; $cybersourcePost['card_expirationMonth'] = $postData['ccexpm']; $cybersourcePost['card_expirationYear'] = '20' . $postData['ccexpy']; $cybersourcePost['orderPage_timestamp'] = $timestamp; $cybersourcePost['orderPage_signaturePublic'] = hopHash($signatureData, getPublicKey()); $cybersourcePost['orderPage_serialNumber'] = getSerialNumber(); $cybersourcePost['orderPage_version'] = '4'; $cybersourcePost['orderPage_transactionType'] = 'sale'; $cybersourcePost['amount'] = $amount; $cybersourcePost['currency'] = $currencycode; $cybersourcePost['hash'] = md5($this->GetValue("accessid") . $transactionid . $_COOKIE['SHOP_ORDER_TOKEN'] . $amount); $cybersourcePost['orderid'] = $transactionid; $cybersourcePost['iscsessionid'] = $_COOKIE['SHOP_ORDER_TOKEN']; return $cybersourcePost; }
public function addIssuerSerial($X509Cert) { $name = getIssuerName($X509Cert); $serialNumber = getSerialNumber($X509Cert); $objXMLSecDSig = new XMLSecurityDSig(); if ($objDSig = $objXMLSecDSig->locateSignature($this->soapDoc)) { $this->SOAPXPath->registerNamespace('secdsig', XMLSecurityDSig::XMLDSIGNS); $query = "./secdsig:KeyInfo"; $nodeset = $this->SOAPXPath->query($query, $objDSig); $keyInfo = $nodeset->item(0); if (!$keyInfo) { $keyInfo = $objXMLSecDSig->createNewSignNode('KeyInfo'); $objDSig->appendChild($keyInfo); } $tokenRef = $this->soapDoc->createElementNS(WSSESoap::WSSENS, WSSESoap::WSSEPFX . ':SecurityTokenReference'); $keyInfo->appendChild($tokenRef); $x509Data = $objXMLSecDSig->createNewSignNode("X509Data"); $x509IssuerSerial = $objXMLSecDSig->createNewSignNode("X509IssuerSerial"); $x509Data->appendChild($x509IssuerSerial); $x509IssuerName = $objXMLSecDSig->createNewSignNode("X509IssuerName", $name); $x509SerialNumber = $objXMLSecDSig->createNewSignNode("X509SerialNumber", $serialNumber); $x509IssuerSerial->appendChild($x509IssuerName); $x509IssuerSerial->appendChild($x509SerialNumber); $tokenRef->appendChild($x509Data); } else { throw new Exception('Unable to locate digital signature'); } }
function InsertSignature($amount, $currency) { if (!isset($amount)) { $amount = "0.00"; } if (!isset($currency)) { $currency = "usd"; } $merchantID = getMerchantID(); $timestamp = getmicrotime(); $data = $merchantID . $amount . $currency . $timestamp; $pub = getPublicKey(); $serialNumber = getSerialNumber(); $pub_digest = hopHash($data, $pub); echo '<input type="hidden" name="amount" value="' . $amount . '">' . "\n"; echo '<input type="hidden" name="currency" value="' . $currency . '">' . "\n"; echo '<input type="hidden" name="orderPage_timestamp" value="' . $timestamp . '">' . "\n"; echo '<input type="hidden" name="merchantID" value="' . $merchantID . '">' . "\n"; echo '<input type="hidden" name="orderPage_signaturePublic" value="' . $pub_digest . '">' . "\n"; echo '<input type="hidden" name="orderPage_version" value="4">' . "\n"; echo '<input type="hidden" name="orderPage_serialNumber" value="' . $serialNumber . '">' . "\n"; }