Skip to main content

Engine Constructor

import * as eWallet from 'bluetime-ewallet';

const engine = new eWallet.Engine(
  sessionToken,           // Required: from POST /EWalletOperations
  requiredAncillaryInfo,  // Optional: address collection requirements
  language                // Optional: UI language code
);
ParameterTypeDescription
sessionTokenstringSession token from your backend
requiredAncillaryInfoRequiredAncillaryInfo | undefinedBilling/shipping address requirements
languagestring | undefinedLanguage code for UI (see Localization)

payBy() Method

engine.payBy(
  eWalletList,           // Required: buttons to display
  callback,              // Required: called when payment completes
  buttonProperties,      // Optional: button styling
  requiredAncillaryInfo  // Optional: override address requirements
);
Each button is an object with name and domEntitySelector:
{ name: 'CardPay', domEntitySelector: '#card-button' }

Button Styling

Customize button appearance with ButtonProperties:
const buttonProperties = {
  color: 'Dark',      // "Light" or "Dark"
  text: 'Pay',        // "None", "Pay", "Buy", "Subscribe", "Book", "Checkout", "Donate"
  width: '200px',
  height: '40px',
  logoPath: '/path/to/logo.png'  // Optional
};

engine.payBy(buttons, handleResult, buttonProperties);

Parsing Results

Use parseResultToken() to decode the result token into structured data:
function handleResult(result) {
  if (!result) return;

  const [data, success] = engine.parseResultToken(result.token);

  if (!data.clientSuccess) {
    console.error('Payment failed:', data.clientErrorMessage);
    return;
  }

  // Check which type of result we received
  if (data.upgChargeResults) {
    // Payment processed through a PSP (card, Google Pay, Apple Pay)
    console.log('Gateway:', data.upgChargeResults.gatewayName);
    console.log('Reference:', data.upgChargeResults.gatewayReference);
    console.log('Amount:', data.upgChargeResults.amount, data.upgChargeResults.currency);
  }

  if (data.directChargeResults) {
    // Payment processed directly (PayPal, bank transfer)
    console.log('Success:', data.directChargeResults.success);
    console.log('Message:', data.directChargeResults.message);
  }

  if (data.tokenAndMaskedCardModel) {
    // Tokenization result
    console.log('Token:', data.tokenAndMaskedCardModel.token);
    console.log('Card:', data.tokenAndMaskedCardModel.bankCard.type);
    console.log('Last 4:', data.tokenAndMaskedCardModel.bankCard.number);

    if (data.tokenAndMaskedCardModel.threeDs) {
      console.log('3DS ECI:', data.tokenAndMaskedCardModel.threeDs.eci);
    }
  }
}

Result Data Structure

EWalletResultData {
  clientSuccess: boolean;
  clientErrorMessage: any;

  // For PSP charges (CardPay, GooglePay, ApplePay)
  upgChargeResults?: {
    gatewayName: string;
    gatewayReference: string;
    authorizationCode: string;
    amount: number;
    currency: string;
    operationType: string;  // "Charge", "PreAuth", etc.
    operationResultCode: string;  // "Success", "Rejected", etc.
  };

  // For direct charges (PayPal, BankPay)
  directChargeResults?: {
    success: boolean;
    message: string;
    data: object;
  };

  // For tokenization
  tokenAndMaskedCardModel?: {
    token: string;
    bankCard: {
      type: string;      // "Visa", "Mastercard", etc.
      number: string;    // Masked: "************1234"
      expirationMonth: number;
      expirationYear: number;
      nameOnCard: string;
    };
    threeDs?: {
      eci: string;
      authenticationValue: string;
      xid: string;
      version: string;
    };
  };
}

Address Collection

Request billing and/or shipping addresses from the payment method (supported by Google Pay, Apple Pay, PayPal).

Configuration

const requiredAncillaryInfo = {
  billingInfo: {
    phoneRequired: true,
    emailAddressRequired: true,
    details: 'FULL'  // "MIN" or "FULL"
  },
  shippingInfo: {
    phoneRequired: false,
    emailAddressRequired: false
  }
};

const engine = new eWallet.Engine(sessionToken, requiredAncillaryInfo);

Address Levels

LevelFields Included
"MIN"name, countryCode, postalCode, phone (if required), email (if required)
"FULL"MIN fields + addressLines, locality (city), administrativeArea (state/province)

Retrieving Addresses

After payment completes, retrieve the collected addresses:
function handleResult(result) {
  if (!result) return;

  const billing = engine.getBillingInfo();
  if (billing) {
    console.log('Name:', billing.name);
    console.log('Email:', billing.emailAddress);
    console.log('Country:', billing.countryCode);
    console.log('Postal:', billing.postalCode);

    // FULL address fields (if requested)
    if (billing.addressLines) {
      console.log('Street:', billing.addressLines.join(', '));
      console.log('City:', billing.locality);
      console.log('State:', billing.administrativeArea);
    }
  }

  const shipping = engine.getShippingInfo();
  if (shipping) {
    console.log('Ship to:', shipping.name);
    console.log('Address:', shipping.addressLines?.join(', '));
  }
}

Additional Methods

getSessionType()

Returns the operation type for this session:
const sessionType = engine.getSessionType();
// "CHARGE", "TOKENIZE", "CHARGE_AND_TOKENIZE", or "PREAUTH_AND_TOKENIZE"

getSelectedProviderName()

Returns which payment method the customer used:
function handleResult(result) {
  const provider = engine.getSelectedProviderName();
  console.log('Customer paid with:', provider);
  // "CardPay", "GooglePay", "ApplePay", "PayPal", "BankPay", or "UPI"
}

Localization

The library supports 20 languages. Pass a language code to the constructor:
const engine = new eWallet.Engine(sessionToken, undefined, 'de');

Supported Languages

CodeLanguageCodeLanguage
enEnglishnlDutch
deGermanplPolish
esSpanishptPortuguese
frFrenchruRussian
itItaliansvSwedish
heHebrewtrTurkish
csCzechzhChinese
elGreekkoKorean
fiFinnishskSlovak
noNorwegiansrSerbian

Operations

The session operation (set when creating the session) determines what the library does:
OperationDescription
CHARGEProcess payment immediately
TOKENIZEStore payment method, return token for later charges
CHARGE_AND_TOKENIZEProcess payment and return a token
PREAUTH_AND_TOKENIZEAuthorize payment and return a token for later capture
Tokenization is only available for CardPay, GooglePay, and ApplePay. PayPal and BankPay support charge only.

Payment Method Requirements

CardPay, GooglePay, ApplePay

Requires a payment processor (PSP) configured in your Orchestra account. Pass paymentGatewayAccountId when creating the session. Orchestra supports payment gateways.

PayPal

Requires PayPal merchant credentials configured in the Orchestra Portal.

ApplePay, GooglePay

In addition to PSP credentials, these require:
  • Merchant registration with Apple/Google
  • Domain verification
  • A PSP that supports 3DS connection
See Digital Wallets for setup details.