我在使用此处提到的示例示例时遇到以下错误:https://github.com/paypal/PayPal-node-SDK/blob/master/samples/subscription/billing_plans/create.js。
return callback(null, billingPlan.id); ^ TypeError: undefined is not a function at /home/mukul/scrub/server/payments/paypal/paypal.controller.js:241:17 at IncomingMessage.<anonymous> (/home/mukul/scrub/node_modules/paypal-rest-sdk/lib/client.js:131:13) at IncomingMessage.emit (events.js:129:20) at _stream_readable.js:908:16 at process._tickCallback (node.js:355:11)
以下是我的代码:
function createBillingPlan(planDesc, planAmount, planFrequency, planName, planCurrency, callback) {
var billingPlanAttributes = {
"description": planDesc,
"merchant_preferences": {
"auto_bill_amount": "yes",
"cancel_url": CANCEL_URL,
"initial_fail_amount_action": "continue",
"max_fail_attempts": "1",
"return_url": RETURN_URL
},
"name": planName,
"payment_definitions": [
{
"amount": {
"currency": "USD",
"value": 25
},
"charge_models": [
{
"amount": {
"currency": "USD",
"value": 2
},
"type": "SHIPPING"
},
{
"amount": {
"currency": "USD",
"value":27
},
"type": "TAX"
}
],
"cycles": "0",
"frequency": frequency,
"frequency_interval": "1",
"name": planName,
"type": "REGULAR"
},
{
"amount": {
"currency": "USD",
"value": "0"
},
"cycles": "1",
"frequency": "MONTH",
"frequency_interval": "1",
"name": "Trial",
"type": "TRIAL"
}
],
"type": "INFINITE"
};
paypal.billingPlan.create(billingPlanAttributes, function (error, billingPlan) {
if (error) {
console.log(error);
return callback(error); // This is causing error
} else {
console.log("Create Billing Plan Response");
console.log(billingPlan);
return callback(null, billingPlan.id); // this is causing error
}
});
} 我知道如何解决这个问题?
由于