Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the request to error response for apple pay validate #201

Merged
merged 4 commits into from
Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions server-middleware/apiApplePay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,45 @@ app.post('/validate', (req, res) => {
req.on('data', (data) => {
// data is in byte array so first transform it to string and then parse it to object, and then take it's property appleUrl
const { appleUrl, merchantType } = JSON.parse(data.toString())
const cert =
merchantType === 'PayFac'
? payfacMerchantIdentityCertificate
: partnershipMerchantIdentityCertificate // pem apple cert
const key =
merchantType === 'PayFac'
? payfacMerchantIdentityKey
: partnershipMerchantIdentityKey

const httpsAgent = new https.Agent({
rejectUnauthorized: false,
cert:
merchantType === 'PayFac'
? payfacMerchantIdentityCertificate
: partnershipMerchantIdentityCertificate, // pem apple cert
key:
merchantType === 'PayFac'
? payfacMerchantIdentityKey
: partnershipMerchantIdentityKey, // key apple
cert,
key,
})
const requestData = {
merchantIdentifier:
merchantType === 'PayFac' ? payfacMerchantId : partnershipMerchantId,
domainName,
displayName: DISPLAY_NAME,
}
axios
.post(
appleUrl,
{
merchantIdentifier:
merchantType === 'PayFac'
? payfacMerchantId
: partnershipMerchantId,
domainName,
displayName: DISPLAY_NAME,
},
{
httpsAgent,
}
)
.post(appleUrl, requestData, {
httpsAgent,
})
.then((a) => {
// return the json received from Apple Pay server unmodified
res.send(a.data)
})
.catch((a) => {
res.send({
message: a.message,
errorMessage: a.message,
Copy link
Contributor

@antiv0 antiv0 Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i d say send ALL (checksum of cert/key), applePayUrl, every possible detail and compare

if this is not due to domain verification revoked then it is down to SOMETHING being off, so better to verify all

request: requestData,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change make sensitive data like keys/certificates available?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only makes the merchant identifier, domain name, and display name available, all of which were previously hard coded into the file

merchantType,
responseStatus: a.response.status,
responseData: a.response.data,
responseHeaders: a.response.headers,
appleUrl,
displayName: DISPLAY_NAME,
domainName,
})
})
})
Expand Down