Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
required: true
},
overrides: {
fields: {
number: {
maskInput: {
// Only show last four digits on blur.
showLastFour: true
}
}
}
}
};
}
const braintreeDropIn = await dropIn.create({
authorization: braintreeToken,
container: `#${CONTAINER_ID}`,
paypal,
card
});
braintreeDropIn.on('paymentMethodRequestable', () => {
setPaymentMethodRequestable(true);
});
braintreeDropIn.on('noPaymentMethodRequestable', () => {
setPaymentMethodRequestable(false);
});
setDropinInstance(braintreeDropIn);
} catch (error) {
it("Calls teardown on destruction", done => {
const braintreeWebDropIn = require("braintree-web-drop-in");
const teardownMock = jest.genMockFunction();
braintreeWebDropIn.create = () =>
new Promise(resolve => {
resolve({ teardown: teardownMock });
});
const component = renderer.create(
{
component.unmount();
const callNumber = teardownMock.mock.calls.length;
expect(callNumber).toEqual(1);
done();
}}
/>
);
});
if (!response || !response.data || !response.data.clientToken) {
this.props.getToken()
return
}
const clientToken = response.data.clientToken
const carmel1K = response.data.Carmel1K
if (carmel1K.item.id !== Carmel1K.item.id ||
carmel1K.item.price !== Carmel1K.item.price) {
this.triggerRedirect("/pricing")
return
}
dropin.create({
authorization: clientToken,
container: '#dropin-container'
}, (createErr, clientService) => {
this.setState({ clientToken, clientService })
})
}
getToken().then(({ token }) => {
let form = document.querySelector('#bakset-form');
dropin.create(
{
authorization: token,
container: '#dropin-container'
},
(createErr, instance) => {
this.setState({
isLoading: false
});
form.addEventListener('submit', e => {
e.preventDefault();
const data = getFormData(form).reduce((prev, next) => {
prev[next[0]] = next[1];
return prev;
}, {});
async componentDidMount() {
this.instance = await BraintreeWebDropIn.create({
container: ReactDOM.findDOMNode(this.wrapper),
preselectVaultedPaymentMethod: this.props.preselectVaultedPaymentMethod,
...this.props.options
});
if (this.props.onNoPaymentMethodRequestable) {
this.instance.on(
"noPaymentMethodRequestable",
this.props.onNoPaymentMethodRequestable
);
}
if (this.props.onPaymentMethodRequestable) {
this.instance.on(
"paymentMethodRequestable",
this.props.onPaymentMethodRequestable
);