A technical guide to integrating any existing loyalty or points system with Resonance network rewards.
If your system can send a webhook, it can integrate with Resonance.
This guide covers the patterns for connecting any existing points system to network rewards.
The Integration Pattern
The core pattern is simple:
1
Your system triggers an event
→
2
Webhook sends data to Resonance
→
3
Resonance awards RSNC
→
✓
Customer redeems across network
core-pattern.js
Universal
// Generic webhook pattern
async function forwardToResonance(event) {
await fetch('https://api.rsnc.network/resonance-api/manual-event', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.RESONANCE_API_KEY}`
},
body: JSON.stringify({
brandId: process.env.RESONANCE_BRAND_ID,
eventType: event.type,
userEmail: event.customerEmail,
metadata: event.data
})
});
}
Common Event Types
Purchase Events
forwardToResonance({
type: 'purchase',
customerEmail: order.customer.email,
data: {
order_id: order.id,
order_value: order.total,
currency: order.currency,
items: order.line_items.length
}
});
Signup Events
forwardToResonance({
type: 'signup',
customerEmail: user.email,
data: {
signup_source: 'website',
referral_code: user.referral_code
|| null
}
});
Referral Events
forwardToResonance({
type: 'referral_complete',
customerEmail: referrer.email,
data: {
referred_email: referred.email,
referral_code: referral.code
}
});
Custom Events
forwardToResonance({
type: 'custom_action',
customerEmail: user.email,
data: {
action: 'wrote_review',
product_id: product.id,
rating: 5
}
});
Platform-Specific Examples
shopify-webhook.js
Shopify
// Shopify order webhook handler
app.post('/webhooks/shopify/orders-paid', async (req, res) => {
const order = req.body;
await forwardToResonance({
type: 'purchase',
customerEmail: order.customer.email,
data: {
order_id: order.id,
order_value: parseFloat(order.total_price),
currency: order.currency
}
});
res.status(200).send('OK');
});
stripe-webhook.js
Stripe
// Stripe payment webhook handler
app.post('/webhooks/stripe', async (req, res) => {
const event = req.body;
if (event.type === 'payment_intent.succeeded') {
const payment = event.data.object;
await forwardToResonance({
type: 'purchase',
customerEmail: payment.receipt_email,
data: {
payment_id: payment.id,
amount: payment.amount / 100, // Convert from cents
currency: payment.currency
}
});
}
res.status(200).send('OK');
});
db-sync.js
Custom CRM/Database
// Database trigger or cron job approach
async function syncRecentPurchases() {
const recentOrders = await db.query(`
SELECT * FROM orders
WHERE created_at > NOW() - INTERVAL '5 minutes'
AND synced_to_resonance = false
`);
for (const order of recentOrders) {
await forwardToResonance({
type: 'purchase',
customerEmail: order.customer_email,
data: {
order_id: order.id,
order_value: order.total
}
});
await db.query(
'UPDATE orders SET synced_to_resonance = true WHERE id = $1',
[order.id]
);
}
}
Error Handling
retry-handler.js
Production-Ready
async function forwardToResonanceWithRetry(event, maxRetries = 3) {
for (let attempt = 1; attempt <= maxRetries; attempt++) {
try {
const response = await fetch(
'https://api.rsnc.network/resonance-api/manual-event',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.RESONANCE_API_KEY}`
},
body: JSON.stringify({
brandId: process.env.RESONANCE_BRAND_ID,
eventType: event.type,
userEmail: event.customerEmail,
metadata: event.data
})
}
);
if (response.ok) {
return { success: true };
}
if (response.status >= 500) {
// Server error, retry
await sleep(1000 * attempt);
continue;
}
// Client error, don't retry
return { success: false, error: await response.text() };
} catch (error) {
if (attempt === maxRetries) {
return { success: false, error: error.message };
}
await sleep(1000 * attempt);
}
}
}
Best Practice: Always implement retry logic with exponential backoff. Store failed events in a dead-letter queue for manual review.
Testing Your Integration
- Use the Resonance sandbox environment first
- Trigger test events from your system
- Verify events appear in the Partner Portal
- Check RSNC balances for test customers
- Switch to production when ready
If you can send a webhook, you can integrate with Resonance.
The patterns are simple. The network effects are not.
Connect your system. Join the network.
See Also