Re: [w3c/browser-payment-api] Use navigator.payments singleton, factory method, or PaymentRequest constructor (#16)

> Couldn't you use static methods of the PaymentRequest constructor if you wanted to create new non-instance methods in future?

Are you suggesting a style like this:

```javascript
var thing = PaymentRequest.someMethod();
```
My only reservation is that `someMethod` may be more generically related to payments as opposed to payment requests (eg: registration of a payment app) in which case this doesn't make sense.

I'm certainly more familiar with (and prefer) the pattern:

```javascript
var thing = navigator.payments.someMethod();
var paymentRequest = navigator.payments.createRequest();
```

I can also imagine us having API endpoints like the following that are used by web-based payment apps:

```javascript
//After the payment app loads ask the browser for the current request that it must process
var paymentRequest = navigator.payments.getRequest();
//Submit back the response
paymentRequest.submitResponse(paymentResponse);
```

Or, if the request is passed to the app as an HTTP request then:

```javascript
//Submit back the response
navigator.payments.submitResponse(paymentResponse);
```

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/browser-payment-api/issues/16#issuecomment-207925624

Received on Sunday, 10 April 2016 06:02:57 UTC