KEMBAR78
passing data on complete() by marcoscaceres · Pull Request #982 · w3c/payment-request · GitHub
Skip to content

Conversation

marcoscaceres
Copy link
Member

@marcoscaceres marcoscaceres commented Jan 19, 2022

closes #981

The following tasks have been completed:

  • Modified Web platform tests (link)

Implementation commitment:

  • WebKit (link to issue)
  • Chromium (link to issue)
  • Gecko (link to issue)

Optional, impact on Payment Handler spec?


Preview | Diff

@marcoscaceres marcoscaceres marked this pull request as ready for review January 20, 2022 00:45
@marcoscaceres
Copy link
Member Author

@dcrousso, ok... we now do IDL conversion and member validation early, giving the developer an opportunity to recover. And the [[\complete]] = true now happens after the checks.

webkit-commit-queue pushed a commit to WebKit/WebKit that referenced this pull request Jan 27, 2022
… passed to `complete()`

https://bugs.webkit.org/show_bug.cgi?id=235415
<rdar://problem/82970451>

Reviewed by Darin Adler.

Source/WebCore:

This allows for developers/merchants to give additional details to Apple Pay on completion.

Issue: <w3c/payment-request#981>
Spec PR: <w3c/payment-request#982>

Test: http/tests/paymentrequest/ApplePayPaymentCompleteDetails.https.html

* Modules/paymentrequest/PaymentCompleteDetails.h: Added.
* Modules/paymentrequest/PaymentCompleteDetails.idl: Added.
* Modules/paymentrequest/PaymentResponse.h:
* Modules/paymentrequest/PaymentResponse.idl:
* Modules/paymentrequest/PaymentResponse.cpp:
(WebCore::PaymentResponse::complete):
* Modules/paymentrequest/PaymentRequest.h:
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::complete):
* Modules/paymentrequest/PaymentHandler.h:
Add new `dictionary PaymentCompleteDetails` that's allowed as an optional second argument to
`PaymentResponse.prototype.complete`. If provided, JSON stringify it and pass the serialized
string data along to the relevant `PaymentHandler` for JSON (re)parsing if the associated
payment method requires it.

* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::convertAndValidate):
(WebCore::merge):
(WebCore::ApplePayPaymentHandler::complete):
(WebCore::ApplePayPaymentHandler::retry):
* Modules/applepay/paymentrequest/ApplePayPaymentCompleteDetails.idl: Added.
* Modules/applepay/paymentrequest/ApplePayPaymentCompleteDetails.h: Added.
(WebCore::ApplePayPaymentCompleteDetails::encode const):
(WebCore::ApplePayPaymentCompleteDetails::decode):
Convert the JSON (re)parsed object into a `ApplePayPaymentCompleteDetails`, merging it into
the `ApplePayPaymentAuthorizationResult` passed to the `PaymentCoordinator` (see below).

* Modules/applepay/ApplePayPaymentAuthorizationResult.h:
* Modules/applepay/ApplePayPaymentAuthorizationResult.cpp: Added.
(WebCore::ApplePayPaymentAuthorizationResult::isFinalState const):
(WebCore::ApplePayPaymentAuthorizationResult::encode const):
(WebCore::ApplePayPaymentAuthorizationResult::decode):
* Modules/applepay/ApplePaySessionPaymentRequest.h:
* Modules/applepay/ApplePaySessionPaymentRequest.cpp:
(WebCore::isFinalStateResult): Deleted.
* Modules/applepay/ApplePaySession.h:
* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
(WebCore::ApplePaySession::completePayment):
* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::completePaymentSession):
* Modules/applepay/PaymentCoordinatorClient.h:
* loader/EmptyClients.cpp:
* testing/MockPaymentCoordinator.h:
* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::completePaymentSession):
Replace `PaymentAuthorizationResult` with `ApplePayPaymentAuthorizationResult` so that data
doesn't need to be moved between identically shaped structs for sending to the UIProcess.

* Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm:
(WebCore::PaymentAPIVersion::current):
Increment the current version.

* Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.h:
* Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp:
(WebCore::ApplePayAMSUIPaymentHandler::complete):
AMS UI does not allow/require any data to be provided on completion.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* PlatformMac.cmake:
* Sources.txt:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit:

This allows for developers/merchants to give additional details to Apple Pay on completion.

Issue: <w3c/payment-request#981>
Spec PR: <w3c/payment-request#982>

* WebProcess/ApplePay/WebPaymentCoordinator.h:
* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::completePaymentSession):
* Scripts/webkit/messages.py:
(headers_for_type):
* Shared/WebCoreArgumentCoders.h:
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::encode): Deleted.
(IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode): Deleted.
* Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in:
* Shared/ApplePay/WebPaymentCoordinatorProxy.h:
* Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
(WebKit::WebPaymentCoordinatorProxy::completePaymentSession):
* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentSession):
* Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
* Platform/cocoa/PaymentAuthorizationPresenter.h:
* Platform/cocoa/PaymentAuthorizationPresenter.mm:
(WebKit::toPKPaymentAuthorizationStatus):
(WebKit::PaymentAuthorizationPresenter::completePaymentSession):
Replace `PaymentAuthorizationResult` with `ApplePayPaymentAuthorizationResult` so that data
doesn't need to be moved between identically shaped structs for sending to the UIProcess.

* Platform/cocoa/WKPaymentAuthorizationDelegate.h:
* Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
Add some WKA hooks.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebPaymentCoordinatorClient.h:
* WebCoreSupport/WebPaymentCoordinatorClient.mm:
(WebPaymentCoordinatorClient::completePaymentSession):

LayoutTests:

* http/tests/paymentrequest/ApplePayPaymentCompleteDetails.https.html: Added.
* http/tests/paymentrequest/ApplePayPaymentCompleteDetails.https-expected.txt: Added.



Canonical link: https://commits.webkit.org/246496@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288698 268f45cc-cd09-0410-ab3c-d52691b4dbfc
annulen pushed a commit to qtwebkit/qtwebkit that referenced this pull request Jan 28, 2022
… passed to `complete()`

https://bugs.webkit.org/show_bug.cgi?id=235415
<rdar://problem/82970451>

Reviewed by Darin Adler.

Source/WebCore:

This allows for developers/merchants to give additional details to Apple Pay on completion.

Issue: <w3c/payment-request#981>
Spec PR: <w3c/payment-request#982>

Test: http/tests/paymentrequest/ApplePayPaymentCompleteDetails.https.html

* Modules/paymentrequest/PaymentCompleteDetails.h: Added.
* Modules/paymentrequest/PaymentCompleteDetails.idl: Added.
* Modules/paymentrequest/PaymentResponse.h:
* Modules/paymentrequest/PaymentResponse.idl:
* Modules/paymentrequest/PaymentResponse.cpp:
(WebCore::PaymentResponse::complete):
* Modules/paymentrequest/PaymentRequest.h:
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::complete):
* Modules/paymentrequest/PaymentHandler.h:
Add new `dictionary PaymentCompleteDetails` that's allowed as an optional second argument to
`PaymentResponse.prototype.complete`. If provided, JSON stringify it and pass the serialized
string data along to the relevant `PaymentHandler` for JSON (re)parsing if the associated
payment method requires it.

* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::convertAndValidate):
(WebCore::merge):
(WebCore::ApplePayPaymentHandler::complete):
(WebCore::ApplePayPaymentHandler::retry):
* Modules/applepay/paymentrequest/ApplePayPaymentCompleteDetails.idl: Added.
* Modules/applepay/paymentrequest/ApplePayPaymentCompleteDetails.h: Added.
(WebCore::ApplePayPaymentCompleteDetails::encode const):
(WebCore::ApplePayPaymentCompleteDetails::decode):
Convert the JSON (re)parsed object into a `ApplePayPaymentCompleteDetails`, merging it into
the `ApplePayPaymentAuthorizationResult` passed to the `PaymentCoordinator` (see below).

* Modules/applepay/ApplePayPaymentAuthorizationResult.h:
* Modules/applepay/ApplePayPaymentAuthorizationResult.cpp: Added.
(WebCore::ApplePayPaymentAuthorizationResult::isFinalState const):
(WebCore::ApplePayPaymentAuthorizationResult::encode const):
(WebCore::ApplePayPaymentAuthorizationResult::decode):
* Modules/applepay/ApplePaySessionPaymentRequest.h:
* Modules/applepay/ApplePaySessionPaymentRequest.cpp:
(WebCore::isFinalStateResult): Deleted.
* Modules/applepay/ApplePaySession.h:
* Modules/applepay/ApplePaySession.cpp:
(WebCore::convertAndValidate):
(WebCore::ApplePaySession::completePayment):
* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::completePaymentSession):
* Modules/applepay/PaymentCoordinatorClient.h:
* loader/EmptyClients.cpp:
* testing/MockPaymentCoordinator.h:
* testing/MockPaymentCoordinator.cpp:
(WebCore::MockPaymentCoordinator::completePaymentSession):
Replace `PaymentAuthorizationResult` with `ApplePayPaymentAuthorizationResult` so that data
doesn't need to be moved between identically shaped structs for sending to the UIProcess.

* Modules/applepay/cocoa/PaymentAPIVersionCocoa.mm:
(WebCore::PaymentAPIVersion::current):
Increment the current version.

* Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.h:
* Modules/applepay-ams-ui/ApplePayAMSUIPaymentHandler.cpp:
(WebCore::ApplePayAMSUIPaymentHandler::complete):
AMS UI does not allow/require any data to be provided on completion.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Headers.cmake:
* PlatformMac.cmake:
* Sources.txt:
* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit:

This allows for developers/merchants to give additional details to Apple Pay on completion.

Issue: <w3c/payment-request#981>
Spec PR: <w3c/payment-request#982>

* WebProcess/ApplePay/WebPaymentCoordinator.h:
* WebProcess/ApplePay/WebPaymentCoordinator.cpp:
(WebKit::WebPaymentCoordinator::completePaymentSession):
* Scripts/webkit/messages.py:
(headers_for_type):
* Shared/WebCoreArgumentCoders.h:
* Shared/Cocoa/WebCoreArgumentCodersCocoa.mm:
(IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::encode): Deleted.
(IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode): Deleted.
* Shared/ApplePay/WebPaymentCoordinatorProxy.messages.in:
* Shared/ApplePay/WebPaymentCoordinatorProxy.h:
* Shared/ApplePay/WebPaymentCoordinatorProxy.cpp:
(WebKit::WebPaymentCoordinatorProxy::completePaymentSession):
* Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
(WebKit::WebPaymentCoordinatorProxy::platformCompletePaymentSession):
* Shared/ApplePay/ios/WebPaymentCoordinatorProxyIOS.mm:
* Platform/cocoa/PaymentAuthorizationPresenter.h:
* Platform/cocoa/PaymentAuthorizationPresenter.mm:
(WebKit::toPKPaymentAuthorizationStatus):
(WebKit::PaymentAuthorizationPresenter::completePaymentSession):
Replace `PaymentAuthorizationResult` with `ApplePayPaymentAuthorizationResult` so that data
doesn't need to be moved between identically shaped structs for sending to the UIProcess.

* Platform/cocoa/WKPaymentAuthorizationDelegate.h:
* Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
Add some WKA hooks.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebPaymentCoordinatorClient.h:
* WebCoreSupport/WebPaymentCoordinatorClient.mm:
(WebPaymentCoordinatorClient::completePaymentSession):

LayoutTests:

* http/tests/paymentrequest/ApplePayPaymentCompleteDetails.https.html: Added.
* http/tests/paymentrequest/ApplePayPaymentCompleteDetails.https-expected.txt: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288698 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@marcoscaceres marcoscaceres force-pushed the PaymentCompleteDetails branch from 8b94e5f to e76b31d Compare July 6, 2022 01:44
@marcoscaceres marcoscaceres changed the title proposed addition: passing data on complete() passing data on complete() Jul 6, 2022
@marcoscaceres
Copy link
Member Author

@stephenmcgruer, @rsolomakhin, would appreciate your review on this addition?

@stephenmcgruer stephenmcgruer self-assigned this Jul 6, 2022
@rsolomakhin
Copy link
Collaborator

Is there a link to the WebKit issue available?

@stephenmcgruer
Copy link
Collaborator

Is there a link to the WebKit issue available?

I found https://bugs.webkit.org/show_bug.cgi?id=235415 and WebKit/WebKit@2fbfd75, but looks like the 'real' issue is an internal Apple one (which is of course ok :))

@marcoscaceres
Copy link
Member Author

Yeah, this just adds optional proprietary behavior for completing.

Copy link
Collaborator

@stephenmcgruer stephenmcgruer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (and @rsolomakhin )

I personally am a fan of having defined concepts rather than prose where possible (e.g., I don't like "an IDL value of the type specified by the specification"), but I acknowledge (a) that that may just be my opinion and (b) that at least for now no public specification exists that will link to this.

Putting on my Chrome hat, I believe we'll be happy to make the IDL change in our implementation though we will likely not do anything with the passed data.

Updating the WPT tests would be great! :)

@marcoscaceres
Copy link
Member Author

Thanks @stephenmcgruer! I agree with you about "an IDL value of the type specified by the specification". If eventually we have a spec to link to, will definitely update.

Updating the WPT tests would be great!

We should get some tests for free from WPT once we merge (at least for the method signature length).

I'm not sure it's worth adding a manual test, but can add one if you think it's worth it.

@marcoscaceres marcoscaceres merged commit 5337037 into gh-pages Jul 7, 2022
@marcoscaceres marcoscaceres deleted the PaymentCompleteDetails branch July 7, 2022 06:55
@stephenmcgruer
Copy link
Collaborator

We should get some tests for free from WPT once we merge (at least for the method signature length).

Of course, I completely forgot about idlharness tests >_<. (Which I really shouldn't, given my history in WPT!). I think that is sufficient for this use-case, thanks :)

marcoscaceres added a commit that referenced this pull request Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow custom data for the active payment method to be provided to PaymentResponse.prototype.complete

4 participants