SEO Title: Day 8: Submit Signed XML to IRBM API in Laravel #irbapi #einvoicepost
Focus Keyphrase: IRB e-invoice integration
Meta Description: Learn how to submit your signed UBL XML to the IRBM MyInvois API using Laravel. Post the base64-encoded invoice with headers and bearer token.
Sending Your Signed Invoice to IRBM
Today we connect your Laravel app to the IRBM MyInvois API. You’ll submit your base64-encoded XML with the correct token, headers, and endpoint.
Step 1: Get Your Access Token
Make a POST request to IRBM’s OAuth endpoint:
$response = Http::asForm()->post('https://preprod-api.myinvois.hasil.gov.my/api/v1.0/token', [
'grant_type' => 'client_credentials',
'client_id' => env('IRB_CLIENT_ID'),
'client_secret' => env('IRB_CLIENT_SECRET'),
]);
$accessToken = $response->json()['access_token'];
Add credentials to your .env
file:
IRB_CLIENT_ID=your_dummy_id
IRB_CLIENT_SECRET=your_dummy_secret
Step 2: Encode and Prepare the Invoice
$signedXml = app(IRBXmlSignatureService::class)->sign($unsignedXml);
$encodedXml = base64_encode($signedXml);
Step 3: Post to the IRBM API
$response = Http::withToken($accessToken)->post('https://preprod-api.myinvois.hasil.gov.my/api/v1.0/invoices', [
'invoice' => $encodedXml,
]);
if ($response->successful()) {
return $response->json();
}
throw new \Exception('Failed to submit invoice: ' . $response->body());
Step 4: Handling the Response
The response will include:
- ✅
uuid
- 🕘
submissionDateTime
- 📦
invoiceStatus
- 🔗 Optional:
invoiceLink
or QR code data
Debug Tip
If your response fails, check:
- ✔️ Signature placement inside
ext:UBLExtensions
- ✔️ Correct token and base64 format
- ✔️ That no raw XML is submitted (always base64-encoded)
Coming Up in Day 9
We’ll build a proper invoice submission service class, handle retries, and log failures for traceability — ready for real-world production handling.
Tags: #IRBIntegration #LaravelHttp #MyInvoisAPI #EInvoice #UBLSubmit