PayPal API返回SUBSCRIPTION_CANNOT_HAVE_QUANTITY,即使计划有quantity_



使用PayPal当前的API,我创建了一个简单的产品:

{
"id" : "A-001",
"name": "A Service",
"description": "Video streaming service",
"type": "SERVICE",
"category": "SOFTWARE"
}

还创建了一个计划,该计划基于数量分层

{
"product_id" : "A-001",
"name": "Default Plan",
"description": "Plan with regular and trial payment definitions.",
"quantity_supported" : true,
"billing_cycles": [
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "TRIAL",
"sequence": 1,
"total_cycles": 1
},
{
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 2,
"total_cycles": 12,
"pricing_scheme": {
"pricing_model" : "TIERED",
"version" : 1,
"tiers": [{
"starting_quantity": 1,
"ending_quantity": 499,
"amount": { "currency_code":"USD", "value":0.55}
},
{
"starting_quantity": 500,
"ending_quantity": 999,
"amount": { "currency_code":"USD", "value":0.5}
},
{
"starting_quantity": 1000,
"ending_quantity": 2499,
"amount": { "currency_code":"USD", "value":0.46}
},
{
"starting_quantity": 2500,
"amount": { "currency_code":"USD", "value":0.37}
}
]
}
}
],
"payment_preferences": {
"auto_bill_outstanding": true,
"setup_fee": {
"value": "10",
"currency_code": "USD"
},
"setup_fee_failure_action": "CONTINUE",
"payment_failure_threshold": 3
},
"taxes": {
"percentage": "10",
"inclusive": false
}
}

现在,我尝试创建一个订阅计划:

{
"plan_id": "P-16786052YT8021220MAMUCDY",
"start_time": "2021-03-01T00:00:00Z",
"quantity": "20",
"shipping_amount": {
"currency_code": "USD",
"value": "0.00"
},
"subscriber": {
"name": {
"given_name": "John",
"surname": "Doe"
},
"email_address": "customer@example.com",
"shipping_address": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "2211 N First Street",
"address_line_2": "Building 17",
"admin_area_2": "San Jose",
"admin_area_1": "CA",
"postal_code": "95131",
"country_code": "US"
}
}
},
"application_context": {
"brand_name": "walmart",
"locale": "en-US",
"shipping_preference": "SET_PROVIDED_ADDRESS",
"user_action": "SUBSCRIBE_NOW",
"payment_method": {
"payer_selected": "PAYPAL",
"payee_preferred": "IMMEDIATE_PAYMENT_REQUIRED"
},
"return_url": "https://example.com/returnUrl",
"cancel_url": "https://example.com/cancelUrl"
}

}

但是我得到一个错误响应:

{
"name": "UNPROCESSABLE_ENTITY",
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "658174d246c0b",
"details": [
{
"issue": "SUBSCRIPTION_CANNOT_HAVE_QUANTITY",
"description": "Subscription can't have quantity as the plan does not support quantity."
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/v1/billing/subscriptions#UNPROCESSABLE_ENTITY",
"rel": "information_link",
"method": "GET"
}
]

}

为什么当我的计划明确说明"quantity_supported" : true,时出现此错误?

在我的例子中,我忘记修改先前计划创建中的PayPal-Request-Id(不允许数量),因此没有创建具有上述详细信息的计划