Paypal Rest API/更新计划无法更新设置费用



我正在尝试使用其余的API来更新计费计划的设置费用。该计划处于活动状态,但目前尚未使用。我为每个客户为每项服务制定了一个计划,因为每项服务的价值都不同,如果他们没有完成付款过程,并在未来某个日期返回,价值可能会发生变化。

因此,如果他们在某个时候回来,我可能需要更新setup_fee,根据API文档,setup_fee可以通过PATCH进行更改。

因此,这是变更请求之前的计划。

{
"id": "P-7H193472JB2565539MCC4REI",
"product_id": "PROD-3GK52832VM631252R",
"name": "Access to Gig",
"status": "ACTIVE",
"description": "Access to Gig",
"usage_type": "LICENSED",
"billing_cycles": [
{
"pricing_scheme": {
"version": 6,
"fixed_price": {
"currency_code": "USD",
"value": "9.44"
},
"create_time": "2021-04-25T20:25:47Z",
"update_time": "2021-04-25T20:25:47Z"
},
"frequency": {
"interval_unit": "MONTH",
"interval_count": 1
},
"tenure_type": "REGULAR",
"sequence": 1,
"total_cycles": 0
}
],
"payment_preferences": {
"service_type": "PREPAID",
"auto_bill_outstanding": true,
"setup_fee": {
"currency_code": "USD",
"value": "19.57"
},
"setup_fee_failure_action": "CANCEL",
"payment_failure_threshold": 1
},
"quantity_supported": false,
"create_time": "2021-04-25T19:52:49Z",
"update_time": "2021-04-25T20:25:47Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/billing/plans/P-7H193472JB2565539MCC4REI",
"rel": "self",
"method": "GET",
"encType": "application/json"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/plans/P-7H193472JB2565539MCC4REI",
"rel": "edit",
"method": "PATCH",
"encType": "application/json"
},
{
"href": "https://api.sandbox.paypal.com/v1/billing/plans/P-7H193472JB2565539MCC4REI/deactivate",
"rel": "self",
"method": "POST",
"encType": "application/json"
}
]

所以现在我想更新setup_fee。

PATCH https://api.sandbox.paypal.com/v1/billing/plans/P-7H193472JB2565539MCC4REI
Authorization: Bearer <ACCESS TOKEN>
Content-Type: application/json
{
"path" : "payment_preferences/setup_fee",
"value" : {
"setup_fee" : {
"value" : "220.80",
"currency_code" : "USD"
}
},
"op" : "replace"
}

作为回应,我得到:

{
'details' => [
{
'location' => 'body',
'issue' => 'MALFORMED_REQUEST_JSON',
'field' => '/',
'description' => 'The request JSON is not well formed.'
}
],
'links' => [],
'message' => 'Request is not well-formed, syntactically incorrect, or violates schema.',
'name' => 'INVALID_REQUEST',
'debug_id' => '9444da3d14a00'
};

知道为什么失败了吗?我试图改变";值";条目是,作为实际的setup_fee,或者作为具有整个setup_fee结构的散列。

Thanx

事实证明我有多个问题,是的,第一个问题是我需要路径为"payment_preferences/setup_ ee";,我忘记了开头的斜线。

但同时,我需要json数据是一个结构数组,而不是一个结构。

[
{
"op":"replace",
"path":"/payment_preferences/setup_fee",
"value":
{
"currency_code":"USD",
"value":"500.00"
}
}
]

谢谢大家。