1. Go to this page and download the library: Download ahmeti/sovos-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ahmeti / sovos-api example snippets
use Bulut\FITApi\FITInvoiceService;
$service = new \Bulut\FITApi\FITInvoiceService(['username'=> 'WS_KULLANICIADI', 'password'=>'WS_SIFRE'], true);
// Son parametre, TEST ortamında ise true yapabilirsiniz veya boş bırakabilirsiniz.
use \Bulut\FITApi\FITArchiveService;
$service = new \Bulut\FITApi\FITArchiveService(['username'=>'EARSIV_WS_Kullanici', 'password'=>'EARSIV_WS_Sifre'], true);
// Son parametre, TEST ortamında ise true yapabilirsiniz veya boş bırakabilirsiniz.
$getDocument = new \Bulut\ArchiveService\GetUserList();
$getDocument->setVknTckn("GONDERICI_VKN_TCKN");
$result = $service->GetUserListRequest($getDocument);
$docRefences = [];
$uuid = \Bulut\eFaturaUBL\XMLHelper::CreateGUID();
$invoice = new \Bulut\eFaturaUBL\Invoice();
$invoice->UBLVersionID = "2.1"; //uluslararası fatura standardı 2.1
$invoice->CustomizationID = "TR1.2"; //fakat GİB UBLTR olarak isimlendirdiği Türkiye'ye özgü 1.2 efatura formatını kullanıyor.
$invoice->ProfileID = "EARSIVFATURA"; //ticari ve temel olarak iki çeşittir. ticari faturalarda sistem yanıtı(application response) döner.
$invoice->ID = "FA02017000000021"; //Eğer fatura ID FIT tarafından oluşacak ise, ID alanı boş, CUST_INV_ID alanı dolu gelmelidir. Eğer kullanıcı firma tarafından oluşacak ise, ID alanı dolu CUST_INV_ID alanı boş olarak gönderilmeli.
$invoice->CopyIndicator = "false"; //kopyası mı, asıl süret mi olduğu belirlenir
$invoice->UUID = $uuid; //fatura UUID
$invoice->IssueDate = "Y-m-d"; //fatura tarihi
$invoice->IssueTime = date('H:i:s');
$invoice->InvoiceTypeCode = "SATIS"; //gönderilecek fatura çeşidi, satış, iade vs.
$invoice->DocumentCurrencyCode = "TRY"; //efatura para birimi
$invoice->LineCountNumeric = 1; //fatura kalemlerinin sayısı
#$invoice->Note = ["Test not"]; //isteğe bağlı not alanı
//Fatura ID otomatik oluşacak ise bu alanı göndermelisiniz.
$invoice_Document_Refence = new \Bulut\eFaturaUBL\DocumentReference();
$invoice_Document_Refence->ID = \Bulut\eFaturaUBL\XMLHelper::CreateGUID();
$invoice_Document_Refence->IssueDate = "Y-m-d";
$invoice_Document_Refence->DocumentTypeCode = "CUST_INV_ID";
$docRefences[] = $invoice_Document_Refence;
//OUTPUT_TYPE
$invoice_Document_Refence1 = new \Bulut\eFaturaUBL\DocumentReference();
$invoice_Document_Refence1->ID = "0100";
$invoice_Document_Refence1->IssueDate = date('Y-m-d');
$invoice_Document_Refence1->DocumentTypeCode = "OUTPUT_TYPE";
$docRefences[] = $invoice_Document_Refence1;
//EREPSENDT
$invoice_Document_Refence2 = new \Bulut\eFaturaUBL\DocumentReference();
$invoice_Document_Refence2->ID = "KAGIT";
$invoice_Document_Refence2->IssueDate = date('Y-m-d');
$invoice_Document_Refence2->DocumentTypeCode = "EREPSENDT";
$docRefences[] = $invoice_Document_Refence2;
$invoice->AdditionalDocumentReference = $docRefences;
$invoice_signature = new \Bulut\eFaturaUBL\Signature();
$invoice_signature->ID = ['val' => "ALICI_VKN_TCKN", 'attrs' => ['schemeID = "VKN_TCKN"']];
$invoice_signature_party = new \Bulut\eFaturaUBL\SignatoryParty();
$invoice__signature_party_ident = new \Bulut\eFaturaUBL\PartyIdentification();
$invoice__signature_party_ident->ID = ['val' => "ALICI_VKN_TCKN", 'attrs' => ['schemeID = "VKN"']];
$invoice_signature_party->PartyIdentification = $invoice__signature_party_ident;
$invoice__signature_party_postal = new \Bulut\eFaturaUBL\PostalAddress();
$invoice__signature_party_postal->StreetName = "deneme cad";
$invoice__signature_party_postal->BuildingName = "01";
$invoice__signature_party_postal->CitySubdivisionName = "ilce";
$invoice__signature_party_postal->CityName = "il";
$invoice__signature_party_postal->PostalZone = "34000";
$invoice__signature_party_postal_country = new \Bulut\eFaturaUBL\Country();
$invoice__signature_party_postal_country->Name = "TÜRKİYE";
$invoice__signature_party_postal->Country = $invoice__signature_party_postal_country;
$invoice_signature_party->PostalAddress = $invoice__signature_party_postal;
$invoice_signature->SignatoryParty = $invoice_signature_party;
$invoice_signature_digital = new \Bulut\eFaturaUBL\DigitalSignatureAttachment();
$invoice_signature_digital_ext = new \Bulut\eFaturaUBL\ExternalReference();
$invoice_signature_digital_ext->URI = "#Signature";
$invoice_signature_digital->ExternalReference = $invoice_signature_digital_ext;
$invoice_signature->DigitalSignatureAttachment = $invoice_signature_digital;
$invoice->Signature = $invoice_signature;
$invoice_AccountSupplierParty = new \Bulut\eFaturaUBL\AccountingSupplierParty();
$invoice_AccountSupplierParty_Party = new \Bulut\eFaturaUBL\Party();
$invoice_AccountSupplierParty_Party->WebsiteURI = "http://unlembilisim.com";
$invoice_AccountSupplierParty_Party_Identifi = new \Bulut\eFaturaUBL\PartyIdentification();
$invoice_AccountSupplierParty_Party_Identifi->ID = ['val'=> "GONDERICI_VKN_TCKN", 'attrs' => ['schemeID="TCKN"']];
$invoice_AccountSupplierParty_Party->PartyIdentification = $invoice_AccountSupplierParty_Party_Identifi;
$invoice_AccountSupplierParty_Party_Name = new \Bulut\eFaturaUBL\PartyName();
$invoice_AccountSupplierParty_Party_Name->Name = "Orhan Gazi Başlı";
$invoice_AccountSupplierParty_Party->PartyName = $invoice_AccountSupplierParty_Party_Name;
$invoice_AccountSupplierParty_Party_Person = new \Bulut\eFaturaUBL\Person();
$invoice_AccountSupplierParty_Party_Person->FirstName = "Orhan Gazi";
$invoice_AccountSupplierParty_Party_Person->FamilyName = "Başlı";
$invoice_AccountSupplierParty_Party->Person = $invoice_AccountSupplierParty_Party_Person;
$invoice_AccountSupplierParty_Party_PostalAdd = new \Bulut\eFaturaUBL\PostalAddress();
$invoice_AccountSupplierParty_Party_PostalAdd->Room = "kapi no";
$invoice_AccountSupplierParty_Party_PostalAdd->StreetName = "cadde";
$invoice_AccountSupplierParty_Party_PostalAdd->BuildingName = "bina";
$invoice_AccountSupplierParty_Party_PostalAdd->BuildingNumber = "bina no";
$invoice_AccountSupplierParty_Party_PostalAdd->CitySubdivisionName = "mahalle";
$invoice_AccountSupplierParty_Party_PostalAdd->CityName = "şehir";
$invoice_AccountSupplierParty_Party_PostalAdd->PostalZone = "posta kodu";
$invoice_AccountSupplierParty_Party_PostalAdd->Region = "asd";
$invoice_AccountSupplierParty_Party_PostalAdd_Country = new \Bulut\eFaturaUBL\Country();
$invoice_AccountSupplierParty_Party_PostalAdd_Country->Name = "Türkiye";
$invoice_AccountSupplierParty_Party_PostalAdd->Country = $invoice_AccountSupplierParty_Party_PostalAdd_Country;
$invoice_AccountSupplierParty_Party->PostalAddress = $invoice_AccountSupplierParty_Party_PostalAdd;
$invoice_AccountSupplierParty_Party_TaxSchema = new \Bulut\eFaturaUBL\PartyTaxScheme();
$invoice_AccountSupplierParty_Party_TaxSchema_Schema = new \Bulut\eFaturaUBL\TaxScheme();
$invoice_AccountSupplierParty_Party_TaxSchema_Schema->Name = "erciyes";
$invoice_AccountSupplierParty_Party_TaxSchema->TaxScheme = $invoice_AccountSupplierParty_Party_TaxSchema_Schema;
$invoice_AccountSupplierParty_Party->PartyTaxScheme = $invoice_AccountSupplierParty_Party_TaxSchema;
$invoice_AccountSupplierParty_Party_Contact = new \Bulut\eFaturaUBL\Contact();
$invoice_AccountSupplierParty_Party_Contact->Telephone = "telef";
$invoice_AccountSupplierParty_Party_Contact->Telefax = "Telefax";
$invoice_AccountSupplierParty_Party_Contact->ElectronicMail = "ElectronicMail";
$invoice_AccountSupplierParty_Party->Contact = $invoice_AccountSupplierParty_Party_Contact;
$invoice_AccountSupplierParty->Party = $invoice_AccountSupplierParty_Party;
$invoice->AccountingSupplierParty = $invoice_AccountSupplierParty;
// Customer
$invoice_AccountCustomerParty = new \Bulut\eFaturaUBL\AccountingCustomerParty();
$invoice_AccountCustomerParty_Party = new \Bulut\eFaturaUBL\Party();
$invoice_AccountCustomerParty_Party->WebsiteURI = "http://unlembilisim.com";
$invoice_AccountCustomerParty_Party_Identifi = new \Bulut\eFaturaUBL\PartyIdentification();
$invoice_AccountCustomerParty_Party_Identifi->ID = ['val'=> $aliciVkn, 'attrs' => ['schemeID="TCKN"']];
$invoice_AccountCustomerParty_Party->PartyIdentification = $invoice_AccountCustomerParty_Party_Identifi;
$invoice_AccountCustomerParty_Party_Name = new \Bulut\eFaturaUBL\PartyName();
$invoice_AccountCustomerParty_Party_Name->Name = "GIB";
$invoice_AccountCustomerParty_Party->PartyName = $invoice_AccountCustomerParty_Party_Name;
$invoice_AccountCustomerParty_Party_Person = new \Bulut\eFaturaUBL\Person();
$invoice_AccountCustomerParty_Party_Person->FirstName = "Test";
$invoice_AccountCustomerParty_Party_Person->FamilyName = "Test";
$invoice_AccountCustomerParty_Party->Person = $invoice_AccountCustomerParty_Party_Person;
$invoice_AccountCustomerParty_Party_PostalAdd = new \Bulut\eFaturaUBL\PostalAddress();
$invoice_AccountCustomerParty_Party_PostalAdd->Room = "kapi no";
$invoice_AccountCustomerParty_Party_PostalAdd->StreetName = "cadde";
$invoice_AccountCustomerParty_Party_PostalAdd->BuildingName = "bina";
$invoice_AccountCustomerParty_Party_PostalAdd->BuildingNumber = "bina no";
$invoice_AccountCustomerParty_Party_PostalAdd->CitySubdivisionName = "mahalle";
$invoice_AccountCustomerParty_Party_PostalAdd->CityName = "şehir";
$invoice_AccountCustomerParty_Party_PostalAdd->PostalZone = "posta kodu";
$invoice_AccountCustomerParty_Party_PostalAdd->Region = "asd";
$invoice_AccountCustomerParty_Party_PostalAdd_Country = new \Bulut\eFaturaUBL\Country();
$invoice_AccountCustomerParty_Party_PostalAdd_Country->Name = "Türkiye";
$invoice_AccountCustomerParty_Party_PostalAdd->Country = $invoice_AccountCustomerParty_Party_PostalAdd_Country;
$invoice_AccountCustomerParty_Party->PostalAddress = $invoice_AccountCustomerParty_Party_PostalAdd;
$invoice_AccountCustomerParty_Party_TaxSchema = new \Bulut\eFaturaUBL\PartyTaxScheme();
$invoice_AccountCustomerParty_Party_TaxSchema_Schema = new \Bulut\eFaturaUBL\TaxScheme();
$invoice_AccountCustomerParty_Party_TaxSchema_Schema->Name = "erciyes";
$invoice_AccountCustomerParty_Party_TaxSchema->TaxScheme = $invoice_AccountCustomerParty_Party_TaxSchema_Schema;
$invoice_AccountCustomerParty_Party->PartyTaxScheme = $invoice_AccountCustomerParty_Party_TaxSchema;
$invoice_AccountCustomerParty_Party_Contact = new \Bulut\eFaturaUBL\Contact();
$invoice_AccountCustomerParty_Party_Contact->Telephone = "telef";
$invoice_AccountCustomerParty_Party_Contact->Telefax = "Telefax";
$invoice_AccountCustomerParty_Party_Contact->ElectronicMail = "ElectronicMail";
$invoice_AccountCustomerParty_Party->Contact = $invoice_AccountCustomerParty_Party_Contact;
$invoice_AccountCustomerParty->Party = $invoice_AccountCustomerParty_Party;
$invoice->AccountingCustomerParty= $invoice_AccountCustomerParty;
$invoice_TaxTotal = new \Bulut\eFaturaUBL\TaxTotal();
$invoice_TaxTotal->TaxAmount = ["val" => "0.01", 'attrs' => ['currencyID="TRY"']];
$invoice_TaxTotal_SubTotal = new \Bulut\eFaturaUBL\TaxSubtotal();
$invoice_TaxTotal_SubTotal->TaxableAmount = ["val" => "0.99", 'attrs' => ['currencyID="TRY"']];
$invoice_TaxTotal_SubTotal->TaxAmount = ["val" => "0.01", 'attrs' => ['currencyID="TRY"']];
$invoice_TaxTotal_SubTotal_Category = new \Bulut\eFaturaUBL\TaxCategory();
$invoice_TaxTotal_SubTotal_Category_Schema = new \Bulut\eFaturaUBL\TaxScheme();
$invoice_TaxTotal_SubTotal_Category_Schema->Name = "KDV";
$invoice_TaxTotal_SubTotal_Category_Schema->TaxTypeCode = "0015";
$invoice_TaxTotal_SubTotal_Category->TaxScheme = $invoice_TaxTotal_SubTotal_Category_Schema;
$invoice_TaxTotal_SubTotal->TaxCategory = $invoice_TaxTotal_SubTotal_Category;
$invoice_TaxTotal->TaxSubtotal = $invoice_TaxTotal_SubTotal;
$invoice->TaxTotal = $invoice_TaxTotal;
$invoice_LegalMonetary = new \Bulut\eFaturaUBL\LegalMonetaryTotal();
$invoice_LegalMonetary->LineExtensionAmount = ["val" => "1", 'attrs' => ['currencyID="TRY"']];
$invoice_LegalMonetary->TaxExclusiveAmount = ["val" => "0.99", 'attrs' => ['currencyID="TRY"']];
$invoice_LegalMonetary->TaxInclusiveAmount = ["val" => "1", 'attrs' => ['currencyID="TRY"']];
$invoice_LegalMonetary->PayableAmount = ["val" => "1", 'attrs' => ['currencyID="TRY"']];
$invoice->LegalMonetaryTotal = $invoice_LegalMonetary;
$invoice_line = new \Bulut\eFaturaUBL\InvoiceLine();
$invoice_line->ID = "1";
$invoice_line->InvoicedQuantity = ["val" => "1", 'attrs' => ['unitCode="CMT"']];
$invoice_line->LineExtensionAmount = ["val" => "0.99", 'attrs' => ['currencyID="TRY"']];
$invoice_line_item = new \Bulut\eFaturaUBL\Item();
$invoice_line_item->Name = "Test Ürün";
$invoice_line->Item = $invoice_line_item;
$invoice_line_price = new \Bulut\eFaturaUBL\Price();
$invoice_line_price->PriceAmount = ["val" => "1", 'attrs' => ['currencyID="TRY"']];
$invoice_line->Price = $invoice_line_price;
$invoice->InvoiceLine = [$invoice_line];
$xml = new \Bulut\eFaturaUBL\XMLHelper($invoice);