This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$UriId = uniqid(); | |
$ns = 'tns'; | |
$writer = new XMLWriter(); | |
$writer->openMemory(); | |
//$writer->startDocument('1.0', 'UTF-8'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function UUIDv4() { | |
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | |
mt_rand(0, 0xffff), mt_rand(0, 0xffff), | |
mt_rand(0, 0xffff), | |
mt_rand(0, 0x0fff) | 0x4000, | |
mt_rand(0, 0x3fff) | 0x8000, | |
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$oib = '11111111111'; | |
$dt = new DateTime('now'); | |
$datumVrijemeIzdavanjaRacuna = $dt->format('d.m.Y H:i:s'); /* use invoice created_at datetime here */ | |
$brojcanaOznakaRacuna = '23'; /* 23/MAGE5/1 */ | |
$oznakaPoslovnogProstora = 'MAGE5'; /* 23/MAGE5/1 */ | |
$oznakaNaplatnogUredaja = '1'; /* 23/MAGE5/1 */ | |
$ukupniIznosRacuna = '182.50'; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$certificateCAcer = '/path/to/cert/democacert.cer'; | |
$certificateCAcerContent = file_get_contents($certificateCAcer); | |
/* Convert .cer to .pem, cURL uses .pem */ | |
$certificateCApemContent = '-----BEGIN CERTIFICATE-----'.PHP_EOL | |
.chunk_split(base64_encode($certificateCAcerContent), 64, PHP_EOL) | |
.'-----END CERTIFICATE-----'.PHP_EOL; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$certificate = null; | |
$certificatePass = 'MyCertPassHere'; | |
$pfxCertificate = '/path/to/cert/fiskal-demo-aplikativni.pfx'; | |
openssl_pkcs12_read(file_get_contents($pfxCertificate), $certificate, $certificatePass); | |
$publicCertificate = $certificate['cert']; | |
$privateKey = $certificate['pkey']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Branko Ajzele <ajzele@gmail.com, http://foggyline.net> | |
*/ | |
$XMLRequestType = 'RacunZahtjev'; /* RacunZahtjev OR PoslovniProstorZahtjev */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Function taken from Magento eCommerce platform from /app/code/core/Mage/Core/Helper/Data.php file. | |
* | |
* @param $len | |
* @param null $chars | |
* @return string | |
*/ | |
function getRandomString($len, $chars = null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$certificateCAcer = '/certificate.cer'; | |
$certificateCAcerContent = file_get_contents($certificateCAcer); | |
/* Convert .cer to .pem, cURL uses .pem */ | |
$certificateCApemContent = '-----BEGIN CERTIFICATE-----'.PHP_EOL | |
.chunk_split(base64_encode($certificateCAcerContent), 64, PHP_EOL) | |
.'-----END CERTIFICATE-----'.PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
/** | |
* Loto (random) number generator. | |
* | |
* Script accepts 3 params. | |
* First two are to determine the type of loto, for example 7 of 39, or 6 of 45. | |
* Third parameter is the number of combinations. | |
* | |
* By default it 7 of 39 and one combination. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function digitallySignXml($XMLContent, $ReferenceNodeName, $store) | |
{ | |
$cert = Mage::getModel('inchoo_fiskalizacija/cert'); | |
//$cert->load(Mage::app()->getWebsite()->getId(), 'website_id'); | |
$cert->load(Mage::getModel('core/store')->load($store)->getWebsiteId(), 'website_id'); | |
$doc = new DOMDocument(); | |
$doc->loadXML($XMLContent); |