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

feat: boutique add currency into an env variable #1638

Merged
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
37 changes: 17 additions & 20 deletions packages/boutique/backend/src/open-payments/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ interface CreateOutgoingPaymentParams {
authServer: string
identifier: string
walletAddress: string
debitAmount: Amount
receiveAmount: Amount
nonce: string
finishUrl?: string
limits: {
debitAmount: Amount
receiveAmount: Amount
receiver?: string
}
}

interface CreateIncomingPaymentParams {
Expand Down Expand Up @@ -127,9 +130,11 @@ export class OpenPayments implements IOpenPayments {
identifier: order.id,
walletAddress: customerWalletAddress.id,
authServer: customerWalletAddress.authServer,

debitAmount: quote.debitAmount,
receiveAmount: quote.receiveAmount,
limits: {
debitAmount: quote.debitAmount,
receiveAmount: quote.receiveAmount,
receiver: incomingPayment.id
},
nonce: clientNonce
})

Expand Down Expand Up @@ -260,8 +265,10 @@ export class OpenPayments implements IOpenPayments {
walletAddress: walletAddress.id,
authServer: walletAddress.authServer,
identifier: clientIdentifer,
debitAmount: amountData,
receiveAmount: amountData,
limits: {
debitAmount: amountData,
receiveAmount: amountData
},
finishUrl: `${this.env.FRONTEND_URL}/cart/finish?identifier=${clientIdentifer}`
})

Expand Down Expand Up @@ -402,15 +409,8 @@ export class OpenPayments implements IOpenPayments {
private async createOutgoingPaymentGrant(
params: CreateOutgoingPaymentParams
): Promise<PendingGrant> {
const {
nonce,
authServer,
identifier,
walletAddress,
debitAmount,
receiveAmount,
finishUrl
} = params
const { nonce, authServer, identifier, walletAddress, limits, finishUrl } =
params

const finish =
finishUrl ??
Expand All @@ -426,10 +426,7 @@ export class OpenPayments implements IOpenPayments {
type: 'outgoing-payment',
actions: ['create', 'read', 'list'],
identifier: walletAddress,
limits: {
debitAmount,
receiveAmount
}
limits
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion packages/boutique/backend/src/payment/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface IPaymentService {

export class PaymentService implements IPaymentService {
private readonly TRESHOLD_MS: number = 5000
private readonly MAX_ATTEMPTS: number = 5
private readonly MAX_ATTEMPTS: number = 24

constructor(
private logger: Logger,
Expand Down
1 change: 1 addition & 0 deletions packages/boutique/frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_CURRENCY=
2 changes: 1 addition & 1 deletion packages/boutique/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"preview": "vite preview"
},
"dependencies": {
"@boutique/shared": "workspace:*",
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
Expand All @@ -17,7 +18,6 @@
"@radix-ui/react-tabs": "^1.1.0",
"@radix-ui/react-toast": "^1.2.1",
"@tanstack/react-query": "^5.56.2",
"@boutique/shared": "workspace:*",
"class-variance-authority": "^0.7.0",
"framer-motion": "^11.5.6",
"react": "^18.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/boutique/frontend/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function cn(...inputs: CxOptions) {
export function formatPrice(price: number): string {
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
currency: import.meta.env.VITE_CURRENCY || 'USD',
maximumFractionDigits: 2,
minimumFractionDigits: 2
})
Expand Down
2 changes: 1 addition & 1 deletion packages/wallet/frontend/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
34 changes: 24 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading