@traund/orquezta-widget-calculator 1.0.3 → 1.0.5
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/dist/index.js +23 -17
- package/dist/index.js.map +1 -1
- package/dist/module.js +23 -17
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/src/calculatorV2.js +8 -4
- package/src/core/endpoints.js +1 -1
- package/src/core/signature.js +1 -2
- package/src/index.js +2 -0
- package/src/simulator.js +3 -3
- package/src/utils/calculateHelper.js +3 -2
- package/src/utils/operationsHelper.js +5 -4
- package/src/utils/rateHelper.js +1 -1
package/package.json
CHANGED
package/src/calculatorV2.js
CHANGED
|
@@ -80,6 +80,7 @@ class Calculator extends Component {
|
|
|
80
80
|
isCountryFromPayPal: false,
|
|
81
81
|
onlySimulation: this.props.onlySimulation,
|
|
82
82
|
reference:this.props.reference,
|
|
83
|
+
secretKey: this.props.secretKey,
|
|
83
84
|
taxSender: 0.00,
|
|
84
85
|
taxReceiver: 0.00
|
|
85
86
|
};
|
|
@@ -362,10 +363,12 @@ class Calculator extends Component {
|
|
|
362
363
|
rates[c] = { buy: 0, sell: 0 };
|
|
363
364
|
}
|
|
364
365
|
|
|
365
|
-
if (usdRate
|
|
366
|
+
if (usdRate && typeof usdRate.result === "number") {
|
|
366
367
|
rates[c].buy = rates[c].sell = parseFloat(
|
|
367
368
|
c == "SV" ? usdRate.result : usdRate.result.toFixed(2)
|
|
368
369
|
);
|
|
370
|
+
} else {
|
|
371
|
+
rates[c].buy = rates[c].sell = 1;
|
|
369
372
|
}
|
|
370
373
|
if (body[country].countryTo[c]) {
|
|
371
374
|
body[country].countryTo[c].usdBuy = rates[c].buy;
|
|
@@ -695,6 +698,7 @@ class Calculator extends Component {
|
|
|
695
698
|
couponValue: this.state.couponValue,
|
|
696
699
|
couponRedeemed: false,
|
|
697
700
|
reference: this.state.reference ,
|
|
701
|
+
secretKey: this.state.secretKey,
|
|
698
702
|
plus: 0
|
|
699
703
|
});
|
|
700
704
|
if (this.state.recalc) {
|
|
@@ -727,7 +731,7 @@ class Calculator extends Component {
|
|
|
727
731
|
model,
|
|
728
732
|
{
|
|
729
733
|
headers: {
|
|
730
|
-
"x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference)
|
|
734
|
+
"x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference,this.state.secretKey)
|
|
731
735
|
},
|
|
732
736
|
}
|
|
733
737
|
);
|
|
@@ -786,7 +790,7 @@ class Calculator extends Component {
|
|
|
786
790
|
model,
|
|
787
791
|
{
|
|
788
792
|
headers: {
|
|
789
|
-
"x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference)
|
|
793
|
+
"x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference,this.state.secretKey)
|
|
790
794
|
},
|
|
791
795
|
}
|
|
792
796
|
);
|
|
@@ -1067,7 +1071,7 @@ class Calculator extends Component {
|
|
|
1067
1071
|
url,
|
|
1068
1072
|
{
|
|
1069
1073
|
headers: {
|
|
1070
|
-
"x-api-access-sig": getSignatureHeader('GET', url, null,this.state.reference)
|
|
1074
|
+
"x-api-access-sig": getSignatureHeader('GET', url, null,this.state.reference,this.state.secretKey)
|
|
1071
1075
|
},
|
|
1072
1076
|
}
|
|
1073
1077
|
);
|
package/src/core/endpoints.js
CHANGED
|
@@ -3,7 +3,7 @@ import { BACKEND_SETTINGS } from "./backend-settings";
|
|
|
3
3
|
class EndPoints {
|
|
4
4
|
constructor(testMode = 'production', externalConfig = null) {
|
|
5
5
|
this._testMode = testMode;
|
|
6
|
-
this.baseUrl = externalConfig
|
|
6
|
+
this.baseUrl = externalConfig?.backendUrl;
|
|
7
7
|
this.path_managment_operations = `${this.baseUrl}/handle-operations`;
|
|
8
8
|
}
|
|
9
9
|
|
package/src/core/signature.js
CHANGED
|
@@ -24,9 +24,8 @@ export function generateSignature(secretKey, params) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function getSignatureHeader(method, url, body = null, apikey = null) {
|
|
27
|
+
export function getSignatureHeader(method, url, body = null, apikey = null, secretKey = null) {
|
|
28
28
|
const referenceApiKey = apikey ;
|
|
29
|
-
const secretKey = process.env.NEXT_PUBLIC_STAGING_APIKEY;
|
|
30
29
|
const signatureParams = {
|
|
31
30
|
method: method,
|
|
32
31
|
url: url,
|
package/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ function WrappedSimulator(props) {
|
|
|
10
10
|
onlyView={props.onlyView ?? false}
|
|
11
11
|
initialCountryTo={props.initialCountryTo ?? "PE-USD"}
|
|
12
12
|
reference={props.reference || ""}
|
|
13
|
+
secretKey={props.secretKey || ""}
|
|
13
14
|
config={props.config}
|
|
14
15
|
/>;
|
|
15
16
|
}
|
|
@@ -23,6 +24,7 @@ function WrappedCalculator(props) {
|
|
|
23
24
|
couponCode={props.couponCode || ""}
|
|
24
25
|
onlySimulation={props.onlySimulation ?? false}
|
|
25
26
|
reference={props.reference || ""}
|
|
27
|
+
secretKey={props.secretKey || ""}
|
|
26
28
|
config={props.config}
|
|
27
29
|
/>
|
|
28
30
|
);
|
package/src/simulator.js
CHANGED
|
@@ -33,9 +33,9 @@ function Simulator(props) {
|
|
|
33
33
|
const content = locale === "es" ? es : en;
|
|
34
34
|
const classes = useStyles();
|
|
35
35
|
|
|
36
|
-
const __ENDPOINTS = new Endpoints(props.testMode, props.config
|
|
37
|
-
const __calculateHelper = new CalculateHelper(props.testMode);
|
|
38
|
-
const __operationsHelper = new OperationsHelper(props.testMode, props.reference);
|
|
36
|
+
const __ENDPOINTS = new Endpoints(props.testMode, props.config);
|
|
37
|
+
const __calculateHelper = new CalculateHelper(props.testMode, props.config);
|
|
38
|
+
const __operationsHelper = new OperationsHelper(props.testMode, props.reference,props.config, props.secretKey);
|
|
39
39
|
|
|
40
40
|
const __firebase = loadFirebaseDB(props.testMode, props.config);
|
|
41
41
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import RateHelper from "./rateHelper";
|
|
2
2
|
|
|
3
3
|
class CalculateHelper {
|
|
4
|
-
constructor(testMode = 'production') {
|
|
4
|
+
constructor(testMode = 'production',config=null) {
|
|
5
5
|
this._testMode = testMode;
|
|
6
|
+
this.config = config;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
async getCaculateRates(countriesData) {
|
|
9
|
-
const rateHelper = new RateHelper(this._testMode);
|
|
10
|
+
const rateHelper = new RateHelper(this._testMode, this.config);
|
|
10
11
|
const middleCurrency = "USD";
|
|
11
12
|
|
|
12
13
|
for (var key in countriesData) {
|
|
@@ -7,9 +7,10 @@ import { getSignatureHeader } from "../../src/core/signature";
|
|
|
7
7
|
import { config } from "aws-sdk";
|
|
8
8
|
|
|
9
9
|
class OperationsHelper {
|
|
10
|
-
constructor(testMode = 'production',
|
|
11
|
-
this.endpoints = new EndPoints(testMode,config
|
|
12
|
-
this.reference =
|
|
10
|
+
constructor(testMode = 'production', apiKey = null, config=null, secretKey = null) {
|
|
11
|
+
this.endpoints = new EndPoints(testMode, config);
|
|
12
|
+
this.reference = apiKey;
|
|
13
|
+
this.secretKey = secretKey;
|
|
13
14
|
this.FEES = {
|
|
14
15
|
"ach": { type: "A", value: 0 },
|
|
15
16
|
"wise": { type: "A", value: 0.39 },
|
|
@@ -28,7 +29,7 @@ class OperationsHelper {
|
|
|
28
29
|
body,
|
|
29
30
|
{
|
|
30
31
|
headers: {
|
|
31
|
-
"x-api-access-sig": getSignatureHeader('POST', url, body, this.reference)
|
|
32
|
+
"x-api-access-sig": getSignatureHeader('POST', url, body, this.reference,this.secretKey)
|
|
32
33
|
},
|
|
33
34
|
}
|
|
34
35
|
);
|
package/src/utils/rateHelper.js
CHANGED
|
@@ -3,7 +3,7 @@ import EndPoints from "../core/endpoints";
|
|
|
3
3
|
|
|
4
4
|
class RateHelper {
|
|
5
5
|
constructor(testMode = 'production',externalConfig = null) {
|
|
6
|
-
this.endpoints = new EndPoints(testMode, externalConfig
|
|
6
|
+
this.endpoints = new EndPoints(testMode, externalConfig);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async getExchangeRate(currencyFrom, currencyTo) {
|