Customer Wallets

Learn how customer wallets help you build scalable customer engagement applications on the Elarian Framework.

Customer wallets help you easily organize payments on Elarian.

Create customer wallet

To create a new wallet, simply initiate a payment to a customer and specify a walletId to put the funds in. This walletid will be initialized on Elarian if it doesn't exist.

const customer = new client.Customer({...});

const { customerId } = await customer.getState();

const resp = await client.initiatePayment(
  {
    purseId: 'BUSINESS-PURSE-ID'
  },
  {
    customerId,
    walletId: 'test-app-wallet'
  },
  {
    amount: 1000,
    currencyCode: 'KES'
  }
);

Get customer wallet balance

...

const { paymentState } = await customer.getState();

const walletId = 'test-app-wallet';
const testAppWallet = paymentState.wallets[walletId];

/*
{
  currencyCode: '...',
  available: {
    currencycode: '...',
    amount: ...
  },
  actual: {
    currencycode: '...',
    amount: ...
  },
  ...
}
*/
console.log(testAppWallet);