Skip to content

Conversation

grace09thompson
Copy link
Contributor

Uses the new Token Request Flow. Could use some suggestions and help cleaning this up (basically adding back in the token style for the button without bindbutton, which does other things I don't want).


// Define what happens on successful data submission
XHR.addEventListener("load", function(event) {
window.location.replace(event.target.responseURL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are using the redirect flow here, but you can keep working with the popup, check merchant-demo code: https://github.com/tokenio/merchant-demo/blob/master/src/components/TokenEnablerButton/index.js#L74 it can take the token request url instead of terms, let me know if you need my help :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to demonstrate plain redirect since that's what our documentation shows. I originally tried using the bindButton set up but it caused all sorts of problems and confusion, so figured for the sample we're giving to devs we should keep it as plain as can be, and show that all Token specific stuff can be kept to the backend 😀


XHR.setRequestHeader("Content-Type", "application/json; charset=utf-8");

var data = $.param({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are relying on jQuery for this, why not use $.post instead of native XMLHttpRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were problems with the redirect part when I was using $.post, ended up with preflight response errors from the web app. This way didn't cause those errors, could be worth playing with to make it consistent though.

@grekinsky
Copy link
Contributor

I created a new branch from this one with styles for the token button and did some refactoring of script.js, let me know if it works for you and I'll create a PR to merge into this branch :-D https://github.com/tokenio/merchant-sample-java/tree/style-token-button

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants