@transferwise/comparison-components 20.0.2 → 20.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/es/{ComparisonTableHeroContainer-f12d8f19.js → ComparisonTableHeroContainer-ab8ea546.js} +2 -2
- package/dist/es/{ComparisonTableHeroContainer-f12d8f19.js.map → ComparisonTableHeroContainer-ab8ea546.js.map} +1 -1
- package/dist/es/{ErrorTemplate-250e9bba.js → ErrorTemplate-1f24ebcf.js} +2 -2
- package/dist/es/{ErrorTemplate-250e9bba.js.map → ErrorTemplate-1f24ebcf.js.map} +1 -1
- package/dist/es/{ProviderComparisonTable-e17876a8.js → ProviderComparisonTable-4e427e58.js} +2 -2
- package/dist/es/{ProviderComparisonTable-e17876a8.js.map → ProviderComparisonTable-4e427e58.js.map} +1 -1
- package/dist/es/{ReceiveAmount-84d0cb30.js → ReceiveAmount-0c3bd3e0.js} +2 -2
- package/dist/es/{ReceiveAmount-84d0cb30.js.map → ReceiveAmount-0c3bd3e0.js.map} +1 -1
- package/dist/es/{TravelMoney-70e3fe1f.js → TravelMoney-e25574b7.js} +2 -2
- package/dist/es/{TravelMoney-70e3fe1f.js.map → TravelMoney-e25574b7.js.map} +1 -1
- package/dist/es/comparison/index.js +1 -1
- package/dist/es/comparison-table/index.js +1 -1
- package/dist/es/comparison-table-hero/index.js +1 -1
- package/dist/es/{index-641643db.js → index-57cc897f.js} +2 -2
- package/dist/es/{index-641643db.js.map → index-57cc897f.js.map} +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/provider-comparison-table/index.js +1 -1
- package/dist/es/provider-comparison-widget/index.js +1 -1
- package/dist/es/transformQuotesResponseV2.js +1 -1
- package/dist/es/travel-money/index.js +1 -1
- package/dist/umd/comparison-components.css +1 -1
- package/dist/umd/comparison-components.js +3 -3
- package/dist/umd/comparison-components.js.map +1 -1
- package/package.json +1 -1
- package/src/domain/QuoteApi.ts +1 -1
- package/src/resources/clients/quotes/__test__/transformQuotesResponseV2.spec.ts +61 -6
- package/src/resources/clients/quotes/__test__/wiseQuoteApiIdrToEurResponse.json +85 -0
- package/src/resources/clients/quotes/transformQuotesResponseV2.ts +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/comparison-components",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.3",
|
|
4
4
|
"description": "Display a comparison table of providers given a route and amount.",
|
|
5
5
|
"homepage": "https://wise.com/gb/compare/",
|
|
6
6
|
"main": "dist/umd/comparison-components.js",
|
package/src/domain/QuoteApi.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FeeType } from '../../../../transfer-fee-comparison/domain/Quote';
|
|
2
2
|
import transformQuotesResponseV2 from '../transformQuotesResponseV2';
|
|
3
3
|
|
|
4
|
+
import wiseQuoteApiIdrToEurResponse from './wiseQuoteApiIdrToEurResponse.json';
|
|
4
5
|
import wiseQuoteApiResponse from './wiseQuoteApiResponse.json';
|
|
5
6
|
|
|
6
7
|
describe('quotes v3 response transformations to the canonical model V2', () => {
|
|
@@ -366,7 +367,7 @@ describe('quotes v3 response transformations to the canonical model V2', () => {
|
|
|
366
367
|
expect(transformQuotesResponseV2(providers, wiseProvider)).toStrictEqual(expected);
|
|
367
368
|
});
|
|
368
369
|
|
|
369
|
-
it('given a route with a small conversion rate, and provider
|
|
370
|
+
it('given a route with a small conversion rate, and provider doesnt have a hidden fee more than a cent, dont show the hidden fee', () => {
|
|
370
371
|
const wiseProvider = {
|
|
371
372
|
...wiseQuoteApiAdjusted,
|
|
372
373
|
rate: 0.00769645,
|
|
@@ -413,12 +414,8 @@ describe('quotes v3 response transformations to the canonical model V2', () => {
|
|
|
413
414
|
type: FeeType.MARKETED,
|
|
414
415
|
amount: { value: 40, currency: 'JPY' },
|
|
415
416
|
},
|
|
416
|
-
{
|
|
417
|
-
type: FeeType.HIDDEN,
|
|
418
|
-
amount: { value: 0.23, currency: 'JPY' },
|
|
419
|
-
},
|
|
420
417
|
],
|
|
421
|
-
total: { value: 40
|
|
418
|
+
total: { value: 40, currency: 'JPY' },
|
|
422
419
|
},
|
|
423
420
|
receiveAmount: { value: 0.46, currency: 'EUR' },
|
|
424
421
|
sendAmount: { value: 100, currency: 'JPY' },
|
|
@@ -428,4 +425,62 @@ describe('quotes v3 response transformations to the canonical model V2', () => {
|
|
|
428
425
|
|
|
429
426
|
expect(transformQuotesResponseV2(providers, wiseProvider)).toStrictEqual(expected);
|
|
430
427
|
});
|
|
428
|
+
|
|
429
|
+
it('given Wise as provider, with a very small convert rate, dont show the hidden fee', () => {
|
|
430
|
+
const wiseProvider = {
|
|
431
|
+
...wiseQuoteApiIdrToEurResponse,
|
|
432
|
+
};
|
|
433
|
+
const providers = {
|
|
434
|
+
providers: [
|
|
435
|
+
{
|
|
436
|
+
name: 'Wise',
|
|
437
|
+
alias: 'transferwise',
|
|
438
|
+
logo: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
439
|
+
partner: true,
|
|
440
|
+
quotes: [
|
|
441
|
+
{
|
|
442
|
+
rate: 10,
|
|
443
|
+
fee: 10,
|
|
444
|
+
dateCollected: new Date('2018-10-23T12:03:27'),
|
|
445
|
+
receivedAmount: 10,
|
|
446
|
+
},
|
|
447
|
+
],
|
|
448
|
+
},
|
|
449
|
+
],
|
|
450
|
+
sendAmount: 20000,
|
|
451
|
+
sourceCurrency: 'IDR',
|
|
452
|
+
targetCurrency: 'EUR',
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
const expected = {
|
|
456
|
+
quotes: [
|
|
457
|
+
{
|
|
458
|
+
provider: {
|
|
459
|
+
name: 'Wise',
|
|
460
|
+
alias: 'transferwise',
|
|
461
|
+
logoUrl: 'https://dq8dwmysp7hk1.cloudfront.net/logos/western-union.svg',
|
|
462
|
+
partner: true,
|
|
463
|
+
},
|
|
464
|
+
route: {
|
|
465
|
+
sourceCurrency: 'IDR',
|
|
466
|
+
targetCurrency: 'EUR',
|
|
467
|
+
},
|
|
468
|
+
rate: 0.0000619427,
|
|
469
|
+
fees: {
|
|
470
|
+
breakdown: [
|
|
471
|
+
{
|
|
472
|
+
type: FeeType.MARKETED,
|
|
473
|
+
amount: { value: 12219, currency: 'IDR' },
|
|
474
|
+
},
|
|
475
|
+
],
|
|
476
|
+
total: { value: 12219, currency: 'IDR' },
|
|
477
|
+
},
|
|
478
|
+
receiveAmount: { value: 0.48, currency: 'EUR' },
|
|
479
|
+
sendAmount: { value: 20000, currency: 'IDR' },
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
expect(transformQuotesResponseV2(providers, wiseProvider)).toStrictEqual(expected);
|
|
485
|
+
});
|
|
431
486
|
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sourceAmount": 20000,
|
|
3
|
+
"guaranteedTargetAmountAllowed": true,
|
|
4
|
+
"targetAmountAllowed": true,
|
|
5
|
+
"paymentOptions": [
|
|
6
|
+
{
|
|
7
|
+
"formattedEstimatedDelivery": "in 4 hours",
|
|
8
|
+
"estimatedDeliveryDelays": [],
|
|
9
|
+
"allowedProfileTypes": [
|
|
10
|
+
"PERSONAL"
|
|
11
|
+
],
|
|
12
|
+
"feePercentage": 0.6110,
|
|
13
|
+
"estimatedDelivery": "2021-11-26T15:15:00Z",
|
|
14
|
+
"sourceCurrency": "IDR",
|
|
15
|
+
"targetCurrency": "EUR",
|
|
16
|
+
"sourceAmount": 20000,
|
|
17
|
+
"targetAmount": 0.48,
|
|
18
|
+
"payOut": "BANK_TRANSFER",
|
|
19
|
+
"fee": {
|
|
20
|
+
"transferwise": 12219.0,
|
|
21
|
+
"payIn": 0.0,
|
|
22
|
+
"discount": 0,
|
|
23
|
+
"total": 12219.0,
|
|
24
|
+
"priceSetId": 266,
|
|
25
|
+
"partner": 0.0
|
|
26
|
+
},
|
|
27
|
+
"payIn": "BANK_TRANSFER",
|
|
28
|
+
"disabled": false
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"formattedEstimatedDelivery": "in 4 hours",
|
|
32
|
+
"estimatedDeliveryDelays": [],
|
|
33
|
+
"allowedProfileTypes": [
|
|
34
|
+
"PERSONAL",
|
|
35
|
+
"BUSINESS"
|
|
36
|
+
],
|
|
37
|
+
"feePercentage": 0.2343,
|
|
38
|
+
"estimatedDelivery": "2021-11-26T15:15:00Z",
|
|
39
|
+
"disabledReason": {
|
|
40
|
+
"code": "error.payInmethod.disabled",
|
|
41
|
+
"message": "Open a multi currency account and add funds to instantly pay for your transfers.",
|
|
42
|
+
"arguments": []
|
|
43
|
+
},
|
|
44
|
+
"sourceCurrency": "IDR",
|
|
45
|
+
"targetCurrency": "EUR",
|
|
46
|
+
"sourceAmount": 20000,
|
|
47
|
+
"targetAmount": 0.95,
|
|
48
|
+
"payOut": "BANK_TRANSFER",
|
|
49
|
+
"fee": {
|
|
50
|
+
"transferwise": 4686.0,
|
|
51
|
+
"payIn": 0.0,
|
|
52
|
+
"discount": 0,
|
|
53
|
+
"total": 4686.0,
|
|
54
|
+
"priceSetId": 267,
|
|
55
|
+
"partner": 0.0
|
|
56
|
+
},
|
|
57
|
+
"payIn": "BALANCE",
|
|
58
|
+
"disabled": true
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"notices": [],
|
|
62
|
+
"transferFlowConfig": {
|
|
63
|
+
"highAmount": {
|
|
64
|
+
"showFeePercentage": false,
|
|
65
|
+
"trackAsHighAmountSender": false,
|
|
66
|
+
"showEducationStep": false,
|
|
67
|
+
"offerPrefundingOption": false
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"rateTimestamp": "2021-11-26T11:51:01Z",
|
|
71
|
+
"clientId": "unknown",
|
|
72
|
+
"type": "REGULAR",
|
|
73
|
+
"sourceCurrency": "IDR",
|
|
74
|
+
"targetCurrency": "EUR",
|
|
75
|
+
"status": "PENDING",
|
|
76
|
+
"rate": 0.0000619427,
|
|
77
|
+
"createdTime": "2021-11-26T11:52:00Z",
|
|
78
|
+
"rateType": "FIXED",
|
|
79
|
+
"rateExpirationTime": "2021-11-29T11:52:00Z",
|
|
80
|
+
"payOut": "BANK_TRANSFER",
|
|
81
|
+
"guaranteedTargetAmount": false,
|
|
82
|
+
"providedAmountType": "SOURCE",
|
|
83
|
+
"expirationTime": "2021-11-26T12:22:00Z",
|
|
84
|
+
"funding": "POST"
|
|
85
|
+
}
|
|
@@ -23,7 +23,7 @@ function extractHiddenFeeInSourceCurrency(
|
|
|
23
23
|
marketedFee: number,
|
|
24
24
|
midmarketRate: number,
|
|
25
25
|
) {
|
|
26
|
-
const toleranceAmountInPercentage = 0.
|
|
26
|
+
const toleranceAmountInPercentage = 0.01;
|
|
27
27
|
const expectedReceivedAmount = midmarketRate * (sendAmount - marketedFee);
|
|
28
28
|
|
|
29
29
|
const receivedTheExpectedAmount = numberEqualsWithRelativeTolerance(
|
|
@@ -34,7 +34,10 @@ function extractHiddenFeeInSourceCurrency(
|
|
|
34
34
|
const receivedHigherThanExpected =
|
|
35
35
|
!receivedTheExpectedAmount && receivedAmount > expectedReceivedAmount;
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const expectedHasMoreThanACentMissing = expectedReceivedAmount - receivedAmount >= 0.01;
|
|
38
|
+
|
|
39
|
+
const hasHiddenFee =
|
|
40
|
+
!receivedTheExpectedAmount && !receivedHigherThanExpected && expectedHasMoreThanACentMissing;
|
|
38
41
|
const hiddenFeePaidOnTargetCurrency = hasHiddenFee ? expectedReceivedAmount - receivedAmount : 0;
|
|
39
42
|
|
|
40
43
|
return parseFloat((hiddenFeePaidOnTargetCurrency * (1 / midmarketRate)).toFixed(2));
|