Bug 220566 - Payment Request API - response.shippingOption is always null
Summary: Payment Request API - response.shippingOption is always null
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: Safari 14
Hardware: Mac (Intel) macOS 10.15
: P2 Normal
Assignee: Devin Rousso
Keywords: InRadar
Depends on:
Reported: 2021-01-12 13:50 PST by nickgzzjr
Modified: 2021-02-16 06:34 PST (History)
6 users (show)

See Also:

Patch (43.73 KB, patch)
2021-01-20 13:47 PST, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description nickgzzjr 2021-01-12 13:50:40 PST
The shippingOption in the response that is resolved from the promise returned when calling request.show() is always null.

I expect the shippingOption to show the user's selected shipping method. 

I am only able to see the shippingOption inside the onshippingoptionchange event handler.

Code Example:

const request = new PaymentRequest(...);

request.onshippingoptionchange = event => {
  request.shippingOption; // not null

const response = await request.show();

response.shippingOption; // null
request.shippingOption; // null
Comment 1 Radar WebKit Bug Importer 2021-01-14 10:10:06 PST
Comment 2 Devin Rousso 2021-01-14 15:53:21 PST
Are you providing `requestShipping` (part of the optional `options` 3rd argument) when constructing the `PaymentRequest`?  `shippingOption` (and `shippingAddress`) are only populated if you do.
Comment 3 nickgzzjr 2021-01-15 10:47:00 PST
Yes I am providing requestShipping: true. I can confirm this because I am seeing the shippingOption inside the onshippingoptionchange event handler.
Comment 4 Devin Rousso 2021-01-20 13:47:37 PST
Created attachment 417993 [details]
Comment 5 EWS 2021-01-21 11:37:57 PST
Committed r271703: <https://trac.webkit.org/changeset/271703>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 417993 [details].
Comment 6 Truitt Savell 2021-01-22 10:38:39 PST
The new test http/tests/paymentrequest/updateWith-modifiers.https.html 

is crashing 


No crash log found for com.apple.WebKit.WebContent.Development:3178.


./Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp(586) : virtual void WebCore::ApplePayPaymentHandler::didAuthorizePayment(const WebCore::Payment &)
1   0x773794e69 WTFCrash
2   0x74fde6a3b WTFCrashWithInfo(int, char const*, char const*, int)
3   0x751ad8ca8 WebCore::ApplePayPaymentHandler::didAuthorizePayment(WebCore::Payment const&)
4   0x751a93cc5 WebCore::PaymentCoordinator::didAuthorizePayment(WebCore::Payment const&)
5   0x77f205862 WebCore::MockPaymentCoordinator::acceptPayment()::$_7::operator()()
6   0x77f20571e WTF::Detail::CallableWrapper<WebCore::MockPaymentCoordinator::acceptPayment()::$_7, void>::call()
7   0x77f1bf482 WTF::Function<void ()>::operator()() const
8   0x77f1faf1e WebCore::dispatchIfShowing(WTF::Function<void ()>&&)::$_9::operator()() const
9   0x77f1fae2e WTF::Detail::CallableWrapper<WebCore::dispatchIfShowing(WTF::Function<void ()>&&)::$_9, void>::call()
10  0x7737c1082 WTF::Function<void ()>::operator()() const
11  0x773843585 WTF::RunLoop::performWork()
12  0x773847e21 WTF::RunLoop::performWork(void*)
14  0x7fff2046b974 __CFRunLoopDoSource0
15  0x7fff2046b6ef __CFRunLoopDoSources0
16  0x7fff2046a121 __CFRunLoopRun
17  0x7fff204696ce CFRunLoopRunSpecific
18  0x7fff211f6fa1 -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
19  0x7fff21285384 -[NSRunLoop(NSRunLoop) run]
20  0x7fff200c03dd _xpc_objc_main
21  0x7fff200bfe65 _xpc_copy_xpcservice_dictionary
22  0x740d1ebcc WebKit::XPCServiceMain(int, char const**)
23  0x74227eacb WKXPCServiceMain
24  0x1062edea2 main
25  0x7fff2038e621 start
LEAK: 1 WebPageProxy
Comment 7 Devin Rousso 2021-01-22 11:12:39 PST
Fixed in r271752.