Lock and Unlock

useLockAndUnlockCard

The following environment variables are required:

API_BAAS_CUSTOMER_CARD_LOCK='/baas/debit-cards/$CARD_ID/lock'
API_BAAS_CUSTOMER_CARD_UNLOCK='/baas/debit-cards/$CARD_ID/unlock'

How to use?

  • Import useLockAndUnlockCard:

import {useLockAndUnlockCard} from 'LinkerStudio/modules/baas/common/hooks/useLockAndUnlockCard';
  • Add this code block:

const [lockCard, isLock, unlockCard, isUnlock, lockOrUnlockCardIsLoading]=useLockAndUnlockCard();

How to lock card?

  • Use the lockCard function, and invoke CardsService from LinkerStudio/modules/baas/common/services/CardsService to lock card:

const lockCard = async ({cardId, lockReason}: PutLockAndUnLockCard) => {
    try {
      await CardsService.lockAndUnLockCard({
        cardId,
        lockReason,
      });
    } catch (error) {
      return error
    } 
};

How to unlock card?

Use the unlockCard function, and invoke CardsService from LinkerStudio/modules/baas/common/services/CardsService to unlock card:

const unlockCard = async ({cardId}: PutLockAndUnLockCard) => {
    try {
      await CardsService.unLockCard({
        cardId,
      });
    } catch (error) {
      return error
    }
};

Last updated