Paypal REST API item_list必填字段缺失

时间:2016-02-26 16:28:06

标签: php paypal paypal-rest-sdk

我收到一条错误消息,说我的某些商品名称丢失了,但事实并非如此。我有2个不同的案例,但我找不到解释。有人可以帮忙吗?

案例1

是否因为连字符?

请求:

PayPalApiPayment Object
(
    [_propMap:PayPalCommonPayPalModel:private] => Array
        (
            [intent] => sale
            [payer] => PayPalApiPayer Object
                (
                    [_propMap:PayPalCommonPayPalModel:private] => Array
                        (
                            [payment_method] => credit_card
                            [funding_instruments] => Array
                                (
                                    [0] => PayPalApiFundingInstrument Object
                                        (
                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                (
                                                    [credit_card] => PayPalApiCreditCard Object
                                                        (
                                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                (
                                                                    [type] => visa
                                                                    [number] => 4200000000000000
                                                                    [expire_month] => 05
                                                                    [expire_year] => 2018
                                                                    [cvv2] => 456
                                                                    [first_name] => Jean-Sébastien
                                                                    [last_name] => Proulx
                                                                )

                                                        )

                                                )

                                        )

                                )

                        )

                )

            [transactions] => Array
                (
                    [0] => PayPalApiTransaction Object
                        (
                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                (
                                    [amount] => PayPalApiAmount Object
                                        (
                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                (
                                                    [currency] => CAD
                                                    [total] => 47.55
                                                    [details] => PayPalApiDetails Object
                                                        (
                                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                (
                                                                    [shipping] => 0
                                                                    [tax] => 1.64
                                                                    [subtotal] => 45.91
                                                                )

                                                        )

                                                )

                                        )

                                    [item_list] => PayPalApiItemList Object
                                        (
                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                (
                                                    [items] => Array
                                                        (
                                                            [0] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => Homme (12 ans et plus) 300m/10km/2,5km
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 35.00
                                                                        )

                                                                )

                                                            [1] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => Frais TQ Découverte, Dépasse-toi et U11 et moins
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 2.00
                                                                        )

                                                                )

                                                            [2] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => Frais TQ non membre Découverte, Dépasse-toi et U11 et moins
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 5.00
                                                                        )

                                                                )

                                                            [3] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => Frais de service MS1
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 3.91
                                                                        )

                                                                )

                                                        )

                                                )

                                        )

                                    [description] => Triathlon Nitek Laser de Nicolet 2016 - 9e édition
                                    [invoice_number] => trx_56d07478755d4
                                )

                        )

                )

        )

)

响应

Array
(
    [code] => 400
    [Message] => Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
    [data] => {"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].item_list.items[1].name","issue":"Required field missing"},{"field":"transactions[0].item_list.items[2].name","issue":"Required field missing"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"6da4a541e4d25"}
)

案例2

是因为名字以数字开头吗?

请求

PayPalApiPayment Object
(
    [_propMap:PayPalCommonPayPalModel:private] => Array
        (
            [intent] => sale
            [payer] => PayPalApiPayer Object
                (
                    [_propMap:PayPalCommonPayPalModel:private] => Array
                        (
                            [payment_method] => credit_card
                            [funding_instruments] => Array
                                (
                                    [0] => PayPalApiFundingInstrument Object
                                        (
                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                (
                                                    [credit_card] => PayPalApiCreditCard Object
                                                        (
                                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                (
                                                                    [type] => visa
                                                                    [number] => 4222222222222222
                                                                    [expire_month] => 05
                                                                    [expire_year] => 2018
                                                                    [cvv2] => 123
                                                                    [first_name] => Jean-Sébastien
                                                                    [last_name] => Proulx
                                                                )

                                                        )

                                                )

                                        )

                                )

                        )

                )

            [transactions] => Array
                (
                    [0] => PayPalApiTransaction Object
                        (
                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                (
                                    [amount] => PayPalApiAmount Object
                                        (
                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                (
                                                    [currency] => CAD
                                                    [total] => 92.74
                                                    [details] => PayPalApiDetails Object
                                                        (
                                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                (
                                                                    [shipping] => 0
                                                                    [tax] => 9.22
                                                                    [subtotal] => 83.52
                                                                )

                                                        )

                                                )

                                        )

                                    [item_list] => PayPalApiItemList Object
                                        (
                                            [_propMap:PayPalCommonPayPalModel:private] => Array
                                                (
                                                    [items] => Array
                                                        (
                                                            [0] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => TRAIL 11 KM
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 55.00
                                                                        )

                                                                )

                                                            [1] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => 1 billet invité pour le souper spaghetti
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 7.00
                                                                        )

                                                                )

                                                            [2] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => 1 Billet Invité BBQ
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 15.00
                                                                        )

                                                                )

                                                            [3] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => T-shirt
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 0.00
                                                                        )

                                                                )

                                                            [4] => PayPalApiItem Object
                                                                (
                                                                    [_propMap:PayPalCommonPayPalModel:private] => Array
                                                                        (
                                                                            [name] => Frais de service MS1
                                                                            [currency] => CAD
                                                                            [quantity] => 1
                                                                            [price] => 6.52
                                                                        )

                                                                )

                                                        )

                                                )

                                        )

                                    [description] => Festival Ultimate Xc Kmag 2016
                                    [invoice_number] => trx_56cf5aed4ba51
                                )

                        )

                )

        )

)

响应

Array
(
    [code] => 400
    [Message] => Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
    [data] => {"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].item_list.items[1].name","issue":"Required field missing"},{"field":"payer.funding_instruments[0].credit_card.number","issue":"Value is invalid"},{"field":"transactions[0].item_list.items[2].name","issue":"Required field missing"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"bf092633bbc19"}
)

1 个答案:

答案 0 :(得分:0)

现在这很令人尴尬。

这里有法国口音的典型案例。 UTF-8 FTW。