All files / src/sections/PayBuilder/Checkout types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202                                                                                                                                                                                                                                                                                                                                                                                                                   
import type { RecaptchaCheckoutAction } from "@utils/getRecaptchaToken";
import type { CustomFieldAnswerPayload } from "./customFields.helpers";
import type { ParticipantPayloadEntry, ParticipantValues } from "./participants.helpers";
 
export interface ICheckoutInputs {
  // Story 2 — per-ticket participant answers, keyed by
  // `${productVariantID}:${unitIndex}` (or SINGLE_PARTICIPANT_KEY when one
  // participant governs the order). Optional because the section renders only
  // for events behind a flag.
  participants?: ParticipantValues;
  // AC054 — the buyer is the participant. Defaults true, which is what keeps an
  // untouched event checkout's payload identical to today's.
  participantsSameAsContact?: boolean;
  // Mirrors the contact email into every `participants.*.email` while true
  // (per-ticket mode only); editing one row's email flips it back. Defaults false.
  sendAllTicketsToEmail?: boolean;
  // The buyer's own name, collected in the Contact section of the event
  // checkout. Optional because it renders only for events (behind a flag);
  // every other form type still derives the name from `Name on Card`.
  name?: string;
  email: string;
  phoneNumber: string;
  payment: {
    cardNumber: string;
    expirationDate: string;
    cvv: string;
    nameOnCard: string;
  };
  billingAddress: {
    country: string;
    firstName: string;
    lastName: string;
    address: string;
    apartment: string;
    city: string;
    province: string;
    zipCode: string;
    useDeliveryAddress: boolean;
  };
  deliveryAddress: {
    country: string;
    firstName: string;
    lastName: string;
    address: string;
    apartment: string;
    city: string;
    province: string;
    zipCode: string;
    phoneNumber: string;
  };
  customerCoversFees: boolean;
  termsConditions: boolean;
  // PAY-Builder016 — customer answers keyed by each field's client id.
  customFields?: Record<string, string>;
  // Merged onto checkout submit for fundraiser / sweepstake forms only.
  Donations?: { selectedAmount?: string; isAnonymous?: boolean };
  Entries?: { selectedEntry?: string; isAnonymous?: boolean };
}
 
export type CheckoutRequestAddress = {
  name?: string;
  line1?: string;
  line2?: string;
  city?: string;
  state?: string;
  zip?: string;
  country?: string;
  phoneNumber?: string;
  notes?: string;
};
 
export type CheckoutRequestUser = {
  firstName?: string;
  lastName?: string;
  email?: string;
  phoneNumber?: string | null;
  occupation?: string;
  employer?: string;
  shippingAddress?: CheckoutRequestAddress | null;
  billingAddress?: CheckoutRequestAddress | null;
};
 
export type CheckoutRequestCard = {
  address?: CheckoutRequestAddress;
  cardholderName?: string;
  number?: string;
  cvv?: string;
  expiryMonth?: number;
  expiryYear?: number;
  isDebit?: boolean;
};
 
/** POST /cart/checkout body. JSON names from givesync-api OrderCheckoutParams. */
export type CheckoutRequest = {
  user?: CheckoutRequestUser;
  paymentMethodParams: {
    paymentMethodID: number | null;
    paymentMethod?: {
      card?: CheckoutRequestCard;
      isDefault?: boolean;
    };
  };
  passFees?: boolean;
  notes?: string;
  sourceTypeName?: string;
  isTTP?: boolean;
  items?: number[];
  isCustomerAnonymous?: boolean;
  customFields?: CustomFieldAnswerPayload[];
  participants?: ParticipantPayloadEntry[];
  captchaToken?: string;
  captchaAction?: RecaptchaCheckoutAction;
};
 
export type CheckoutCaptchaPayload = Pick<
  CheckoutRequest,
  "captchaToken" | "captchaAction"
>;
 
export type CheckoutResponseItem = {
  id: number;
  createdAt: number;
  updatedAt: number;
  orderID: number;
  groupID: number;
  unitPrice: number;
  quantity: number;
  recurringFrequency: number | null;
  recurringMax: number | null;
  productVariantID: number;
  productVariantName: string;
  productVariantPrice: number;
  productVariantImageURL: string;
  productName: string;
  productReference: string;
  productType: string;
  recurringIntervalName: string | null;
  successMessage: string;
  recurringNextAt: number | null;
  isAutomaticallyAdded: boolean;
};
 
export type CheckoutResponsePaymentMethodCard = {
  brandName: string;
  brandDisplayName: string;
  last4: string;
  isDebit: boolean;
  expiryMonth: number;
  expiryYear: number;
};
 
export type CheckoutResponsePaymentMethod = {
  id: number;
  type: string;
  isDefault: boolean;
  card?: CheckoutResponsePaymentMethodCard | null;
};
 
export type CheckoutResponseBinInfo = {
  id: number;
  isValid: boolean;
  cardBrand: string;
  cardType: string;
  cardCategory: string;
  issuer: string;
  issuerWebsite: string;
  isCommercial: boolean;
  isPrepaid: boolean;
};
 
export type CheckoutResponse = {
  id: number;
  createdAt: number;
  updatedAt: number;
  cost: number;
  fees: number;
  passFees: boolean;
  notes: string;
  sourceType: string;
  processedAsAuthOnly: boolean;
  userAccID: number;
  userFirstName: string;
  userLastName: string;
  userEmail: string;
  userPhoneNumber: string | null;
  userOccupation: string | null;
  userEmployer: string | null;
  transactionID: string;
  transactionProcessingState: string;
  customerFirstName: string;
  customerLastName: string;
  customerEmail: string;
  customerPhoneNumber: string | null;
  customerOccupation: string | null;
  customerEmployer: string | null;
  mspResponseCode: string | null;
  paymentMethod: CheckoutResponsePaymentMethod | null;
  binInfo: CheckoutResponseBinInfo | null;
  items: CheckoutResponseItem[];
  dstAccOwnerEmail: string;
};