Skip to content

Commit

Permalink
Add transaction complete event types
Browse files Browse the repository at this point in the history
  • Loading branch information
vctrchu committed Jan 22, 2025
1 parent 4de072e commit 083d4bf
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 9 deletions.
3 changes: 3 additions & 0 deletions packages/ui-extensions/src/surfaces/point-of-sale/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export type {
LineItemDiscount,
CustomSale,
Address,
PaymentMethod,
ShippingLine,
TaxLine,
} from './types/cart';

export type {MultipleResourceResult} from './types/multiple-resource-result';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import {
Discount,
LineItem,
PaymentMethod,
ShippingLine,
TaxLine,
} from '../../api';
import {BaseInput} from './BaseInput';

export interface PurchaseCompleteInput extends BaseInput {
lineItems: any[];
discounts: any[];
attributedStaff: any;
orderId: any;
draftCheckoutId: any;
taxLines: any[];
shippingLines: any[];
purchaseComplete: {
attributedStaff: any;
discounts: Discount[];
draftCheckoutId: string;
lineItems: LineItem[];
orderId: string;
paymentMethods: PaymentMethod[];
shippingLines: ShippingLine;
taxLines: TaxLine[];
};
}
82 changes: 82 additions & 0 deletions packages/ui-extensions/src/surfaces/point-of-sale/types/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface LineItem {
vendor?: string;
properties: {[key: string]: string};
isGiftCard: boolean;
attributedUserId?: number;
}

export interface Discount {
Expand Down Expand Up @@ -107,3 +108,84 @@ export interface Address {
provinceCode?: string;
countryCode?: CountryCode;
}

export type ShippingLine =
| {
handle: string;
price: string;
title: string;
methodType: ShippingMethodType;
type: 'Calculated';
}
| {
handle: string;
price: string;
title: string;
type: 'Custom';
};

export enum ShippingMethodType {
Shipping = 'SHIPPING',
Retail = 'RETAIL',
}

export interface TaxLine {
uuid: string;
price: string;
rate: number;
// For bundles we need to show the range of the tax rate.
// This is the minimum and maximum tax rate of the tax lines of the components.
rateRange?: [number, number];
title: string;
enabled: boolean;
}

export type PaymentMethod =
| CashPayment
| CreditPayment
| GiftCardPayment
| ShopPayPayment
| CustomPayment
| UnknownPayment;

export type CardSource = 'manual' | 'swiped' | 'emv';

interface BasePayment {
amount: string;
}

interface CreditPayment extends BasePayment {
type: 'CreditCard';
lastDigits: string;
brand: string;
tipAmount: string;
cardSource?: CardSource;
hasPendingOfflineTransactions: boolean;
}

interface CashPayment extends BasePayment {
type: 'Cash';
changeAmount: string;
roundedAmount?: string;
}

interface GiftCardPayment extends BasePayment {
type: 'GiftCard';
lastCharacters: string;
balance?: string;
}

interface ShopPayPayment extends BasePayment {
type: 'ShopPay';
isInstallmentsPayment: boolean;
orderTransactionId?: string;
}

interface CustomPayment extends BasePayment {
type: 'Custom';
name: string;
}

interface UnknownPayment extends BasePayment {
type: 'Unknown';
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ export interface Device {
*/
name: string;
/**
* The string ID of the device
* The ID of the device
*/
deviceId: string;
deviceId: number;
/**
* Whether the device is a tablet
*/
Expand Down

0 comments on commit 083d4bf

Please sign in to comment.