Skip to content

Commit

Permalink
fix (#949)
Browse files Browse the repository at this point in the history
  • Loading branch information
RustemYuzlibaev authored Feb 9, 2023
1 parent 30d5a39 commit 4234a70
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 30 deletions.
54 changes: 33 additions & 21 deletions src/components/SoraCard/steps/KycView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,41 @@ export default class KycView extends Mixins(TranslationMixin) {
loadingKycView = true;
async getReferenceNumber(URL: string): Promise<string> {
async getReferenceNumber(URL: string): Promise<string | undefined> {
const { kycService } = soraCard(this.soraNetwork);
const token = localStorage.getItem('PW-token');
const result = await fetch(URL, {
method: 'POST',
body: JSON.stringify({
ReferenceID: uuidv4(),
MobileNumber: '',
Email: '',
AddressChanged: false,
DocumentChanged: false,
IbanTypeID: null,
CardTypeID: null,
AdditionalData: '',
}),
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await result.json();
return data.ReferenceNumber;
try {
const result = await fetch(URL, {
method: 'POST',
body: JSON.stringify({
ReferenceID: uuidv4(),
MobileNumber: '',
Email: '',
AddressChanged: false,
DocumentChanged: false,
IbanTypeID: null,
CardTypeID: null,
AdditionalData: '',
}),
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await result.json();
return data.ReferenceNumber;
} catch (data) {
console.error('[SoraCard]: Error while initiating KYC', data);
this.$notify({
message: 'Something went wrong. Please, start again',
title: '',
});
this.$emit('confirm-kyc', false);
unloadScript(kycService.sdkURL);
}
}
async mounted(): Promise<void> {
Expand Down
14 changes: 8 additions & 6 deletions src/store/soraCard/actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { defineActions } from 'direct-vuex';
import { api } from '@soramitsu/soraneo-wallet-web';
import { api, WALLET_CONSTS } from '@soramitsu/soraneo-wallet-web';
import { FPNumber } from '@sora-substrate/util';

import { waitForAccountPair } from '@/utils';
import { defineUserStatus, getXorPerEuroRatio } from '@/utils/card';
import { defineUserStatus, getXorPerEuroRatio, soraCard } from '@/utils/card';
import { soraCardActionContext } from './../soraCard';
import { Status } from '@/types/card';
import { loadScript } from 'vue-plugin-load-script';
Expand Down Expand Up @@ -66,15 +66,17 @@ const actions = defineActions({
},

async initPayWingsAuthSdk(context): Promise<void> {
const { commit } = soraCardActionContext(context);
const { commit, rootState } = soraCardActionContext(context);
const soraNetwork = rootState.wallet.settings.soraNetwork || WALLET_CONSTS.SoraNetwork.Test;
const { authService } = soraCard(soraNetwork);

await loadScript('https://auth-test.soracard.com/WebSDK/WebSDK.js').then(() => {
await loadScript(authService.sdkURL).then(() => {
// TODO: annotate via TS main calls
// @ts-expect-error no undefined
const login = Paywings.WebSDK.create({
Domain: 'soracard.com',
UnifiedLoginApiKey: '6974528a-ee11-4509-b549-a8d02c1aec0d',
env: 'Test',
UnifiedLoginApiKey: authService.apiKey,
env: authService.env,
AccessTokenTypeID: 1,
UserTypeID: 2,
ClientDescription: 'Auth',
Expand Down
6 changes: 3 additions & 3 deletions src/utils/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ const emptyStatusFields = (): Status => ({
export function soraCard(soraNetwork: string) {
const getAuthServiceData = (soraNetwork: string) => {
const test = {
sdkURL: 'https://auth-test.paywings.io/auth/sdk.js',
authURL: 'https://auth-test.soracard.com',
sdkURL: 'https://auth-test.soracard.com/WebSDK/WebSDK.js',
apiKey: '6974528a-ee11-4509-b549-a8d02c1aec0d',
env: WALLET_CONSTS.SoraNetwork.Test,
};

const prod = {
sdkURL: '',
authURL: '',
apiKey: '',
env: WALLET_CONSTS.SoraNetwork.Prod,
};

return soraNetwork === WALLET_CONSTS.SoraNetwork.Prod ? prod : test;
Expand Down

0 comments on commit 4234a70

Please sign in to comment.