Новости | FAQ | Авторы | Документация | В действии | Библиотека |
Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
agat 20.05.2008 14:02 / 20.05.2008 22:18
советую всем интересующимся данным вопросом ознакомится с принципами работы схемы.################################################ @payByCreditCard[hParams][dPurchaseTime;sTotalAmount;sAltTotalAmount;sSD;sDataToSign] ^use[OpenSSL.p] $oSSL[^OpenSSL::create[ $.sOpensslScript[/cgi-bin/openssl/openssl.exe] $.sServerCert[/data/openssl/test-server.pub] $.sUserCert[/data/openssl/1752144.pem] ]] ^if(def $hParams.orderID){ $sImage[^image[ $.src[$MEDIA_DIR/loading.gif] $.border[0] $.align[left] $.hspace[15] ]] ^switch[$oSite.language.uri]{ ^case[ru]{<h3>Устанавливается соединение с процессинговым центром</h3><br />$sImage Пожалуйста, подождите...} ^case[en]{<h3>Connecting to the processing center</h3><br />$sImage Please wait...} ^case[tr]{<h3>İşlem merkezine bağlanıyor</h3><br />$sImage Lütfen bekleyin...} } ^try{ $tUPC[^table::load[/data/upc.cfg]] }{ $exception.handled(1) ^Lib:location[/404/] } $dPurchaseTime[^dtf:format[%y%m%d%H%M%S]] $sTotalAmount[^eval($hParams.totalAmount*100)] $sAltTotalAmount[^eval($hParams.altTotalAmount*100)] $sSD[] $sDataToSign[$tUPC.MerchantID^;$tUPC.TerminalID^;$dPurchaseTime^;$hParams.orderID^;$tUPC.Currency,$tUPC.AltCurrency^;$sTotalAmount,$sAltTotalAmount^;$sSD^;] <form name="UPCform" method="post" action="https://secure.upc.ua/ecgtest/enter"> <input type="hidden" name="Version" value="1" /> <input type="hidden" name="MerchantID" value="$tUPC.MerchantID" /> <input type="hidden" name="locale" value="^switch[$oSite.language.uri]{^case[ru]{ru}^case[en;tr]{en}}" /> <input type="hidden" name="TerminalID" value="$tUPC.TerminalID" /> <input type="hidden" name="TotalAmount" value="$sTotalAmount" /> <input type="hidden" name="Currency" value="$tUPC.Currency" /> <input type="hidden" name="AltTotalAmount" value="$sAltTotalAmount" /> <input type="hidden" name="AltCurrency" value="$tUPC.AltCurrency" /> <input type="hidden" name="OrderID" value="$hParams.orderID" /> <input type="hidden" name="PurchaseTime" value="$dPurchaseTime" /> <input type="hidden" name="PurchaseDesc" value="$hParams.sPurchaseDesc" /> <input type="hidden" name="Signature" value="^oSSL.sign[$sDataToSign]" /> <script language="javascript"> <!-- document.UPCform.submit()^; // --> </script> <noscript> <input type="submit" value="^Say:next[]" /> </noscript> </form> }{ ^Lib:location[/404/] } # end of @payByCreditCard[]дальше идет класс операций
@CLASS OpenSSL ################################################ @create[hParams] $OPENSSL_SCRIPT[$hParams.sOpensslScript] $SERVER_CERT[${env:DOCUMENT_ROOT}$hParams.sServerCert] $USER_CERT[${env:DOCUMENT_ROOT}$hParams.sUserCert] $DATA_DIR[${env:DOCUMENT_ROOT}/data/temp] # end of @create[] ################################################ @sign[sData][sDataName;fResult;fSign] $sDataName[^math:uuid[]] $sSignName[^math:uuid[]] ^sData.save[$DATA_DIR/$sDataName] $fResult[^file::exec[$OPENSSL_SCRIPT dgst -sha1 -out $DATA_DIR/$sSignName -sign $USER_CERT $DATA_DIR/$sDataName]] $fSign[^file::load[binary;$DATA_DIR/$sSignName]] $result[^fSign.base64[]] ^if(-f "$DATA_DIR/$sDataName"){ ^file:delete[$DATA_DIR/$sDataName] } ^if(-f "$DATA_DIR/$sSignName"){ ^file:delete[$DATA_DIR/$sSignName] } # end of @sign[] ################################################ @signed[hParams][sDataName;sSignName;fResult;fSignature] $result(0) ^if(def $hParams.data && def $hParams.signature){ $sDataName[^math:uuid[]] $sSignName[^math:uuid[]] $fSignature[^file::base64[$hParams.signature]] ^hParams.data.save[$DATA_DIR/$sDataName] ^fSignature.save[binary;$DATA_DIR/$sSignName] $fResult[^file::exec[$OPENSSL_SCRIPT dgst -sha1 -verify $SERVER_CERT -signature $DATA_DIR/$sSignName $DATA_DIR/$sDataName]] ^if(^fResult.text.match[Verified OK]){ $result(1) } ^if(-f "$DATA_DIR/$sDataName"){ ^file:delete[$DATA_DIR/$sDataName] } ^if(-f "$DATA_DIR/$sSignName"){ ^file:delete[$DATA_DIR/$sSignName] } } # end of @signed[] ################################################ @selfSigned[hParams][sDataName;sSignName;fResult;fSignature] $result(0) $sDataName[^math:uuid[]] $sSignName[^math:uuid[]] $fSignature[^file::base64[$hParams.signature]] ^hParams.data.save[$DATA_DIR/$sDataName] ^fSignature.save[binary;$DATA_DIR/$sSignName] $fResult[^file::exec[$OPENSSL_SCRIPT dgst -sha1 -prverify $USER_CERT -signature $DATA_DIR/$sSignName $DATA_DIR/$sDataName]] ^if(^fResult.text.match[Verified OK]){ $result(1) } ^if(-f "$DATA_DIR/$sDataName"){ ^file:delete[$DATA_DIR/$sDataName] } ^if(-f "$DATA_DIR/$sSignName"){ ^file:delete[$DATA_DIR/$sSignName] } # end of @selfSigned[]для работы моей системы нужен OpenSSL последней версии, ну и пара сертификатов - свой для подписывания отправляемых данных, и второй - сертификат процессингового центра. Им мы проверяем подпись пришедших данных.