Hello, I'm trying to make changes to my website's apple pay flow and an unable to verify if the flow works because I get the following error in the console when trying to pay:
TypeError: undefined is not an object (evaluating 'applePaySession.completeMerchantValidation')
By following this error message, I try to setup an ngrok proxy to verify my local development domain and that fails as well even though as you can see, the file does actually exist.
Can anyone help with A) giving me a different way to develop locally aka having a "successful" apple pay payment so I can verify my website's flow after payment or B) help me figure out why the domain verification is failing. Thanks!
Hi @cocomishra,
You wrote:
[...] TypeError: undefined is not an object (evaluating 'applePaySession.completeMerchantValidation') [...] By following this error message, I try to setup an ngrok proxy to verify my local development domain and that fails as well even though as you can see, the file does actually exist. [...]
The type error above may be unrelated to your merchant domain validation file, and both may have different underlying causes. The error:
TypeError: undefined is not an object (evaluating 'applePaySession.completeMerchantValidation')
This means the applePaySession is undefined at the point the callback fires. This is typically a scoping or session creation issue, not an ngrok issue. For example:
- Session variable is out of scope: The most frequent cause is that the
ApplePaySessionobject is declared inside a block and is not accessible in theonvalidatemerchantcallback. - Session was never created successfully: If
new ApplePaySession()throws or returnsundefined, all subsequent calls on it will produce this error. Guard against this in your logic with console logs to help surface this error while debugging. - Merchant validation response is malformed: Even if the session exists, if the merchant session payload returned from your server is incorrect,
completeMerchantValidationwill fail. Make sure your server passes back the raw, unparsed JSON from Apple's servers.
Now, to the potential merchant domain verification issue. Please see the following technote for more information:
TN3173: Troubleshooting issues with your Apple Pay merchant identifier configuration
Cheers,
Paris X Pinkney | WWDR | DTS Engineer