Skip to content

Instantly share code, notes, and snippets.

@toddgeist
Created January 30, 2016 19:06
Show Gist options
  • Save toddgeist/38eeb8a98055953fee4f to your computer and use it in GitHub Desktop.
Save toddgeist/38eeb8a98055953fee4f to your computer and use it in GitHub Desktop.
React Component to show ConnectTo Quickbooks Online Button
import React, { PropTypes } from 'react';
/**
* Connect to QBO Button
* @param props
* @returns {XML}
*/
const ConnectToQuickBooksOnlineButton = (props)=>{
const {callbackURL} = props;
const QBLogin = () => {
// we wrap QBO's button in a template string
// becuase it has some stuff that isn't supported by JSX and react
// like xml name spaces
const template = `
<script type="text/javascript" src="https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js"></script>
<script>
intuit.ipp.anywhere.setup({
menuProxy: '',
grantUrl: '${callbackURL}'
});
</script>
<ipp:connectToIntuit></ipp:connectToIntuit>`
// then we return it in a format ready for dansgeouslySetInnerHTML
return {
__html: template
}
};
return (
<div dangerouslySetInnerHTML={QBLogin()} ></div>
)
};
//validate props
ConnectToQuickBooksOnlineButton.propTypes = {
callbackURL : PropTypes.string.isRequired
};
export default ConnectToQuickBooksOnlineButton
@alexanderwhatley
Copy link

Hi, the code that you wrote is not working for me. Can you take a look at the fiddle I made: https://jsfiddle.net/aewhatley/jg82osm7/2/. Thanks for your help.

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