Skip to content

Commit

Permalink
call eligibility api with an lsat
Browse files Browse the repository at this point in the history
  • Loading branch information
siddy2181 committed Dec 2, 2024
1 parent ecd5ac1 commit bb81b0b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions dist/button.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions dist/test/button.js

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions src/three-domain-secure/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { type LoggerType } from "@krakenjs/beaver-logger/src";
import { ZalgoPromise } from "@krakenjs/zalgo-promise/src";
import { FPTI_KEY } from "@paypal/sdk-constants/src";
import { createAccessToken } from "@paypal/sdk-client/src";

import { ValidationError } from "../lib";

Expand Down Expand Up @@ -92,20 +93,24 @@ export class ThreeDomainSecureComponent {
this.restClient = restClient;
this.graphQLClient = graphQLClient;
this.sdkConfig = parseSdkConfig({ sdkConfig, logger });

if (this.sdkConfig.authenticationToken) {
this.restClient.setAccessToken(this.sdkConfig.authenticationToken);
}
}

async isEligible(merchantPayload: MerchantPayloadData): Promise<boolean> {
// eslint-disable-next-line no-console
console.log("Entered IsEligible");

const data = parseMerchantPayload({ merchantPayload });
const idToken = merchantPayload.idToken;
this.fastlaneNonce = merchantPayload.nonce;

try {
const accessToken = await createAccessToken(this.sdkConfig.clientID);
// $FlowIssue confusing ZalgoPromise return type with resolved string value
this.restClient.setAccessToken(accessToken);
} catch (error) {
this.logger.warn(error);
throw error;
}

try {
// $FlowFixMe
const { status, links } = await this.restClient.request<
Expand All @@ -115,7 +120,6 @@ export class ThreeDomainSecureComponent {
method: "POST",
baseURL: `${this.sdkConfig.paypalApiDomain}/v2/payments/payment`,
data,
accessToken: idToken, // this.sdkConfig.authenticationToken,
});

let responseStatus = false;
Expand Down
2 changes: 2 additions & 0 deletions src/three-domain-secure/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getLogger,
getPayPalAPIDomain,
getSDKToken,
getClientID,
} from "@paypal/sdk-client/src";

import type { LazyExport } from "../types";
Expand Down Expand Up @@ -32,6 +33,7 @@ export const ThreeDomainSecureClient: LazyExport<ThreeDomainSecureComponentInter
sdkConfig: {
authenticationToken: getSDKToken(),
paypalApiDomain: getPayPalAPIDomain(),
clientID: getClientID(),
},
});
return {
Expand Down
1 change: 1 addition & 0 deletions src/three-domain-secure/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type responseBody = {|
export type SdkConfig = {|
authenticationToken: ?string,
paypalApiDomain: string,
clientID: string,
|};

export type threeDSResponse = {|
Expand Down

0 comments on commit bb81b0b

Please sign in to comment.