Skip to content

Commit a8813a5

Browse files
committed
[INTER-3577] Fix undefined shipping address issue
1 parent 9918b1d commit a8813a5

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/fastlane/fastlane.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default class Fastlane {
8282
profileData: {
8383
card: resp.profileData.card,
8484
name: resp.profileData.name,
85-
shippingAddress: this.transformPaypalAddress(paypalAddress),
85+
shippingAddress: paypalAddress === undefined ? undefined : this.transformPaypalAddress(paypalAddress),
8686
},
8787
};
8888
}

src/types/fastlane.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export interface IFastlaneAuthenticatedCustomerResult {
7474
firstName: string;
7575
lastName: string;
7676
};
77-
shippingAddress: IFastlaneAddress;
77+
shippingAddress: IFastlaneAddress | undefined;
7878
card: IFastlanePaymentToken;
7979
}
8080
}

tests/fastlane/fastlane.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Fastlane from 'src/fastlane/fastlane';
2+
import { IFastlaneAuthenticatedCustomerResult } from 'src';
23

34
describe('testing Fastlane class', () => {
45
const fastlaneInstanceMock = {
@@ -91,6 +92,7 @@ describe('testing Fastlane class', () => {
9192

9293
test.each([
9394
{
95+
name: 'ppcp',
9496
type: 'ppcp',
9597
respProfileData: {
9698
card: {},
@@ -133,6 +135,20 @@ describe('testing Fastlane class', () => {
133135
}),
134136
} as const,
135137
{
138+
name: 'ppcp - no shipping address',
139+
type: 'ppcp',
140+
respProfileData: {
141+
card: {},
142+
name: {
143+
firstName: 'firstName',
144+
lastName: 'firstName',
145+
},
146+
shippingAddress: undefined,
147+
},
148+
expected: (): IFastlaneAuthenticatedCustomerResult['profileData']['shippingAddress'] => undefined,
149+
} as const,
150+
{
151+
name: 'braintree',
136152
type: 'braintree',
137153
respProfileData: {
138154
card: {},
@@ -157,7 +173,7 @@ describe('testing Fastlane class', () => {
157173
return this.respProfileData.shippingAddress;
158174
},
159175
} as const,
160-
])('$type triggerAuthenticationFlow', async (input) => {
176+
])('$name triggerAuthenticationFlow', async (input) => {
161177
// Arranging
162178
fastlaneInstanceMock.identity.triggerAuthenticationFlow.mockResolvedValue({
163179
authenticationState: 'succeeded',

0 commit comments

Comments
 (0)