TOTAL REQUESTS
0
TAXPAYERS IN DATABASE
0
TIER 3 API CONSUMPTION
0
IMPORT STATUS
IDLE
Current Phase: STANDBY (IDLE)
Elapsed Duration: 0s
0% Completed
0 records processed
Lines Read
0
Valid Records
0
Corrupted Lines
0
Read Interruption
0 ms (Shadow Swap)
| ID | Started At | Type | Valid Records | New | Updated | Duration | File Size | Status |
|---|
1. Microservice REST Endpoint
Any external WordPress instance can query taxpayers via a lightweight HTTP POST or GET request:
POST http://<MICROSERVICE_IP>:3000/api/ruc
Content-Type: application/json
{"ruc": "20131312955"}
2. PHP Integration Snippet for functions.php
Add this helper to your WordPress theme with 30-day Transient caching to minimize network overhead:
function lookup_sunat_ruc( $ruc ) {
$ruc = trim( $ruc );
if ( ! preg_match( '/^[0-9]{11}$/', $ruc ) ) {
return new WP_Error( 'invalid_ruc', 'RUC must contain exactly 11 digits.' );
}
$cache_key = 'sunat_ruc_' . $ruc;
$cached = get_transient( $cache_key );
if ( false !== $cached ) return $cached;
$url = 'http://127.0.0.1:3000/api/ruc/' . $ruc;
$res = wp_remote_get( $url, [ 'timeout' => 5 ] );
if ( is_wp_error( $res ) ) return $res;
$data = json_decode( wp_remote_retrieve_body( $res ), true );
if ( ! empty( $data['success'] ) && ! empty( $data['data'] ) ) {
set_transient( $cache_key, $data['data'], 30 * DAY_IN_SECONDS );
return $data['data'];
}
return new WP_Error( 'not_found', $data['message'] ?? 'Taxpayer not found.' );
}
3. Docker Compose Production Deployment
Deploy and maintain the microservice on any VPS with a single command:
docker compose up -d