All files / src/services/api/riskProfile riskProfileActions.ts

62.5% Statements 5/8
90% Branches 9/10
25% Functions 1/4
62.5% Lines 5/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60                    54x               3x                             54x                     54x                   54x          
import { customInstance } from "..";
 
export type TBlockTransaction = {
  merchantId: number;
  id: string;
  reason?: string;
  canNotifyMerchant?: boolean;
  skipRefund?: boolean;
  refundItemIDs?: string[];
};
export const blockTransaction = ({
  merchantId,
  id,
  reason,
  canNotifyMerchant,
  skipRefund,
  refundItemIDs,
}: TBlockTransaction) =>
  customInstance({
    url: `/merchants/${merchantId}/transactions/${id}/block`,
    method: "POST",
    data: {
      blockReason: reason ? reason : "",
      ...(canNotifyMerchant !== undefined && {
        canNotifyMerchant: canNotifyMerchant,
      }),
      ...(skipRefund !== undefined && { skipRefund: skipRefund }),
      ...(Boolean(refundItemIDs && refundItemIDs.length > 0) && {
        refundItemIDs,
      }),
    },
  });
 
export const voidTransaction = (id: string) =>
  customInstance({
    url: `/refunds`,
    method: "POST",
    data: {
      reason: "",
      transactionIDs: [id],
      transactionItemIDs: null,
    },
  });
 
export const unblockTransaction = (merchantId: number, id: string) =>
  customInstance({
    url: `/merchants/${merchantId}/transactions/${id}/block`,
    method: "PATCH",
    data: {
      isFalsePositive: true,
      falsePositiveReason: "",
    },
  });
 
export const allowTransaction = (merchantId: number, id: string) =>
  customInstance({
    url: `/merchants/${merchantId}/transactions/${id}/capture`,
    method: "POST",
  });