-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(applepay): interface changes and error message changes (#2)
- Loading branch information
rsimhadri
authored and
GitHub Enterprise
committed
Oct 17, 2022
1 parent
bd0e8a5
commit 02fa580
Showing
7 changed files
with
344 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* @flow */ | ||
|
||
|
||
import { getMerchantDomain, getCurrency, getPayPalHost, getCreateOrderPayLoad, mapGetConfigResponse } from '../util'; | ||
|
||
|
||
global.window = Object.create(window); | ||
|
||
const url = 'http://checkout.com'; | ||
Object.defineProperty(window, 'location', { | ||
value: { | ||
origin: url, | ||
search: '?customDomain=\'testenv.qa.paypal.com\'' | ||
} | ||
}); | ||
|
||
jest.mock('@paypal/sdk-client/src', () => ({ | ||
getPayPalAPIDomain: () => 'https://paypal.com', | ||
getMerchantID: () => 'HZZ2RQHJM4CE6', | ||
getBuyerCountry: () => 'US', | ||
getSDKQueryParam: (param) => { | ||
if (param === 'currency') { | ||
return 'USD'; | ||
} | ||
|
||
return ''; | ||
} | ||
})); | ||
|
||
describe('util', () => { | ||
describe('should return merchant domain', () => { | ||
it('validate getMerchantDomain', () => { | ||
const domain = getMerchantDomain(); | ||
expect(domain).toBe('checkout.com'); | ||
}); | ||
}); | ||
|
||
describe('getCurrency', () => { | ||
it('Should return USD by default', () => { | ||
expect(getCurrency()).toBe('USD'); | ||
}); | ||
}); | ||
|
||
describe('getPayPalHost', () => { | ||
it('should return \'paypal.com\'', () => { | ||
expect(getPayPalHost()).toBe('paypal.com'); | ||
}); | ||
}); | ||
|
||
describe('getCreateOrderPayLoad', () => { | ||
it('should create order with capture Intent and default payee Information', () => { | ||
const requestPayLoad = { | ||
purchase_units: [ | ||
{ | ||
amount: { | ||
currency_code: 'USD', | ||
value: '0.99' | ||
} | ||
} | ||
] | ||
}; | ||
expect(getCreateOrderPayLoad(requestPayLoad)).toStrictEqual({ | ||
intent: 'CAPTURE', | ||
purchase_units: [ | ||
{ | ||
amount: { | ||
currency_code: 'USD', | ||
value: '0.99' | ||
}, | ||
payee: { | ||
merchant_id: 'HZZ2RQHJM4CE6' | ||
} | ||
} | ||
], | ||
payer: undefined, | ||
application_context: undefined | ||
}); | ||
}); | ||
|
||
it('should create order with passed in information', () => { | ||
const requestPayLoad = { | ||
intent: 'AUTHORIZE', | ||
purchase_units: [ | ||
{ | ||
amount: { | ||
currency_code: 'USD', | ||
value: '0.99' | ||
} | ||
} | ||
] | ||
}; | ||
expect(getCreateOrderPayLoad(requestPayLoad)).toStrictEqual({ | ||
intent: 'AUTHORIZE', | ||
purchase_units: [ | ||
{ | ||
amount: { | ||
currency_code: 'USD', | ||
value: '0.99' | ||
}, | ||
payee: { | ||
merchant_id: 'HZZ2RQHJM4CE6' | ||
} | ||
} | ||
], | ||
payer: undefined, | ||
application_context: undefined | ||
}); | ||
}); | ||
}); | ||
|
||
describe('mapGetConfigResponse', () => { | ||
it('should return config data mapped as per client api spec', () => { | ||
const requestPayLoad = { | ||
'merchantCountry': 'US', | ||
'supportedNetworks': [ | ||
'masterCard', | ||
'discover', | ||
'visa', | ||
'amex' | ||
], | ||
'isEligible': true, | ||
'merchantCapabilities': [ | ||
'supports3DS', | ||
'supportsCredit', | ||
'supportsDebit' | ||
] | ||
}; | ||
|
||
expect(mapGetConfigResponse(requestPayLoad)).toStrictEqual({ | ||
'merchantCountry': 'US', | ||
'countryCode': 'US', | ||
'currencyCode': 'USD', | ||
'supportedNetworks': [ | ||
'masterCard', | ||
'discover', | ||
'visa', | ||
'amex' | ||
], | ||
'isEligible': true, | ||
'merchantCapabilities': [ | ||
'supports3DS', | ||
'supportsCredit', | ||
'supportsDebit' | ||
] | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.