Coder Social home page Coder Social logo

Comments (7)

msporny avatar msporny commented on August 25, 2024

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

I assert that our design approach should be: "There is data and functions act on that data"

There are at least three reasons to take this approach:

  1. It helps us clearly delineate the payment messages from the things you can do with those payment messages (this helps us more easily use the same messages for the HTTP API and the browser API and align w/ ISO20022).
  2. It simplifies the browser API and thus reduces the cognitive load on developers as it's clear that you have payment data and things you can do with that payment data.
  3. It avoids unnecessary complexity in the browser implementations by making the browser just a payment message router instead of exposing a payment request state machine to the payee.
  4. It's more flexible, as a data-only approach decouples behavior from the data.

There is much more on the downsides of object-and-verb API design here:

http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html

from webpayments.

dlongley avatar dlongley commented on August 25, 2024

See also: Rule of Least Power.

from webpayments.

burdges avatar burdges commented on August 25, 2024

It's fairly hard to imagine what a payment request gains from being code. If the payee has say preferences about instruments, then that could be encoded fine in data. It's easy to imagine web developers botching up payment requests though.

from webpayments.

msporny avatar msporny commented on August 25, 2024

Here's a proposal, since there doesn't seem to be any push-back on the issues list:

The PaymentRequest object will not have code attached to it. It will be a pure data object (with no added Javascript functions) as demonstrated in: http://wicg.github.io/web-payments-browser-api/#processing-a-payment-request

from webpayments.

msporny avatar msporny commented on August 25, 2024

Let's also not forget that XMLHttpRequest is problematic API partially due to the fact that it stores state (like the PaymentRequest API proposal) and managing that state machine has led to code being more complicated than necessary for developers.

The problem got so bad that there is a new Fetch API proposal that attempts to cut down on many of the state-machine related issues (among a slew of other non-state-machine-related issues).

from webpayments.

adrianhopebailie avatar adrianhopebailie commented on August 25, 2024

Moved @msporny proposal to it's own issue so that the discussion may continue on this thread if the proposal is not accepted.

from webpayments.

msporny avatar msporny commented on August 25, 2024

Migrated to w3c/payment-request#47

from webpayments.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.