Skip to content

Configure a loyalty client

Use the following code to create a client for your Loyalty Program:

import { createLoyaltyProgramClient } from '@fanpoints/server-js';
const client = createLoyaltyProgramClient({
loyaltyProgramId: 'the Loyalty Program id', // can be found in the dashboard
clientId: 'the client id',
secret: 'the client secret',
});

You can generate the clientId and secret in the Fanpoints dashboard.

Testing your configuration

You can test your configuration by using the ping function:

client.ping().then(() => {
console.log('The client is working!');
});

Configuring Marketing Partners and Loyalty Programs

You can also configure the client to interact with both Loyalty Programs and partners:

import { createClient } from '@fanpoints/server-js';
const client = createClient({
loyaltyProgramConfig: {
loyaltyProgramId: 'the Loyalty Program id',
clientId: 'the client id',
secret: 'the client secret',
},
otherPartnerConfigs: [
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret'
partnerLabels: ['tickets', 'gift_cards'],
defaultCurrency: 'chf'
},
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret'
partnerLabels: ['merchandise', 'sports_equipment'],
defaultCurrency: 'chf'
},
],
});