Skip to content

Commit

Permalink
Fix for CS-8814
Browse files Browse the repository at this point in the history
CX version 0.1.25
  • Loading branch information
pkumar-strivve committed Nov 11, 2024
1 parent 0c99d85 commit 96005a0
Show file tree
Hide file tree
Showing 9 changed files with 5,961 additions and 5,578 deletions.
11,497 changes: 5,933 additions & 5,564 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@strivve/strivve-cx",
"version": "0.1.24",
"version": "0.1.25",
"private": false,
"main": "dist/main.js",
"module": "dist/index.js",
Expand Down
11 changes: 9 additions & 2 deletions public/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/component/__tests__/SelectSiteView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class Service implements StrivveServiceInterface {
return Promise.resolve();
}

createCardholderQuery(id: string) {
getCardholderQuery(id: string) {
return Promise.resolve();
}

Expand Down
2 changes: 1 addition & 1 deletion src/component/__tests__/component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ErrorService implements StrivveServiceInterface {
return Promise.resolve();
}

createCardholderQuery(id: string) {
getCardholderQuery(id: string) {
return Promise.resolve();
}

Expand Down
2 changes: 1 addition & 1 deletion src/component/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class StrivveService implements StrivveServiceInterface {
});
}

createCardholderQuery(id: string): any {
getCardholderQuery(id: string): any {
const query: any = {
callbacks: {},
addListener: (id: string, func: any, status: string) => {
Expand Down
10 changes: 5 additions & 5 deletions src/core/accountLinkCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,18 @@ export default class AccountLinkCore {
}

createQuery(job: any) {
const query = this.service.createCardholderQuery(job.cardholder_id);
const query = this.service.getCardholderQuery(job.cardholder_id);
const statusHandler = (data: any) => {
const message = data.message || data.error_message;
this.onMessage?.(data.job_id, message);

const isComplete = message.auth_percent_complete === 100;
const isAuthComplete = message.auth_percent_complete === 100;
const percent =
this.state.percent > message.auth_percent_complete
? this.state.percent
: message.auth_percent_complete;

if (message?.termination_type || data?.type === 'error' || isComplete) {
if (message?.termination_type || data?.type === 'error' || isAuthComplete) {
if (failedStatus.includes(message?.termination_type)) {
this.updateState({
percent,
Expand All @@ -271,7 +271,7 @@ export default class AccountLinkCore {

if ( message?.percent_complete === 100 || message?.termination_type ) {
console.log("**********************************");
console.log("Removing listeners (statusHandler)");
console.log(`Removing listeners (statusHandler) for job ID = ${job.id}`);
query.removeListeners(job.id);
console.log("**********************************");
}
Expand Down Expand Up @@ -313,7 +313,7 @@ export default class AccountLinkCore {

if ( message?.percent_complete === 100 || message?.termination_type ) {
console.log("**********************************");
console.log("Removing listeners");
console.log(`Removing listeners (pendingHandler) for job ID = ${job.id}`);
query.removeListeners(job.id);
console.log("**********************************");
}
Expand Down
11 changes: 9 additions & 2 deletions src/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class StrivveService implements StrivveServiceInterface {
public fi_detail?: any;
queue_name_override?: string;
public cardholder?: any;
cardholder_query?: CardholderQuery;

constructor({
api_instance,
Expand Down Expand Up @@ -221,8 +222,14 @@ class StrivveService implements StrivveServiceInterface {
return session?.authorizeCardholder(grant);
}

createCardholderQuery(job_id: string): CardholderQuery {
return this.ch.createCardholderQuery(this.username, Number(job_id));
getCardholderQuery(job_id: string): CardholderQuery {
if ( !this.cardholder_query ) {
console.log("Creating new cardholder query");
this.cardholder_query = this.ch.createCardholderQuery(this.username, Number(job_id));
} else {
console.log("Reusing cardholder query");
}
return this.cardholder_query;
}

postCreds(body: PostCredsBody) {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export interface StrivveServiceInterface {
StrivveResponse<{ cardholder_safe_key: string; cardholder: Cardholder }>
>;
getMissingCardDataFields(card_id: string, selected_sites: MerchantSite[]): Promise<string[]>;
createCardholderQuery(id: string): any;
getCardholderQuery(id: string): any;
postCreds(body: PostCredsBody): Promise<any>;
setSafeKey(key: string): void;
cancelJob(job_id: number): any;
Expand Down

0 comments on commit 96005a0

Please sign in to comment.