gpt4 book ai didi

javascript - 如何捕获 strip 传输的错误和成功?

转载 作者:行者123 更新时间:2023-12-03 06:02:41 25 4
gpt4 key购买 nike

我正在尝试启动传输,但如果有错误,我需要捕获错误,并且如果传输成功,我需要执行另一种方法。如何捕获成功/错误?

stripe.transfers.create({
amount: payoutAmount*100,
currency: "usd",
destination: "default_for_currency",
method: "instant"
},{stripe_account: String(accountId)}
);

最佳答案

Node.js Stripe 库是异步的,因此您需要包含 that API call 的回调或者将其返回到 var 并使用 promises 处理它.

使用回调,它会是这样的:

stripe.transfers.create({
amount: payoutAmount*100,
currency: "usd",
destination: "default_for_currency",
method: "instant"
}, {stripe_account: String(accountId)}, function(error, transfer) {
if (error) {
// Transfer failed, so do something with the error:
return doSomethingWithError(error);
}

// Transfer succeeded, so do something with the Transfer:
doSomethingWithTransfer(transfer);
});

关于javascript - 如何捕获 strip 传输的错误和成功?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39691328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com