braintree / braintree_node

Braintree Node.js library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
334 stars 104 forks source link

Unexpected Error #189

Closed hassanmehdi98 closed 3 years ago

hassanmehdi98 commented 3 years ago

General information

Issue description

Not able to call any method, getting this error constantly while using it from a local machine

image

Here is the minimum code required for reproducing this:

private constructor(merchantId: string, publicKey: string, privateKey: string, env?: braintree.Environment) {
        this._gateway = new braintree.BraintreeGateway({
            merchantId,
            publicKey,
            privateKey,
            environment: env
        });
}
async CreateCustomer(firstName: string, lastName: string, email: string): Promise<BraintreeCreateCustomerResponse> {
        let data = await this._gateway.customer.create({
            firstName,
            lastName,
            email
        });

        return { Id: data.customer.id };
}
hassanmehdi98 commented 3 years ago

Resolved by passing correct environment variable enum. Looks like @types/braintree was misleading