Collecting Payments

Learn how to build scalable Payments applications using the Elarian customer engagement framework.

Collecting payments from a customer to your business

Elarian wallets allow you to model various payment interactions, here are some supported variations while collecting payments on mobile platforms.

  1. From mobile money platform to wallet on Elarian
  2. From mobile money platform to purse on Elarian
  3. From wallet on Elarian to purse on Elarian

From mobile money platform to wallet on Elarian

const customer = new client.Customer({
    number: 'YOUR-CUSTOMERS-PHONE-NUMBER',
    provider: 'cellular'
});

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

const resp = await client.initiatePayment(
  {
    customerNumber: customer.customerNumber,
    channelNumber: {
      number: 'YOUR-MOBILE-MONEY-PLATFORM-BUSINESS-NUMBER',
      channel: 'cellular',
    },
  },
  {
    customerId,
    walletId: 'CUSTOMER-WALLET-ID',
  },
  {
    amount: 1000,
    currencyCode: 'KES',
  },
);

console.log(resp);

From mobile money platform to purse on Elarian

...

const resp = await client.initiatePayment(
  {
    customerNumber: customer.customerNumber,
    channelNumber: {
      number: 'YOUR-MOBILE-MONEY-PLATFORM-BUSINESS-NUMBER',
      channel: 'cellular',
    },
  },
  {
    purseId: 'BUSINESS-PURSE-ID',
  },
  {
    amount: 1000,
    currencyCode: 'KES',
  },
);

console.log(resp);

From wallet on Elarian to purse on Elarian

...

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

console.log(resp);