Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transaction complete event types #2577

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/large-laws-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/ui-extensions': minor
'@shopify/ui-extensions-react': minor
---

Adds POS UI Extension: TransactionCompleteInput property typing and payment interfaces
4 changes: 4 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,8 +91,12 @@ export type {
LineItemDiscount,
CustomSale,
Address,
ShippingLine,
TaxLine,
} from './types/cart';

export type {PaymentMethod} from './types/payment';

export type {MultipleResourceResult} from './types/multiple-resource-result';

export type {PaginatedResult} from './types/paginated-result';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
Discount,
LineItem,
PaymentMethod,
ShippingLine,
TaxLine,
} from '../../api';
import {BaseInput} from './BaseInput';

export interface TransactionCompleteInput extends BaseInput {
transactionComplete: {
discounts: Discount[];
draftCheckoutId: number;
js-goupil marked this conversation as resolved.
Show resolved Hide resolved
lineItems: LineItem[];
orderId?: number;
paymentMethods: PaymentMethod[];
shippingLines?: ShippingLine;
taxLines?: TaxLine[];
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
CashTrackingSessionCompleteInput,
CashTrackingSessionCancelInput,
} from './input/CashTrackingSessionInput';
import {PurchaseCompleteInput} from './input/PurchaseCompleteInput';
import {TransactionCompleteInput} from './input/TransactionCompleteInput';

export interface EventExtensionTargets {
'pos.transaction-complete.event.observe': (
input: PurchaseCompleteInput,
input: TransactionCompleteInput,
) => BaseIntent;
'pos.cash-tracking-session-start.event.observe': (
input: CashTrackingSessionStartInput,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-extensions/src/surfaces/point-of-sale/input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type {BaseInput} from './event/input/BaseInput';
export type {PurchaseCompleteInput} from './event/input/PurchaseCompleteInput';
export type {TransactionCompleteInput} from './event/input/TransactionCompleteInput';

export type {Device} from './types/device';
27 changes: 27 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;
Copy link
Contributor Author

@vctrchu vctrchu Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attributedStaff is known as attributedUserId as defined in the POS model CheckoutLineItem

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, we'll have to map this value over for the cart api as well just fyi

}

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

export type ShippingLine = CalculatedShippingLine | CustomShippingLine;

export interface CalculatedShippingLine {
uuid: string;
price: string;
title: string;
methodType: 'SHIPPING' | 'RETAIL';
type: 'Calculated';
}

export interface CustomShippingLine {
uuid: string;
price: string;
title: string;
type: 'Custom';
}

export interface TaxLine {
uuid: string;
price: string;
rate: number;
rateRange?: {min: number; max: number};
title: string;
enabled: boolean;
}
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
48 changes: 48 additions & 0 deletions packages/ui-extensions/src/surfaces/point-of-sale/types/payment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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';
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';
}
Loading