Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dokumentazioa #12

Closed
asierblaz opened this issue Sep 29, 2022 · 5 comments
Closed

Dokumentazioa #12

asierblaz opened this issue Sep 29, 2022 · 5 comments

Comments

@asierblaz
Copy link

Kaixo dokumentazioa igoko duzue? edo adibideren bat, fakturak egiteko?

Eskerrikasko

@arraintxo
Copy link
Member

Ziur adibide pare bat jarriko ditugula honetarako denbora apur bat ateratzen dugunean, bitartean test-en artean dagoen TicketBaiMother klasean fakturak zelan sortu ikusi dezakezu: https://github.com/Barnetik/tbai-php-lib/blob/main/tests/Barnetik/Tbai/Mother/TicketBaiMother.php

Hauek sinatu eta bidaltzeko egin beharrekoak ere edozein "Endpoint"eko testetan ikusi dezakezu:

@asierblaz
Copy link
Author

bale ba, eskerrikasko!

@ortegafernando
Copy link

ortegafernando commented Jan 31, 2024

Kaixo, norbaitek eman al dezake bere "hello world"? Eskerrik asko

@arraintxo
Copy link
Member

arraintxo commented Apr 23, 2024

Egun on @ortegafernando

Hemen helloworld sinple bat. "tbai-sample.json" fitxategia testen direktoriopean topatu dezakezu.
El fichero "tbai-sample.json" lo puede encontrar bajo el directorio de tests de la librería.

use Barnetik\Tbai\Api\Gipuzkoa\Endpoint as GipuzkoaEndpoint;
use Barnetik\Tbai\Fingerprint\Vendor;
use Barnetik\Tbai\PrivateKey;
use Barnetik\Tbai\TicketBai;

$license = 'DEV_LICENSE';
$developerCif = 'CIF';
$appName = 'APP NAME';
$version = '1.0';

$certificatePath = '/path/to/certificate.p12';
$certificatePassword = 'myCertificatePassword';
$signedXml = './signed.xml';

$ticketbai = TicketBai::createFromJson(
    new Vendor($license, $developerCif, $appName, $version),
    json_decode(file_get_contents('tbai-sample.json'), true)
);

$ticketbai->sign(
    PrivateKey::p12($certificatePath),
    $certificatePassword,
    $signedXml
);

// new GipuzkoaEnpoint() for production server
$gipuzkoaEndpoint = new GipuzkoaEndpoint(true, true);
$result = $gipuzkoaEndpoint->submitInvoice(
    $ticketbai,
    PrivateKey::p12($certificatePath),
    $certificatePassword,
);

if ($result->isDelivered()) {
    var_dump('SUCCESS!');
} else {
    var_dump($result->errorDataRegistry());
}

@arraintxo
Copy link
Member

README-an bertan gehitu dugu liburutegia erabiltzeko behar den informazio apurra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants