发送发票将返回:“传入的JSON请求未映射到API请求”

时间:2014-01-18 22:16:36

标签: api rest paypal

我正在尝试向客户发送发票,但我收到了:

[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

我发送以下内容: 注意我是json编码,我也试过&没有评论部分。 我的标头应用程序类型是json。 提交网址:https://api.sandbox.paypal.com/v1/payments/payment

$f = array(
        /*"intent" => "sale",
        "redirect_urls" => array(
            "return_url" => "http://www.return.com/",
            "cancel_url" => "http://www.cancel.com/"
        ),
        "payer" => array(
            "payment_method" => "paypal"
        ),
         *
         */
        "requestEnvelope" => array(
            "errorLanguage" => "en_US"
        ),
        "invoice" => array(
            "merchantEmail" => "merchant@domain.com",
            "payerEmail" => "payer@domain.com",
            "currencyCode" => "USD",
            "paymentTerms" => "DueOnReceipt",
            "merchantInfo" => array(
                "address" => array(
                    "line1" => "Address"
                )
            ),
            "itemList" => array(
                "item" => array(
                    array(
                        "name" => "Item1",
                        "quantity" => "25",
                        "unitPrice" => "3"
                    ), array(
                        "name" => "Item2",
                        "quantity" => "32",
                        "unitPrice" => "3"
                    )
                )
            )
        )
    );

1 个答案:

答案 0 :(得分:1)

"invoice" => array( "merchantEmail" => "merchant@domain.com", "payerEmail" => "payer@domain.com", "currencyCode" => "USD", "paymentTerms" => "DueOnReceipt", "merchantInfo" => array( "address" => array( "line1" => "Address" ) )

您应该阅读invoice-object如何宣布https://developer.paypal.com/webapps/developer/docs/api/#invoice-object

E.g。 invoice-object没有密钥merchantEmailpayerEmail ..... 你的阵列是完全错误的