Re: [w3c/browser-payment-api] Making this API work with HTML Forms (#330)

> Marcos, it seems as if you're getting caught up on the idea of "web sites currently use forms to collect credit cards, so we should optimize for that." 

That's possible, yes 😸 Apologies, I don't meant to derail this too much. 

> I'm no expert here, but what does a validity check for a proprietary payment response look like? What about for a Stripe token? Or an Apple Pay response? Or a SEPA credit transfer?

Right now, I'm only interested in the most simple validation of the values returned by PaymentResponse (i.e., shipping address, credit card number, email, etc.). There is enough complexity just in that to keep us happy for a little while. 

The above proprietary payment methods and associated tokens + related data will require that information be POSTed to some server for validation. The client can't do much else with that stuff. 

> Perhaps. We can all agree the payment data ultimately needs to be sent somewhere, but that somewhere is quite varied. It could be Braintree's client-side JavaScript API, where you don't submit() you client.tokenizeCard(), for example.

But at the end of the day, everything that leaves the browser conforms to the Fetch spec. So, irrespective of what any library does, it basically has only a few choices:

 * Form.submit()
 * xhr.send()
 * fetch() 
 * Or some navigation hack to GET a URL (but that would be highly unlikely). 

> But these issues aside for the moment, I think the larger point is that the time for such a large change has passed. If this is a path the WG wants to go down, we should consider how we can add this later in a backwards compatible way.
> Would this work by allowing a user to do something like, paymentResponse.toFormData() or similar?

Yes, it would. Alternatively: 

```JS
var data = new FormData(paymentResponse);
```

Few ways to skin this cat. However, I'm pretty sure this will come up sooner or later as more sites try to integrate this API with their existing payment systems. 



-- 
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/330#issuecomment-265651772

Received on Thursday, 8 December 2016 04:43:58 UTC