接收未处理的承诺拒绝警告:类型错误 [ERR_INVALID_ARG_TYPE]:"original"参数必须是函数类型



我在尝试承诺贝宝rest sdk的billingPlan和billingAgreement时收到未经处理的承诺拒绝警告。我需要承诺它,因为我需要在后台使用wait,但我的编码方式可能有问题。请帮我找出我做错了什么。谢谢


const Plan = util.promisify(paypal.billingPlan)
const agreement = util.promisify(paypal.billingAgreement)
try{
let billingPlan = await Plan.create(billingPlanAttributes)
try{ 
let response = await Plan.update(billingPlan.id, billingPlanUpdateAttributes)
console.log('Billing plan create response:::', billingPlan)
console.log("response from updatePlan", response)
try{
let billingAgreement = await agreement.create(billingAgreementAttributes)
console.log("Create Billing Agreement Response");
//console.log(billingAgreement);
for (var index = 0; index < billingAgreement.links.length; index++) {
if (billingAgreement.links[index].rel === 'approval_url') {
var approval_url = billingAgreement.links[index].href;
console.log("For approving subscription via Paypal, first redirect user to");
console.log(approval_url);
console.log("Payment token is");
console.log(url.parse(approval_url, true).query.token);
// See billing_agreements/execute.js to see example for executing agreement 
// after you have payment token
}
}
}catch(err){
console.log('error found in agreemtne')
console.log(err)
}
}catch(err){
console.log('error found in updatePlan')
console.log(err)
}
}catch(err){
console.log('error found in createPlan')
console.log(err)
}
}

我收到的错误是-未处理的PromiseRejectionWarning:TypeError[ERR_INVALID_ARG_TYPE]:;原始的";参数的类型必须为function。在Object.promimify上收到一个Object实例。请提供帮助!

我还试着承诺整个paypal.billingPlan.create、paypal.bollingPlan.update和paypal.bilingAgreement.create,但后来我收到一个错误,说无法读取它的基本URL。这应该是paypal.billingPlan/paypal.billingAgreement。不确定这条信息是否有价值,但请帮助

您显然使用了不推荐使用的REST SDK,以及不推荐使用与订阅API的当前版本(没有REST SDK(不兼容的计费协议。

不要使用不推荐使用的SDK。并且,实现当前版本的PayPal订阅。

相关内容

最新更新