w3c / w3c/payment-request

Extensibility of PaymentResponse.complete(result)

Open
#817 9 comments 0 reactions 2 assignees View on GitHub

Nobody has claimed this yet.

Extensibility Future Candidate Feature proposal - needs discussion SRC
Dominant language
HTML
Stars
510
Forks
139
PR merge metrics
No merged PRs in 30d

Description

In his analysis of SRC, @mountainhippo identified the need to have a post-authorization step where the merchant/website notifies the payment handler of the result of the payment.

I believe that this is roughly why we have PaymentResult.complete(result) driven by a similar requirement from Apple Pay (@aestes can confirm).

My question is, how extensible can we make the result argument so we can support other payment methods with this requirement?

result is currently defined as being an optional PaymentComplete enum but I think it would be better if it was more generic.

The ideal would be if payment method specs could define a format for this (JSON serializable object) in the same way they do for their custom payment request and response data.

This would allow an SRC payment method spec to define the exact format of result when a website calls PaymentResponse.complete(result) after a payment.

Concretely this would mean:

  1. Change the definition of the PaymentResponse interface such that PaymentResponse.complete(response) is defined as:
  [NewObject]
  Promise<void> complete(optional object result);

where object is the object type (as used in the definition of PaymentMethodData.data).

  1. Change the definition of the complete() method to include a definition of result argument. Something like the following, copied from PaymentMethodData.data:

An object that provides optional information that might be needed by the supported payment methods. If supplied, it will be JSON-serialized.

  1. Move the definition of the PaymentComplete enum out of the PR API spec and into payment method specs that use it as is (E.g. Apple Pay).

The effect is that any payment method specification can then define 3 custom data formats:

  1. request data, passed in by the website as PaymentMethodData.data
  2. response data, received by the website as PaymentResponse.data
  3. complete data, passed in as result by the website when calling PaymentResponse.complete(result)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.