Skip to content

Commit

Permalink
Adds hostname configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissrogers committed Sep 29, 2023
1 parent cd95939 commit 44e64d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/provider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export default class RecurlyProvider extends React.Component {
* [API Access](https://app.recurly.com/go/developer/api_access).
*/
publicKey: PropTypes.string,

/**
* Register the current hostname
*/
hostname: PropTypes.string,
/**
* Sets a default currency
*/
Expand Down Expand Up @@ -56,7 +61,7 @@ export default class RecurlyProvider extends React.Component {
constructor (props) {
super(props);

if (!this.props.publicKey) {
if (!(this.props.publicKey || this.props.hostname)) {
throw new Error(`
Please pass your 'publicKey' value to this RecurlyProvider.
Example: <RecurlyProvider publicKey="MY_PUBLIC_KEY">
Expand Down
8 changes: 8 additions & 0 deletions test/provider.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,12 @@ describe('<RecurlyProvider />', function () {
}
});
});

describe('with a hostname', function () {
it('does not throw an error', function () {
expect(() => {
render(<RecurlyProvider hostname="test-hostname" api={api} />);
}).not.toThrow();
});
});
});

0 comments on commit 44e64d3

Please sign in to comment.