Broadleaf Microservices
  • v1.0.0-latest-prod

MyFatoorah Payment Services React Hooks

The Broadleaf MyFatoorah Payment Services React SDK provides several hooks for implementors to make use of.

useInitiateSessionRequest

The hook is used to create an event callback that can be used to create the SetupIntent. SetupIntent is used to set up future card payments

Parameters

Parameter Type Required? Description

myFatoorahPaymentServicesClient

MyFatoorah Payment Services Client

The client needed to make API requests

authState

AuthState

Important information about the authentication state of the user.

Response

Parameter Type Required? Description

initiateSession

`() ⇒ Promise<InitiateSessionResponse

undefined>` InitiateSessionResponse.

The callback method to use to initiate a MyFatoorah checkout session

isFetching

boolean

Whether the request is being processed.

error

ApiError

Example

import { MyFatoorahPaymentServicesClient } from '@broadleaf/myfatoorah-payment-services-api';
import { useInitiateSessionRequest } from '@broadleaf/myfatoorah-payment-services-react';
import { usePaymentAuthState } from '@app/common/hooks';

const myFatoorahPaymentServicesClient = new MyFatoorahPaymentServicesClient();
const authState = usePaymentAuthState();

const { initiateSessionResponse, isFetching, error } = useInitiateSessionRequest({
  myFatoorahPaymentServicesClient,
  authState
});