2017-05-01 21 views
0

我在使用Drop-in功能的沙盒模式中尝试Braintree。 我使用现有的customerID创建客户端令牌。但是,当我做transaction.sale调用这个customerId和期权storeInVault = true提示错误以下错误:Braintree沙箱transaction.sale给出错误:“销售客户ID已被采纳”

Sale Customer ID has already been taken.

按照它应该更新与支付现时客户的文档。

下面是代码:

gateway.transaction.sale({ 
    amount: '10.00', 
    paymentMethodNonce: nonceFromTheClient, // Generated nonce passed from client 
    customer: { 
    id: 232057823, //this customer exist in the vault 
    email : user.emails[0].address 
    }, 
    options: { 
    submitForSettlement: true, 
    storeInVault: true 
    //storeInVaultOnSuccess: true 
    } 
}, function (err, result) { 
    if (err) { 
    console.log(err); 
    } else { 
    if (result.success) { 
     return result.success; 
    } else { 
      console.log('ERR Sale '+result.message); 
      return result.success; 
    } 
    } 
}); 

我使用流星与包patrickml:braintree

回答

1

您看起来使用的是Braintree Transaction Sale API Call,其中包含storeInVault:true选项。这样做是使用包含的付款方法随机数创建一个事务,并试图创建一个客户ID为232057823,这就是为什么你遇到了这个错误。

如果您的目标是简单更新现有客户,那么您需要使用Customer Update API call

+0

我认为这是我可能要做的。但根据文档:**现有客户使用新的付款方式** 要将此交易的付款方式与现有客户关联,请将customerId与options.storeInVault或options.storeInVaultOnSuccess一起传递为true。 的Node.js 'gateway.transaction.sale({ 量: “10.00”, paymentMethodNonce:nonceFromTheClient, 客户ID: “theCustomerId”, 选项:{ storeInVaultOnSuccess:真 } },功能(ERR,结果){ });' –

+0

该文档是正确的,但我可以看到混淆。您在客户选项中嵌套'id'属性。在您已链接的示例中,customerId属性在顶层指定。 – ThinkAboutIt

+1

尤里卡瞬间!良好的捕捉,它总是有助于有第二双眼睛!非常感谢。 –