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:
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?
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.
Code Block 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:
Code Block 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?
merchIdentityCert is added to both of the cert and key fields in the example but these values are not meant to be the same. For example, a Merchant Identity is a p12, or a PKCS12 that contains the Merchant Certificate and a Private Key that was created when you generated a CSR to request your Merchant Certificate. This is a Merchant Identity. Knowing that, you can use the key and the certificate in the way that is being displayed if you have a PEM file that contains both assets. You can also use this file with other server side APIs, but the goal of using a Merchant Identity is to identify yourself as a Merchant and perform client authentication.According to the documentation
cert: merchIdentityCert and key: merchIdentityCert both are the same
As for your issue it is very strange that you would not be able to get a response from the servers at all. I would check that you are using the correct URL and request Payload.
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com