I am integrating the apple pay and following the payment request API! According to the documentation (https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/requesting_an_apple_pay_payment_session)
cert: merchIdentityCert and key: merchIdentityCert both are the same. I append my merchantIdentityCertificate.pem to both cert and key.
But, Unable to get any response from the apple pay servers. After my request it is throwing an error and safari is displaying a message as “This resource came from a local override”
Code:
const merchIdentityCert = fs.readFileSync("./merchIdentityCert.pem")
const httpsAgent = new https.Agent({
cert: merchIdentityCert,
key: merchIdentityCert,
maxVersion: "TLSv1.2",
minVersion: "TLSv1.2"
})
const post = (url, body) => {
logger.info({ message: "apple pay START", url, body })
fetch(url, {
body: JSON.stringify(body),
method: "POST",
agent: httpsAgent
}).then(resp => {
logger.info({ message: "apple pay SUCCESS", resp })
return resp
}).catch((error) => {
logger.info({ message: "apple pay ERROR", error })
return error
})
}
Logs:
message: "apple pay START", url: "https://-pay-gateway-cert.apple.com/paymentservices/startSession", body: {"merchantIdentifier":"..","displayName":"Test Pay","initiative":"web","initiativeContext":"--**.***."}
message: "apple pay ERROR", error: {}*
I am using a node-fetch library. My web app and node app deployed in AWS servers. I have fulfilled server setup and environment setup requirements with certificates. [https://developer.apple.com/documentation/apple_pay_on_the_web/setting_up_your_server]
Does anyone have an idea about this?
Able to resolve the {"size":0,"timeout":0} issue and it is related to node fetch library. I fixed it from my code level. (Node-fetch problems with POST requests, https://www.npmjs.com/package/node-fetch)
Apart from that, I used the below request to debug using the remote server, and It was giving the session object to me.
my code: