I am trying to call onPaymentStatus() function inside the jQuery function. But i am unable use 'this' scope
this.braintree.client.create({
authorization: 'client_token'},
(err, client) => {
client.request({
endpoint: 'payment_methods/credit_cards',
method: 'post',
data: data
}, function (requestErr, response) {
if (requestErr) { throw new Error(requestErr); }
console.log('Got nonce:', response.creditCards[0].nonce);
this.onPaymentStatus(response.creditCards[0].nonce); //
});
});
onPaymentStatus (nonce) {
console.log(nonce);
}
I got error ERROR TypeError: Cannot read property 'onPaymentStatus' of null