简体   繁体   English

创建帐单计划因Malformed_Request错误

[英]Create Billing Plan is erroring with Malformed_Request

I am trying to create a billing plan with the request below. 我正在尝试使用下面的请求创建一个计费方案。 (It's valid JSON) and I've checked the request and seems to be correct based on the example requests given on PayPal's (Irrespective of this, I've tried using the stock example and It wont work. (这是有效的JSON),并且我已经检查了请求,并且根据PayPal给出的示例请求,它似乎是正确的(无论如何,我都尝试使用库存示例,但它不起作用。

POST https://api.sandbox.paypal.com/v1/payments/billing-plans HTTP/1.1
Content-Type: application/json
Authorization: Bearer A015Ocv2vKmHg2NY2PNSbGEIN5jWHsZFKr.63kJzvtNaeII
Host: api.sandbox.paypal.com
Content-Length: 775
Expect: 100-continue

{
"name": "Membership Fee",
"description": "Monthly Fee with Trial Month",
"type": "INFINITE",
"payment_definitions": [
    {
        "name": "Plan",
        "type": "REGULAR",
        "frequency": "MONTH",
        "frequency_interval": "1",
        "amount": {
            "value": "15",
            "currency": "GBP"
        },
        "cycles": "12"
    },
    {
        "name": "First Month Free Trial",
        "type": "TRIAL",
        "frequency": "MONTH",
        "frequency_interval": "1",
        "amount": {
            "value": "0.01",
            "currency": "GBP"
        },
        "cycles": "1"
    }
],
"merchant_preferences": {
    "setup_fee": {
        "value": "0",
        "currency": "GBP"
    },
    "return_url": "http://app.URLREMOVED.co.uk/complete",
    "cancel_url": "http://app.URLREMOVED.co.uk/cancel",
    "auto_bill_amount": "YES",
    "initial_fail_amount_action": "CONTINUE",
    "max_fail_attempts": "12"
}
}

Response I get: 我得到的回应:

HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
PROXY_SERVER_INFO: host=slcsbjava4.slc.paypal.com;threadId=35463
Paypal-Debug-Id: 8437249fdc6d1
SERVER_INFO: paymentsplatformserv:v1.payments.billing-    plans&CalThreadId=127&TopLevelTxnStartTime=147d9bc0282&Host=slcsbjm3.slc.paypal.com&pid=25126
Content-Language: *
Date: Fri, 15 Aug 2014 12:54:42 GMT
Connection: close
Content-Type: application/json
Content-Length: 213
Connection: close

{"name":"MALFORMED_REQUEST","message":"Incoming JSON request does not map to API     request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST","debug_id":"8437249fdc6d1"}

As far as I can see the request is correct, I'm authenticating, I've got the correct URL, anyone spot what the problem is? 据我所知,请求是正确的,我正在认证,我具有正确的URL,有人发现问题出在哪里吗?

You have autobill_amount and it should be auto_bill_amount . 您有autobill_amount ,应该为auto_bill_amount You also have initial_amount_fail_action and it should be initial_fail_amount_action . 您也有initial_amount_fail_action ,它应该是initial_fail_amount_action

Right, It was my error not setting the cycles to 0, as this is a continuing payment until someone cancels it, it should be 0 not 12. 是的,我的错误是没有将周期设置为0,因为这是连续付款,直到有人取消它,应该是0而不是12。

So, Corrected request (Which works) 因此,更正了请求(有效)

{
"name": "Membership Fee",
"description": "Monthly Fee with Trial Month",
"type": "infinite",
"payment_definitions": [
    {
        "name": "Free Trial",
        "type": "REGULAR",
        "frequency": "MONTH",
        "frequency_interval": "1",
        "amount": {
            "value": "15",
            "currency": "GBP"
        },
        "cycles": "0"
    },
    {
        "name": "First Month Free Trial",
        "type": "TRIAL",
        "frequency": "MONTH",
        "frequency_interval": "1",
        "amount": {
            "value": "0.01",
            "currency": "GBP"
        },
        "cycles": "1"
    }
],
"merchant_preferences": {
    "setup_fee": {
        "value": "1",
        "currency": "GBP"
    },
    "return_url": "http://app.URLREMOVED.co.uk/complete",
    "cancel_url": "http://app.URLREMOVED.co.uk/cancel",
    "auto_bill_amount": "YES",
    "initial_fail_amount_action": "CONTINUE",
    "max_fail_attempts": "0"
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM