[browser-payment-api] Should a payment request be just data, or a programmable object? (#47)

Migrating from https://github.com/w3c/webpayments/issues/36:

The paymentRequest API asserts that a payment request is a programmable object:

http://wicg.github.io/paymentrequest/specs/paymentrequest.html#paymentrequest-interface

that is instantiated like so

```javascript
var payment = new PaymentRequest(supportedInstruments, details, options, schemeData);
```

and can have methods called on it like so:

```javascript
payment.addEventListener("shippingAddressChange", function (changeEvent) {
    // Process shipping address change
});
```

The Web Payments CG's Browser API asserts that a payment request is just data:

http://wicg.github.io/web-payments-browser-api/#processing-a-payment-request

and that data is processed by functions:

```javascript
var request = {
  type: 'PaymentRequest',
  description: 'Payment to ExampleMerch for widgets',
  acceptablePayment: {
    paymentMethod: 'https://w3id.org/payment-methods#Visa',
    paymentAmount: {
      amount: '4.35',
      currency: 'USD'
    }
  }
};

// request payment and get a promise that will resolve to
// a payment acknowledgement
var payment = navigator.payment.request(request);

// called when the payment request has been processed
payment.then(function(acknowledgement) {
  // payment request was at least partially processed, do something with the
  // acknowledgement, such as check its approval code or forward an approval
  // token to actually execute the payment
}).catch(function(err) {
  // payment request failed
});
```

These are two different general design approaches for the browser API:

1. There is data, and functions act on that data (Web Payments CG approach).
2. There are objects that consist of data, and verbs that hang off of those objects (paymentRequest approach).

So, what is our design approach for the browser API?

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/browser-payment-api/issues/47

Received on Monday, 14 March 2016 02:07:28 UTC