[w3c/payment-request] Allow custom data for the active payment method to be provided to `PaymentResponse.prototype.complete` (Issue #981)

It'd be great for there to be a standardized way for developers/merchants to provide data back to the `PaymentRequest` after it's been accepted.  This would allow additional information to be provided back to the underlying platform payment method handler/UI.

I was thinking it'd be something like this:
```webidl
partial interface PaymentResponse {
  [NewObject] Promise<undefined> complete(optional PaymentComplete result = "unknown", optional PaymentMethodData paymentMethod);
}
```
or maybe even just
```webidl
partial interface PaymentResponse {
  [NewObject] Promise<undefined> complete(optional PaymentComplete result = "unknown", optional object paymentMethodData);
}
```

Alternatively, we maybe might want to wrap the `PaymentComplete` in a new IDL `dictionary` (just like `PaymentValidationErrors`), which would also allow for more extension in the future if desired.
```webidl
enum PaymentResultStatus {
  "fail",
  "success",
  "unknown"
}

dictionary PaymentResult {
    PaymentResultStatus status = "unknown";
    PaymentMethodData paymentMethod;
}

partial interface PaymentResponse {
  [NewObject] Promise<undefined> complete(optional PaymentResultStatus = "unknown"); // Would we still want/need this?
  [NewObject] Promise<undefined> complete(optional PaymentResult);
}
```

Though (in both cases) I'm not sure if we want just a `PaymentMethodData` or a `sequence<PaymentMethodData>` so that a developer/merchant can declaratively provide data back to all supported payment methods at once instead of having to adjust the data based on which payment method is currently being used.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/issues/981
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/payment-request/issues/981@github.com>

Received on Thursday, 16 December 2021 23:50:06 UTC