Get available methods

Using your account Public API Key on MoneyHash class instance you will be able to have the functionality of the following method

Get Account Methods

To access the available pay-in methods, saved cards, and customer balances, call the getMethods with the following search criteria

NameType
currencystring - required
amountstring | number - optional
customerstring - optional
flow_idstring - optional
moneyHash
  .getMethods({
    currency: "<currency>",
    amount: "<amount>",
    customer: "<customer_id>",
    flowId: "<flow_id">
  })
  .then(({ paymentMethods, expressMethods, savedCards, customerBalances }) => {
    console.log({
      paymentMethods,
      expressMethods,
      savedCards,
      customerBalances,
    });
  });

Get Intent Methods

To access the available pay-in/pay-out methods, saved cards, and customer balances, call the getIntentMethods sending the intent_id as the parameter. For example, you could use this information to predefine a payment method. Or choose which paymentMethods to display to give the customer the option to choose their preferred method.

Creating an Intent

First, create an intent with the Payment intent endpoint. This step does not use MoneyHash's Javascript SDK and is standard for all MoneyHash's integrations, except for HPP. This endpoint requires authentication to be executed properly. You need to provide the Account API Key as a header and send the required data in the request body. Check the Create an Intent page for further explanation.


moneyHash
  .getMethods({ intentId: "<intent_id>" })
  .then(({ paymentMethods, expressMethods, savedCards, customerBalances }) => {
    console.log({
      paymentMethods,
      expressMethods,
      savedCards,
      customerBalances,
    });
  });

moneyHash
  .getIntentMethods("<intent_id>")
  .then(({ paymentMethods, expressMethods, savedCards, customerBalances }) => {
    console.log({
      paymentMethods,
      expressMethods,
      savedCards,
      customerBalances,
    });
  });

🚧

getIntentMethods will be deprecated in next major version.

Please start using getMethods instead


Get Intent Details

To access all intent details related to a specific intent_id.

moneyHash
  .getIntentDetails("<intent_id>")
  .then(({ intent, transaction, selectedMethod, state, stateDetails, shippingData, productItems, nativePayData, recommendedMethods }) => {
    console.log({
      intent,
      transaction,
      selectedMethod,
      state,
      stateDetails,
      shippingData,
      productItems,
      nativePayData,
      recommendedMethods
    });
  });

Proceed With Payment

moneyHash
  .proceedWith({
    intentId: "<intent_id>",
    type: "method" | "savedCard" | "customerBalance",
    id: "<method_id>" | "<card_id>" | "<customer_balance_id>",
    metaData: {
      cvv: "<cvv>", // required for customer saved cards that requires cvv
    },
  })
  .then(({ intent, transaction, selectedMethod, state, stateDetails, shippingData, productItems, nativePayData, recommendedMethods }) => {
    console.log({
      intent,
      transaction,
      selectedMethod,
      state,
      stateDetails,
      shippingData,
      productItems,
      nativePayData,
      recommendedMethods,
    });
  });

To stay up to date with the process, you can use the onComplete and/or onFail callback methods when creating the MoneyHash instance.

Refer to Event Listeners