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.
const options= {
url: endpointURL,
cert: merchIdentityCert,
key: merchIdentityCert,
method: 'post',
body:{
merchantIdentifier: "merchant.com.example.mystore",
displayName: "MyStore",
initiative: "web",
initiativeContext: "mystore.example.com"
},
json: true,
}
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?