Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate PreferenceID #9

Open
pablomayobre opened this issue Jun 10, 2017 · 1 comment
Open

Generate PreferenceID #9

pablomayobre opened this issue Jun 10, 2017 · 1 comment

Comments

@pablomayobre
Copy link

Both Android and iOS SDKs offer the MerchantServer.createPreferences function. It would be great to expose that to the JS side (or at least simulate it since if I understood right it is only an HTTP GET request with the JSON object as the body)

This request is only to be in feature parity with the SDKs (in the Basic Checkout API)

@pablomayobre
Copy link
Author

pablomayobre commented Jun 12, 2017

I would write this function simply as:

export const createPreferences = (url, preferences) => fetch(url, {
  method: 'POST',
  redirect: 'follow',
  body: JSON.stringify(preferences)
});

People that want more control should use the fetch API directly.

This is everything that MerchantServer.createPreferences does. It separates the domain from the uri but then joins them again to form the url.
We could rely on a package like url-join to recreate this behaviour but there is no real use case... the user provides both the domain and the uri anyway so why not provide the complete url?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants