-
Notifications
You must be signed in to change notification settings - Fork 22
fix(payment): align quoted bank fee with actual deposit bank #3864
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,7 +37,9 @@ import { FeeService, UserFeeRequest } from 'src/subdomains/supporting/payment/se | |
| import { Price } from 'src/subdomains/supporting/pricing/domain/entities/price'; | ||
| import { BankTxReturn } from '../../bank-tx/bank-tx-return/bank-tx-return.entity'; | ||
| import { BankTx } from '../../bank-tx/bank-tx/entities/bank-tx.entity'; | ||
| import { BankService } from '../../bank/bank/bank.service'; | ||
| import { CardBankName, IbanBankName } from '../../bank/bank/dto/bank.dto'; | ||
| import { VirtualIbanService } from '../../bank/virtual-iban/virtual-iban.service'; | ||
| import { CryptoInput, PayInConfirmationType } from '../../payin/entities/crypto-input.entity'; | ||
| import { PriceCurrency, PriceValidity, PricingService } from '../../pricing/services/pricing.service'; | ||
| import { FeeAmountsDto, FeeInfo, FeeSpec, InternalFeeDto, toFeeDto } from '../dto/fee.dto'; | ||
|
|
@@ -77,6 +79,8 @@ export class TransactionHelper implements OnModuleInit { | |
| private readonly buyService: BuyService, | ||
| private readonly assetService: AssetService, | ||
| private readonly countryService: CountryService, | ||
| private readonly bankService: BankService, | ||
| private readonly virtualIbanService: VirtualIbanService, | ||
| ) {} | ||
|
|
||
| onModuleInit() { | ||
|
|
@@ -269,7 +273,7 @@ export class TransactionHelper implements OnModuleInit { | |
| const chfPrice = await this.pricingService.getPrice(txAsset, PriceCurrency.CHF, PriceValidity.ANY); | ||
| const txAmountChf = chfPrice.convert(txAmount); | ||
|
|
||
| const bankIn = TransactionHelper.getDefaultBankByPaymentMethod(paymentMethodIn); | ||
| const bankIn = await this.getBankIn(from, paymentMethodIn, user?.userData); | ||
| const bankOut = TransactionHelper.getDefaultBankByPaymentMethod(paymentMethodOut); | ||
|
|
||
| const wallet = walletName ? await this.walletService.getByIdOrName(undefined, walletName) : undefined; | ||
|
|
@@ -851,6 +855,31 @@ export class TransactionHelper implements OnModuleInit { | |
|
|
||
| // --- HELPER METHODS --- // | ||
|
|
||
| private async getBankIn( | ||
| from: Active, | ||
| paymentMethodIn: PaymentMethod, | ||
| userData?: UserData, | ||
| ): Promise<CardBankName | IbanBankName | undefined> { | ||
| const isBankTransfer = | ||
| isFiat(from) && | ||
| [FiatPaymentMethod.BANK, FiatPaymentMethod.INSTANT].includes(paymentMethodIn as FiatPaymentMethod); | ||
| if (!isBankTransfer) return TransactionHelper.getDefaultBankByPaymentMethod(paymentMethodIn); | ||
|
|
||
| // vIBAN deposits are received at the vIBAN bank | ||
| if (userData) { | ||
| const virtualIban = await this.virtualIbanService.getActiveForUserAndCurrency(userData, from.name); | ||
| if (virtualIban?.bank.receive) return virtualIban.bank.name; | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This early return is wrong for EUR (see other comment on
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 32b6581 — eligibility prediction removed from |
||
|
|
||
| const bank = await this.bankService.getBank({ | ||
| currency: from.name, | ||
| paymentMethod: paymentMethodIn as FiatPaymentMethod, | ||
| userData, | ||
| }); | ||
|
|
||
| return bank?.name ?? TransactionHelper.getDefaultBankByPaymentMethod(paymentMethodIn); | ||
| } | ||
|
|
||
| static getDefaultBankByPaymentMethod(paymentMethod: PaymentMethod): CardBankName | IbanBankName { | ||
| switch (paymentMethod) { | ||
| case FiatPaymentMethod.BANK: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currenciesincludes EUR but EUR vIBANs no longer exist (Yapeal EUR hasreceive=false). This causesisUserEligibleto return true for EUR users, triggering vIBAN creation attempts ingetBankInfothat silently fail and an incorrect Yapeal fee quote ingetBankIn(see other comment). Should be['CHF']only.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 32b6581 —
currenciesis now['CHF'], sogetBankInfono longer attempts EUR vIBAN creation.