PHP code example of formance / formance-sdk
1. Go to this page and download the library: Download formance/formance-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/ */
formance / formance-sdk example snippets
declare(strict_types=1);
formance\stack\Models\Shared;
$sdk = stack\SDK::builder()
->setSecurity(
new Shared\Security(
clientID: '<YOUR_CLIENT_ID_HERE>',
clientSecret: '<YOUR_CLIENT_SECRET_HERE>',
)
)
->build();
$response = $sdk->getVersions(
);
if ($response->getVersionsResponse !== null) {
// handle response
}
declare(strict_types=1);
formance\stack\Models\Shared;
$sdk = stack\SDK::builder()
->setSecurity(
new Shared\Security(
clientID: '<YOUR_CLIENT_ID_HERE>',
clientSecret: '<YOUR_CLIENT_SECRET_HERE>',
)
)
->build();
$response = $sdk->getVersions(
);
if ($response->getVersionsResponse !== null) {
// handle response
}
declare(strict_types=1);
r;
use formance\stack;
use formance\stack\Models\Errors;
use formance\stack\Models\Operations;
use formance\stack\Models\Shared;
$sdk = stack\SDK::builder()
->setSecurity(
new Shared\Security(
clientID: '<YOUR_CLIENT_ID_HERE>',
clientSecret: '<YOUR_CLIENT_SECRET_HERE>',
)
)
->build();
try {
$request = new Operations\V2AddMetadataOnTransactionRequest(
requestBody: [
'admin' => 'true',
],
dryRun: true,
id: BigInteger::of('1234'),
ledger: 'ledger001',
);
$response = $sdk->ledger->v2->addMetadataOnTransaction(
request: $request
);
if ($response->statusCode === 200) {
// handle response
}
} catch (Errors\V2ErrorResponseThrowable $e) {
// handle $e->$container data
throw $e;
} catch (Errors\SDKException $e) {
// handle default exception
throw $e;
}
declare(strict_types=1);
formance\stack\Models\Shared;
$sdk = stack\SDK::builder()
->setServerIndex(1)
->setEnvironment('us-east-1')
->setOrganization('<value>')
->setSecurity(
new Shared\Security(
clientID: '<YOUR_CLIENT_ID_HERE>',
clientSecret: '<YOUR_CLIENT_SECRET_HERE>',
)
)
->build();
$response = $sdk->getVersions(
);
if ($response->getVersionsResponse !== null) {
// handle response
}
declare(strict_types=1);
formance\stack\Models\Shared;
$sdk = stack\SDK::builder()
->setServerURL('https://orgID-stackID.eu.sandbox.formance.cloud')
->setSecurity(
new Shared\Security(
clientID: '<YOUR_CLIENT_ID_HERE>',
clientSecret: '<YOUR_CLIENT_SECRET_HERE>',
)
)
->build();
$response = $sdk->getVersions(
);
if ($response->getVersionsResponse !== null) {
// handle response
}