Skip to content

Commit

Permalink
include all fields in return object (for debugging)
Browse files Browse the repository at this point in the history
  • Loading branch information
elizalucas committed Mar 22, 2022
1 parent d47b213 commit d2b110f
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions server-middleware/apiApplePay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
payfacMerchantId,
} from './applePaySettings'
import { apiHostname, domainName } from './serverEnv'
import { encoding } from 'openpgp'
import getCheckSum = encoding.armor.getCheckSum

const app = express()
const DISPLAY_NAME = 'Circle Apple Pay'
Expand All @@ -25,17 +27,19 @@ 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:
Expand All @@ -55,9 +59,14 @@ app.post('/validate', (req, res) => {
res.send({
errorMessage: a.message,
request: requestData,
merchantType,
responseStatus: a.response.status,
responseData: a.response.data,
responseHeaders: a.response.headers,
checksumCert: getCheckSum(cert),
checksumKey: getCheckSum(key),
appleUrl,
displayName: DISPLAY_NAME,
})
})
})
Expand Down

0 comments on commit d2b110f

Please sign in to comment.