Closed ChrisSargent closed 5 years ago
Hey,
I seems in one of the latest updates the error handling for card errors on the hosted fields has changed.
We used to have this code:
const hostedFieldsPromise = (HostedFields, options) => new Promise((resolve, reject) => { HostedFields.setup(options.clientId, 'custom', { onRegistered: resolve, onError: error => reject(new Error(error)), ...options }); });
And we'd get card validation come through correctly as errors.
Now, if there is a card validation problem, it's calling the onRegistered method but with a response.err string. Hence, we've had to change to:
onRegistered
response.err
const hostedFieldsPromise = (HostedFields, options) => new Promise((resolve, reject) => { HostedFields.setup(options.clientId, 'custom', { onRegistered: response => { const { err } = response; if (err) { return reject(new Error(err)); } return resolve(response); }, onError: error => reject(new Error(error)), ...options }); });
This behaviour seems a little strange to resolve hit the onRegistered method when the card is not registered.
hey guys, sorry, my bad, it wasn't doing this at all :-) Closing
Glad it's working for you. Thanks for the update.
Hey,
I seems in one of the latest updates the error handling for card errors on the hosted fields has changed.
We used to have this code:
And we'd get card validation come through correctly as errors.
Now, if there is a card validation problem, it's calling the
onRegistered
method but with aresponse.err
string. Hence, we've had to change to:This behaviour seems a little strange to resolve hit the
onRegistered
method when the card is not registered.