Save card for future use

First, create a card intent with the Card 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 a Card Intent page for further explanation.

Don't forget to include "card_token_type": "UNIVERSAL" while creating the card intent.


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

const moneyHash = new MoneyHash({
  type: "payment",
  publicApiKey: "<account_public_api_key>",
});

Collect Card Data

Collect card data to create a card token for a customer.

const cardData = await moneyHash.cardForm.collect();

You will need to render card form fields to be able to collect customer card information.

Create Card Token

moneyHash.cardForm.createCardToken({
  cardData, // Collected card data using moneyHash.cardForm.collect()
  cardIntentId: "<card_intent_id">,
}).then(({ state, stateDetails }) => {
  console.log({ state, stateDetails });
});

📘

You can run any business login needed between collecting card data & tokenizing it.