SEO Title: Day 1: Setting Up the Foundation for IRB e-Invoice Integration in Laravel #laravel #irinvoice
Focus Keyphrase: IRB e-invoice integration
Meta Description: Begin your IRB e-invoice integration tutorial for Laravel. Set up the project structure and prepare for UBL XML generation, digital signing, and secure submission.
Build a Fully Working IRB e-Invoice Integration in 10 Days
Malaysia’s Inland Revenue Board (IRB) now requires businesses to submit e-Invoices using the MyInvois platform. Over the next 10 days, you’ll build a fully working IRB e-invoice integration in Laravel — from generating UBL-compliant XML to digitally signing and submitting to IRBM.
Today’s Goal: Project Setup + Base Structure
To prepare for UBL generation and API submission, we’ll:
- 🎯 Create a clean Laravel project
- 📁 Create folder structure for IRB-related classes
- 🔐 Store IRB certificate and private key
- ⚙️ Add base config to
.env
andconfig/certs.php
Step 1: Create a New Laravel Project
composer create-project laravel/laravel irb-einvoice
cd irb-einvoice
Or use your existing Laravel app.
Step 2: Create Base Folders for IRB Integration
mkdir -p app/Services/IRB
mkdir -p storage/certs
Step 3: Add IRB Certificate and Private Key
Put your IRBM client certificate and private key here:
storage/certs/
├── irb_client_cert.pem
├── irb_client_key.pem
Tip: Use SSLShopper to convert .p12 files into .pem format.
Step 4: Create Basic Cert Config
Create config/certs.php
:
return [
'irb_client_cert' => storage_path('certs/irb_client_cert.pem'),
'irb_client_key' => storage_path('certs/irb_client_key.pem'),
'irb_client_key_passphrase' => env('IRB_CLIENT_KEY_PASSPHRASE', ''),
];
Update your .env
file:
IRB_CLIENT_KEY_PASSPHRASE=""
Step 5: Create Your First IRB Service Class
Create app/Services/IRB/IRBXmlSignatureService.php
:
namespace App\Services\IRB;
use Exception;
class IRBXmlSignatureService
{
private string $certPem;
private string $pkeyPem;
private ?string $pkeyPassphrase;
public function __construct()
{
$this->certPem = file_get_contents(config('certs.irb_client_cert'));
$this->pkeyPem = file_get_contents(config('certs.irb_client_key'));
$this->pkeyPassphrase = config('certs.irb_client_key_passphrase');
if (!$this->certPem || !$this->pkeyPem) {
throw new Exception('IRB certificate or key not found.');
}
}
// Signature method will be added later
}
Up Next: Generate UBL 2.1-Compliant Invoice XML
In Day 2: Generate UBL XML Structure for IRB, we’ll build a generator that creates IRB-compliant invoice XML using namespaces, strict node ordering, and invoice details.
Tags: #Laravel #IRBIntegration #UBL #EInvoice #IRBM