[Apple Pay]how to update multiTokenContexts when PKPaymentRequestShippingContactUpdate method trigger

multiTokenContexts is defined as follows (https://developer.apple.com/documentation/passkit/pkpaymentrequest/multitokencontexts) You can assign a value when initializing PKPaymentRequest (https://developer.apple.com/documentation/passkit/pkpaymentrequest). However, in actual usage scenarios, when the Apple Pay address changes and PKPaymentRequestShippingContactUpdate (https://developer.apple.com/documentation/passkit/pkpaymentrequestshippingcontactupdate) is triggered, how to update multiTokenContexts? The documentation and code do not provide updates for this parameter.

In contrast, Apple Pay on the Web provides newMultiTokenContexts as an update when ApplePayShippingContactUpdate (https://developer.apple.com/documentation/apple_pay_on_the_web/applepayshippingcontactupdate) is triggered.

Has anyone encountered this problem? Would you happen to have any solutions? Thank you.

Answered by AikenWu in 821381022

I solved this problem and recorded it here so that other people who need it can use it as a solution. First, you need to specify the initialized multiTokenContexts in the initialization. Then, because PKPaymentRequestShippingContact inherits PKPaymentRequestUpdate, because PKPaymentRequestUpdate has a multiTokenContexts public property. So we can manually change the multiTokenContexts property directly before updating the ShippingContact method init. In this way, even if the updated method does not provide a multiTokenContexts parameter update, it can recognize the updated multiTokenContexts.

Accepted Answer

I solved this problem and recorded it here so that other people who need it can use it as a solution. First, you need to specify the initialized multiTokenContexts in the initialization. Then, because PKPaymentRequestShippingContact inherits PKPaymentRequestUpdate, because PKPaymentRequestUpdate has a multiTokenContexts public property. So we can manually change the multiTokenContexts property directly before updating the ShippingContact method init. In this way, even if the updated method does not provide a multiTokenContexts parameter update, it can recognize the updated multiTokenContexts.

Great, but why did you post it three times?

[Apple Pay]how to update multiTokenContexts when PKPaymentRequestShippingContactUpdate method trigger
 
 
Q