-
Notifications
You must be signed in to change notification settings - Fork 1
Description
To improve UX and handle Solana price volatility during payment confirmation, we need to implement configurable thresholds around payment amount acceptance and overpayment refunding.
Currently, the exact SOL amount is calculated from fiat (USD/EUR) prices using a conversion rate updated every x minutes, leading to possible payment mismatches due to price fluctuations.
Feature Requirements:
Add new configuration options for Solana Pay module:
conversionRateBufferFactor (number, default ~1.05): multiplier applied to the fiat-to-SOL conversion rate to add a buffer margin in merchant’s favor.
minAcceptanceRatio (number, default ~0.98): minimum ratio of received payment amount to the expected amount required to consider payment accepted (e.g., 0.98 = accept if paid ≥ 98%).
overpaymentRefundRatio (number, default ~1.10): ratio threshold beyond which the excess payment should be refunded (e.g., 1.10 = refund if paying more than 110%).
Update the payment verification logic to:
Use the buffered conversion rate when calculating the required SOL payment amount.
Accept payments with amounts ≥ minAcceptanceRatio * requiredAmount.
If payment amount > overpaymentRefundRatio * requiredAmount, calculate the excess for refund.
Otherwise, accept payment as-is without refund.
Update configuration schema and documentation for these new options.
Add unit tests covering various payment scenarios: exact payment, small underpay tolerated, small overpay accepted without refund, large overpay triggering refund.
Context:
This feature will smooth out UX issues caused by price volatility and give merchants flexibility in defining tolerances, preventing failed payments due to minor underpayments and minimizing loss from overpayments.
option example:
options: {
passPhrase: SOLANA_MNEMONIC,
rpcUrl: SOLANA_RPC_URL || 'https://api.devnet.solana.com',
coldStorageWallet: SOLANA_COLD_STORAGE_WALLET,
paymentThresholds: {
conversionRateBufferFactor: 1.05, // multiplier applied to fiat->SOL conversion rate (e.g. 1.05 = +5%)
minAcceptanceRatio: 0.98, // accept payments >= 98% of expected SOL amount
overpaymentRefundRatio: 1.10 // if payment > 110%, refund the excess
}
}
Metadata
Metadata
Assignees
Labels
Projects
Status