Re: [w3c/browser-payment-api] editorial: clarify that payment handler data is converted (#536)

The bitcoin use case is easily addressed by simply moving the the version number to the PMI. 

Thus: 

```JS
const v1 = [{
  supportedMethods: ["bitcoin-v1"],
  data: { 
    pki_type: "none", 
    pki_data: "",
    serialized_payment_details: "F1AABE5B69...",
    signature: "1FE56C09..."
  }
};

// V2 added new things, changes the semantics/types of v1 fields
const v2 = [{
  supportedMethods: ["bitcoin-v2"],
  data: { 
    this_is_needed_in_v2: "thing", // Add new field
    pki_type: ["this", "is", "now", "an", "array"], 
    pki_data: "",
    serialized_payment_details: "F1AABE5B69...",
    signature: "1FE56C09..."
  }
};

// Bitcoin v3 recognized the error of their ways, so it's backwards compatible with v1, but adds further information 
const v3 = [{
  supportedMethods: ["bitcoin-v1", "bitcoin-v3"],
  data: { 
    // In v3, we add this field the is needed for a better user experience, 
    // but a v1 processor can safely ignore it: 
    new_field_ignored_in_v1: ["thing"],
    pki_type: "none", 
    pki_data: "",
    serialized_payment_details: "F1AABE5B69...",
    signature: "1FE56C09..."
  }
};
```

And so, this works fine:

```JS
const paymentRequest = new PaymentRequest([v3, v2, v1], details, options)
```

What am I missing? 

If nothing, then option 2 remains. 



-- 
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/pull/536#issuecomment-304552927

Received on Monday, 29 May 2017 01:12:44 UTC