iosapplepayapplepayjs

Receiving Type Error when calling completeValidateMerchant in Apple Pay


We are trying to add Apple Pay to our existing web site. I have the payment sheet popping up, and am seeing the call to onvalidatemerchant which in turn calls our server that returns what looks to be a valid Merchant Session object, but when I call completeMerchantValidation with the object I get a Type Error with no other information.

Has anyone come across this and found a way to resolve the error. I am testing on an iPad Mini with iOS 10.2.1.


Solution

  • Solution posted here in-case someone else has a similar problem.

    It turns out that you need to pass a JavaScript object to completeMerchantValidation. It turned out I was passing a JSON string to completeMerchantValidation and needed to convert it to an object by using JSON.parse(response.data.Result); then things started working as expected.