1. Go to this page and download the library: Download billie/api-php-sdk 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/ */
/** @var \Billie\Sdk\HttpClient\BillieClient $billieClient */
$requestService = new \Billie\Sdk\Service\Request\CheckoutSession\CreateSessionRequest($billieClient);
$requestModel = new \Billie\Sdk\Model\Request\CheckoutSession\CreateSessionRequestModel();
$requestModel->setMerchantCustomerId('THE-NUMBER-OR-ID-OF-THE-CUSTOMER');
/** @var \Billie\Sdk\Model\Response\CreateSessionResponseModel $responseModel */
$responseModel = $requestService->execute($requestModel);
$checkoutSessionId = $responseModel->getCheckoutSessionId(); // use this session ID and submit it to the widget.
/** @var \Billie\Sdk\HttpClient\BillieClient $billieClient */
$requestService = new \Billie\Sdk\Service\Request\CheckoutSession\CheckoutSessionConfirmRequest($billieClient);
$requestModel = new \Billie\Sdk\Model\Request\CheckoutSession\CheckoutSessionConfirmRequestModel();
$requestModel
->setSessionUuid('CHECKOUT-SESSION-ID')
->setCompany(new \Billie\Sdk\Model\Request\CheckoutSession\Confirm\Debtor())
->setAmount(new \Billie\Sdk\Model\Amount())
->setDuration(14)
->setDeliveryAddress(new \Billie\Sdk\Model\Address());
/** @var \Billie\Sdk\Model\Order $responseModel */
$responseModel = $requestService->execute($requestModel); // this is the finally created order
/** @var \Billie\Sdk\HttpClient\BillieClient $billieClient */
$requestService = new \Billie\Sdk\Service\Request\Invoice\CreateInvoiceRequest($billieClient);
$requestModel = new \Billie\Sdk\Model\Request\Invoice\CreateInvoiceRequestModel();
$requestModel
->setOrders(['REFERENCE-ID']) // use this method to set Billie reference-id or merchants order-number
->setOrderUuId('REFERENCE-UD') // use this method to set Billie reference-id
->setOrderExternalCode('MERCHANT_ORDER_ID') // use this method to set merchants order-number
// to keep your code clean, only use one of the above methods
->setInvoiceNumber('merchant-invoice-number')
->setInvoiceUrl('https://public-url.com/to/to/merchant-invoice.pdf')
->setAmount(
(new Amount())
->setGross(100)
->setTaxRate(19.00)
)
// optional parameters:
->setLineItems([
new \Billie\Sdk\Model\Request\Invoice\LineItem('merchant-product-id-2', 1),
new \Billie\Sdk\Model\Request\Invoice\LineItem('merchant-product-id-1', 2)
])
->setShippingInformation(new \Billie\Sdk\Model\ShippingInformation())
/** @var \Billie\Sdk\Model\Response\CreateInvoiceResponseModel $responseModel */
$responseModel = $requestService->execute($requestModel);
$uuid = $responseModel->getUuid(); // uuid of the invoice
/** @var \Billie\Sdk\HttpClient\BillieClient $billieClient */
$requestService = new \Billie\Sdk\Service\Request\Invoice\UpdateInvoiceRequest($billieClient);
$requestModel = new \Billie\Sdk\Model\Request\Invoice\UpdateInvoiceRequestModel('INVOICE-REFERENCE-UUID');
$requestModel
->setInvoiceNumber('merchant-invoice-number')
->setInvoiceUrl('https://public-url.com/to/to/merchant-invoice.pdf');
if ($requestService->execute($requestModel)) {
// invoice has been updated
}
/** @var \Billie\Sdk\HttpClient\BillieClient $billieClient */
$requestService = new \Billie\Sdk\Service\Request\Invoice\CancelInvoiceRequest($billieClient);
$requestModel = new \Billie\Sdk\Model\Request\InvoiceRequestModel('INVOICE-REFERENCE-UUID');
if ($requestService->execute($requestModel)) {
// invoice has been deleted/canceled
}
/** @var \Billie\Sdk\HttpClient\BillieClient $billieClient */
$requestService = new \Billie\Sdk\Service\Request\Invoice\CreateCreditNoteRequest($billieClient);
$requestModel = new \Billie\Sdk\Model\Request\Invoice\CreateCreditNoteRequestModel('INVOICE-UUID', 'MERCHANT/EXTERNAL_CREDIT_NOTE_NUMBER');
$requestModel
->setAmount(
(new Amount())
->setGross(100)
->setTaxRate(19.00)
)
// optional parameters:
->setLineItems([
new \Billie\Sdk\Model\Request\Invoice\LineItem('merchant-product-id-2', 1),
new \Billie\Sdk\Model\Request\Invoice\LineItem('merchant-product-id-1', 2)
])
->setComment('custom comment for refund')
/** @var \Billie\Sdk\Model\Response\CreateInvoiceResponseModel $responseModel */
$responseModel = $requestService->execute($requestModel);
$uuid = $responseModel->getUuid(); // uuid of the invoice
$logFile = '/path/to/your/logfile.log';
$logger = new \Monolog\Logger('name-for-the-logger');
// handler for errors
$handlerDebug = new \Monolog\Handler\StreamHandler('/path/to/your/log-file.debug.log', LogLevel::DEBUG);
$logger->pushHandler($handlerDebug);
// handler for debug-information
$handlerError = new \Monolog\Handler\StreamHandler('/path/to/your/log-file.error.log', LogLevel::ERROR);
$logger->pushHandler($handlerError);
\Billie\Sdk\Util\Logging::setPsr3Logger($logger);
// call this if you want to log the request-headers too
\Billie\Sdk\Util\Logging::setLogHeaders(true);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.