Skip to content

Commit

Permalink
POS: Settings: add ability to add merchant name to memos
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Jan 26, 2023
1 parent 6f8e17d commit 2a2b101
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@
"views.Settings.POS.enableSquare": "Enable Square POS integration",
"views.Settings.POS.squareAccessToken": "Square Access token",
"views.Settings.POS.squareLocationId": "Square Location ID",
"views.Settings.POS.merchantName": "Merchant name (Optional, used for invoice memos)",
"views.Settings.POS.confPref": "Confirmation preference",
"views.Settings.POS.disableTips": "Disable tips",
"views.Settings.POS.devMode": "Developer mode",
Expand Down
2 changes: 2 additions & 0 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ interface PosSettings {
squareEnabled?: boolean;
squareAccessToken?: string;
squareLocationId?: string;
merchantName?: string;
confirmationPreference?: string;
disableTips?: boolean;
squareDevMode?: boolean;
Expand Down Expand Up @@ -212,6 +213,7 @@ export default class SettingsStore {
squareEnabled: false,
squareAccessToken: '',
squareLocationId: '',
merchantName: '',
confirmationPreference: 'lnOnly',
disableTips: false,
squareDevMode: false
Expand Down
9 changes: 6 additions & 3 deletions views/Order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ export default class OrderView extends React.Component<OrderProps, OrderState> {
const { changeUnits, units } = UnitsStore;
const fiat = settings.fiat;
const disableTips: boolean =
settings && settings.pos && settings.pos.disableTips;
(settings && settings.pos && settings.pos.disableTips) || false;
const merchantName =
settings && settings.pos && settings.pos.merchantName;

const fiatEntry =
fiat && fiatRates && fiatRates.filter
Expand All @@ -90,8 +92,9 @@ export default class OrderView extends React.Component<OrderProps, OrderState> {

const lineItems = order.line_items;

// TODO add custom memo label in settings
const memo = `ZEUS POS: ${order.id}`;
const memo = merchantName
? `${merchantName} POS powered by ZEUS - Order ${order.id}`
: `ZEUS POS - Order ${order.id}`;

// round to nearest sat
const subTotalSats = new BigNumber(order.total_money.amount)
Expand Down
41 changes: 41 additions & 0 deletions views/Settings/PointOfSale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface PointOfSaleState {
squareEnabled: boolean;
squareAccessToken: string;
squareLocationId: string;
merchantName: string;
confirmationPreference: string;
disableTips: boolean;
squareDevMode: boolean;
Expand All @@ -42,6 +43,7 @@ export default class PointOfSale extends React.Component<
squareEnabled: false,
squareAccessToken: '',
squareLocationId: '',
merchantName: '',
confirmationPreference: 'lnOnly',
disableTips: false,
squareDevMode: false
Expand All @@ -59,6 +61,7 @@ export default class PointOfSale extends React.Component<
(settings.pos && settings.pos.squareAccessToken) || '',
squareLocationId:
(settings.pos && settings.pos.squareLocationId) || '',
merchantName: (settings.pos && settings.pos.merchantName) || '',
confirmationPreference:
(settings.pos && settings.pos.confirmationPreference) ||
'lnOnly',
Expand All @@ -82,6 +85,7 @@ export default class PointOfSale extends React.Component<
squareEnabled,
squareAccessToken,
squareLocationId,
merchantName,
confirmationPreference,
disableTips,
squareDevMode
Expand Down Expand Up @@ -174,6 +178,7 @@ export default class PointOfSale extends React.Component<
pos: {
squareAccessToken,
squareLocationId,
merchantName,
squareEnabled: !squareEnabled,
confirmationPreference,
disableTips,
Expand Down Expand Up @@ -209,6 +214,7 @@ export default class PointOfSale extends React.Component<
squareEnabled,
squareAccessToken: text,
squareLocationId,
merchantName,
confirmationPreference,
disableTips,
squareDevMode
Expand Down Expand Up @@ -239,6 +245,38 @@ export default class PointOfSale extends React.Component<
squareEnabled,
squareAccessToken,
squareLocationId: text,
merchantName,
confirmationPreference,
disableTips,
squareDevMode
}
});
}}
/>

<Text
style={{
color: themeColor('secondaryText'),
fontFamily: 'Lato-Regular'
}}
>
{localeString(
'views.Settings.POS.merchantName'
)}
</Text>
<TextInput
value={merchantName}
onChangeText={async (text: string) => {
this.setState({
merchantName: text
});

await updateSettings({
pos: {
squareEnabled,
squareAccessToken,
squareLocationId,
merchantName: text,
confirmationPreference,
disableTips,
squareDevMode
Expand All @@ -261,6 +299,7 @@ export default class PointOfSale extends React.Component<
squareEnabled,
squareAccessToken,
squareLocationId,
merchantName,
confirmationPreference: value,
disableTips,
squareDevMode
Expand Down Expand Up @@ -306,6 +345,7 @@ export default class PointOfSale extends React.Component<
squareAccessToken,
squareLocationId,
squareEnabled,
merchantName,
confirmationPreference,
disableTips:
!disableTips,
Expand Down Expand Up @@ -354,6 +394,7 @@ export default class PointOfSale extends React.Component<
squareAccessToken,
squareLocationId,
squareEnabled,
merchantName,
confirmationPreference,
disableTips,
squareDevMode:
Expand Down

0 comments on commit 2a2b101

Please sign in to comment.