All files / src/pages/MerchantCheckout utils.ts

83.33% Statements 5/6
67.56% Branches 25/37
100% Functions 2/2
100% Lines 5/5

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    1x 18x   18x         1x 18x                                                      
import { TypeCheckoutInfo } from "@pages/MerchantCheckout/types";
 
const generateImageUrl = (imageKey: string) => {
  Iif (!imageKey) return "";
 
  return `${
    process.env.VITE_ASSETS_CDN_HOST
  }/customer-avatar/${imageKey?.replace("http://", "")}/medium`;
};
 
export const generateCheckoutInfo = (params: any): TypeCheckoutInfo => {
  return {
    address: params?.address ?? "",
    city: params?.city ?? "",
    country: params?.country ?? "",
    redirectUrl: params?.redirect_url ?? "",
    externalUrl: params?.external_url ?? "",
    merchantName: params?.merchant_name ?? "",
    orderId: params?.order_id ?? "",
    merchantId: params?.merchant_id ?? "",
    imageUrl: generateImageUrl(params?.image_url ?? ""),
    customerEmail: params?.email ?? "",
    amount: params?.amount ?? "",
    zip: params?.zip,
    state: params?.state,
    line1: params?.line1,
    line2: params?.line2 ?? "",
    phone: params?.phone,
    firstName: params?.first_name,
    lastName: params?.last_name,
    companyName: params?.company_name ?? "",
    key: params?.key,
    environment: params?.environment ?? "",
    externalReference: params?.external_reference ?? "",
    netId: params?.net_id ?? "",
    requestorUa: params?.requestor_ua ?? params?.requestorUa ?? "",
  };
};