Skip to content

Commit bb62853

Browse files
authored
Merge branch 'feature/DTPPCPSDK-2660-3ds-eligibility' into feature/DTPPCPSDK-2662-show
2 parents bb9ad0d + 1fa80ab commit bb62853

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

Diff for: src/three-domain-secure/component.jsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,9 @@ const parseMerchantPayload = ({
3737
}: {|
3838
merchantPayload: MerchantPayloadData,
3939
|}): requestData => {
40-
// what validation on merchant input should we do here?
41-
// empty object
4240
const { threeDSRequested, amount, currency, nonce, transactionContext } =
4341
merchantPayload;
44-
// amount - validate that it's a string
45-
// currency - validate that it's a string
46-
// what validations are done on the API end - what client side validation is the API expecting
42+
4743
return {
4844
intent: "THREE_DS_VERIFICATION",
4945
payment_source: {
@@ -98,6 +94,7 @@ export class ThreeDomainSecureComponent {
9894
});
9995

10096
let responseStatus = false;
97+
10198
if (status === "PAYER_ACTION_REQUIRED") {
10299
this.authenticationURL = links.find(
103100
(link) => link.rel === "payer-action"

Diff for: src/three-domain-secure/component.test.js

+39-3
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,48 @@ describe("three domain secure component - isEligible method", () => {
6868
expect(eligibility).toEqual(false);
6969
});
7070

71-
test.todo("create payload with correctly parameters", async () => {
72-
const threeDomainSecureClient = createThreeDomainSecureComponent();
71+
test("should assign correct URL to authenticationURL", async () => {
72+
const threeDomainSecureClient = createThreeDomainSecureComponent({
73+
request: () =>
74+
Promise.resolve({
75+
...defaultEligibilityResponse,
76+
links: [
77+
{ href: "https://not-payer-action.com", rel: "not-payer-action" },
78+
...defaultEligibilityResponse.links,
79+
],
80+
}),
81+
});
82+
await threeDomainSecureClient.isEligible(defaultMerchantPayload);
83+
expect(threeDomainSecureClient.authenticationURL).toEqual(
84+
"https://testurl.com"
85+
);
86+
});
87+
88+
test("create payload with correctly parameters", async () => {
7389
const mockedRequest = mockEligibilityRequest();
90+
const threeDomainSecureClient = createThreeDomainSecureComponent({
91+
request: mockedRequest,
92+
});
93+
7494
await threeDomainSecureClient.isEligible(defaultMerchantPayload);
7595

76-
expect(mockedRequest).toHaveBeenCalledWith();
96+
expect(mockedRequest).toHaveBeenCalledWith(
97+
expect.objectContaining({
98+
data: expect.objectContaining({
99+
intent: "THREE_DS_VERIFICATION",
100+
payment_source: expect.objectContaining({
101+
card: expect.objectContaining({
102+
single_use_token: defaultMerchantPayload.nonce,
103+
verification_method: "SCA_WHEN_REQUIRED",
104+
}),
105+
}),
106+
amount: expect.objectContaining({
107+
currency_code: defaultMerchantPayload.currency,
108+
value: defaultMerchantPayload.amount,
109+
}),
110+
}),
111+
})
112+
);
77113
});
78114

79115
test("catch errors from the API", async () => {

0 commit comments

Comments
 (0)