Backend Runtimes
PHP, Laravel & WordPress / WooCommerce Integration
Inject localized purchasing power parity discounts and auto-apply promo codes inside Laravel controllers, Symfony apps, or custom WordPress hooks with sub-10ms edge latency.
Laravel Service with Cache::remember
Create a dedicated pricing service that caches regional pricing lookups for 10 minutes:
<?php
// app/Services/ParityPricingService.php
namespace App\Services;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
class ParityPricingService
{
protected string $apiUrl = 'https://api.parityedge.app/v1/lookup';
protected string $projectId;
public function __construct()
{
$this->projectId = config('services.parityedge.project_id', 'prj_live_YOUR_KEY');
}
public function calculate(float $basePrice, string $clientIp): array
{
$parity = $this->resolve($clientIp);
if ($parity && !empty($parity['eligible']) && ($parity['discountPercentage'] ?? 0) > 0) {
$discountMultiplier = (100 - (int)$parity['discountPercentage']) / 100;
$finalPrice = round($basePrice * $discountMultiplier, 2);
return [
'basePrice' => $basePrice,
'finalPrice' => $finalPrice,
'parity' => $parity,
];
}
return [
'basePrice' => $basePrice,
'finalPrice' => $basePrice,
'parity' => $parity,
];
}
public function resolve(string $clientIp): ?array
{
$cacheKey = 'parity_edge:' . md5($clientIp);
return Cache::remember($cacheKey, now()->addMinutes(10), function () use ($clientIp) {
try {
$response = Http::timeout(1.0)
->withHeaders([
'x-forwarded-for' => $clientIp,
])
->get($this->apiUrl, [
'projectId' => $this->projectId,
]);
return $response->successful() ? $response->json() : null;
} catch (\Exception $e) {
Log::warning('[ParityEdge] Resolution timeout: ' . $e->getMessage());
return null;
}
});
}
}Laravel Controller Endpoint
<?php
// app/Http/Controllers/PricingController.php
namespace App\Http\Controllers;
use App\Services\ParityPricingService;
use Illuminate\Http\Request;
class PricingController extends Controller
{
public function show(Request $request, ParityPricingService $pricingService)
{
$clientIp = $request->ip() ?? '';
$pricing = $pricingService->calculate(49.00, $clientIp);
return response()->json($pricing);
}
}WordPress & WooCommerce Global Hook
Add to your child theme's functions.php to automatically enqueue the runtime script on checkout and product pages:
add_action('wp_enqueue_scripts', function() {
if (is_product() || is_cart() || is_checkout()) {
wp_enqueue_script(
'parityedge-runtime',
'https://api.parityedge.app/v1/parity.global.js',
array(),
null,
true
);
add_filter('script_loader_tag', function($tag, $handle) {
if ($handle === 'parityedge-runtime') {
return str_replace(' src', ' data-project-id="prj_live_YOUR_KEY" async src', $tag);
}
return $tag;
}, 10, 2);
}
});Production Architecture Highlights
Fail-Open Circuit Safety
Laravel Http client catches network timeouts and returns standard baseline USD rates, guaranteeing zero checkout drop-offs.
Automated ASN Threat Filtering
The ParityEdge edge engine inspects autonomous system numbers at the edge border, preventing commercial VPN discount manipulation.