For Engineers

API Deep Dive: Advanced Pricing

Client-side vs server-side architectures, webhook integration, caching strategies, rate limit optimization, and code examples.

Architecture Patterns: Client vs Server

Client-Side (Recommended for most)

PriceParity script loads on checkout, geolocalizes visitor IP, applies Paddle coupon in real-time. Zero backend work.

<script>
window.PriceParity = {
  apiKey: 'pp_live_...',
  productId: '12345'
}
</script>
<script src="https://cdn.priceparity.net/v1/engine.js"></script>

Pros: Simple, no backend changes. Cons: Coupon created client-side (less secure for sensitive use cases).

Server-Side (For B2B/high-security)

Your backend calls PriceParity API, calculates regional price, creates coupon via Paddle API directly. More control, more complexity.

// Node.js example
const priceparity = require('@priceparity/sdk')

const result = await priceparity.evaluate({
  apiKey: process.env.PP_API_KEY,
  productId: '12345',
  customerIp: req.ip
})

// result.couponCode is generated
// Use result.couponCode in Paddle checkout

Pros: Full control, audit trail, B2B-safe. Cons: More backend code, additional latency.

Webhook Integration: Tracking Coupon Usage

Listen to Paddle webhooks to track PPP pricing adoption and revenue lift:

Paddle webhook events to listen for:

  • checkout.completed - Customer purchased with PPP coupon
  • subscription.created - Recurring PPP customer
  • subscription.updated - Pricing change (detect downgrades)

Webhook signature verification: Always verify x-paddle-signature using your webhook secret to prevent spoofing.

Caching Strategies: Reducing API Calls

Geo IP Cache (5 min)

Cache IP → country mapping. Most visitors have same IP for days.

Redis key: geo:192.0.2.1 → US

Pricing Tier Cache (24h)

Cache region → tier → coupon mapping. Invalidate only on pricing rule change.

Redis key: pricing:tenant:region:tier → coupon_code

Coupon Code Cache (48h)

Cache coupon validity after creation. Reduces Paddle API calls.

Redis key: coupon:code → valid_until

Fraud Detection Cache (1h)

Cache VPN detection results to avoid repeat checks on same IP.

Redis key: vpn:192.0.2.1 → true/false

Rate Limit Optimization

PriceParity API limits

  • • 200 req/min per API key
  • • 60 req/min per IP address
  • • Trial plan: 200 evaluations/30 days total
  • • Pro plan: Unlimited evaluations

Strategies to stay within limits:

  • Batch IP blocks: Group multiple IPs in single API call if possible
  • Aggressive caching: Cache geo/pricing results 24h+ to reduce calls
  • Client-side SDK: Use browser SDK to parallelize geo lookup (doesn't count against rate limit)
  • Upgrade to Pro: If you hit 200 req/min limit, Pro plan scales linearly with load

Error Handling & Failover

504

Timeout (API slow)

Skip coupon, charge full price. User pays USD equivalent. Log for monitoring.

429

Rate limited

Queue request for retry. Fallback to cached pricing if available.

401

Invalid API key

Skip coupon, charge full price. Page error (fix immediately).

404

Country not in pricing rules

No coupon, charge full price. Expected (not all countries get discount).

A/B Testing Regional Pricing

Run a 50/50 test: control group sees full price, test group sees PPP pricing. Measure conversion lift.

// Randomize bucket
const bucket = Math.random() < 0.5 ? 'control' : 'ppp'

if (bucket === 'ppp') {
  // Load PriceParity
  showPPPPricing()
} else {
  // Show regular pricing
  showFullPrice()
}

// Track conversion by bucket
mixpanel.track('conversion', {bucket})

Typical results: +30-70% conversion lift in PPP-pricing segment, depending on traffic mix.

Multi-Product Setup

For multiple products/prices, initialize one PriceParity instance per product:

<script>
window.PP_Starter = { productId: '100' }
window.PP_Pro = { productId: '200' }
window.PP_Enterprise = { productId: '300' }
</script>
<script>
// Each tier pricing handled independently
// Geo + pricing rules cached per product
</script>

Ready to integrate?

See full API documentation and code samples in our developer hub.

View API Docs