简体   繁体   中英

Unexpected Error Braintree (ECONNREFUSED)

Getting this error while using braintree sdk for Nodejs (v14.15.0) on a local machine (Win 10 x64).

在此处输入图像描述

Here is the minimal code:

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 };
}

As per the Type Definitions for braintree, you'll have to provide a configuration of the environment you are using, so this:

private constructor(merchantId: string, publicKey: string, privateKey: string, env?: braintree.Environment)

becomes this:

private constructor(merchantId: string, publicKey: string, privateKey: string, env?: braintree.Environment.Sandbox)

You can choose any of the following:

Development, Production, Qa, Sandbox

I'm not entirely sure if this will help. But, it's worth a try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM