PaymentRequest TypeError

Details at Stack Overflow

We're trying to enable Apple Pay on the Web for a web application of ours, but getting this error when trying to construct the PaymentRequest object:

TypeError: Type error: PaymentRequest@[native code] startApplePay@https:-myurl-:319:47 onclick@https://-myurl-:606:14:undefined

Answered by dougbkyndryl in 793769022

For completeness/posterity, also added to StackOverflow:

The annoyingly tiny answer was that the first argument to the PaymentRequest constructor is supposed to be an array.

const request = new PaymentRequest([ applePayMethod ], paymentDetails);

(Or, make the variable an array from the start. The two examples I'd seen used different approaches, I missed the array brackets.)

Accepted Answer

For completeness/posterity, also added to StackOverflow:

The annoyingly tiny answer was that the first argument to the PaymentRequest constructor is supposed to be an array.

const request = new PaymentRequest([ applePayMethod ], paymentDetails);

(Or, make the variable an array from the start. The two examples I'd seen used different approaches, I missed the array brackets.)

PaymentRequest TypeError
 
 
Q