"404: Invalid URI -- no content" on merchant verification

Hi,

in the node.js server I got validation url from client and then post request to this url:


const { validationURL } = req.body;
    const cert = fs.readFileSync(certPath);
    const key = fs.readFileSync(keyPath);
    const options = {
      url: `${validationURL}/paymentSession`,
      method: 'POST', 
      "headers": {
        "Content-Type": "application/json",
      },
      key,
      cert,
      body:{
        merchantIdentifier: 'merchant.domain.name', // from developer panel
        displayName: 'ProjectName',
        initiative: 'web',
        initiativeContext: 'domain.name', // verified from developer panel
      },
      json: true,
    };
    
    let response = '';
    request.post(options, function (error, response, body) {
      console.log('inner error:', error); 
      console.log('inner statusCode:', response && response.statusCode); 
      console.log('inner body:', body); 
    }).on('error', function(err) {
      console.log(err)
    });


And I keep getting

inner error: null
inner statusCode: 404
inner body: Invalid URI -- no content


What may go wrong?

It's about url or body payload?

I form url according to https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/requesting_an_apple_pay_payment_session


Endpoint: https://{validation URL}/paymentSession
For Apple Pay on the web, use the fully qualified validation URL received in onvalidatemerchant.

request looks like this:


{ uri: 'https://apple-pay-gateway-pr-pod3.apple.com/paymentservices/startSession/paymentSession',
  method: 'POST',
  key: ,
  cert: ,
  body:
   { merchantIdentifier: 'merchant.domain.name',
     displayName: 'ProjectName',
     initiative: 'web',
     initiativeContext: 'domain.name' },
  json: true }


Any ideas?

With all best regards.

Replies

Hi, silentimp!

Do you resolve the problem? I catch the same error and I don't know how to fix it.

I also stumbled across same problem while following the documentation. The solution is simply don't add /paymentSession to validation URL. Just use the given validation URL without any modification.