1

我被这个错误困扰了很长一段时间,我不知道如何解决这个问题。我将传递给事务对象的检查数据加倍,甚至三倍,但仍然无法找出为什么它一直向我抛出这个“'' is less than 1 characters long”错误消息。我什至在互联网上找不到该错误消息的文档。

我的代码当前状态的简要概述:

  1. 我的交易对象创建包含在 try..catch 语句(\Paymill\Services\PaymillException) 中

  2. 正确创建了 Client 和 Payment 对象。我可以在我的 paymill 控制面板上看到这两个。

  3. 我也将购物车数组传递给 Transaction 对象

  4. 使用以下序列导出项目描述:trim(substr(html_entity_decode($item['description']), 0, 123)) . "..."

  5. 正在通过信用卡付款

  6. 第一次付款成功第二次付款失败

这是部分异常对象输出:

[__PHP_Incomplete_Class_Name] => Paymill\Services\PaymillException
            [_errorMessage:Paymill\Services\PaymillException:private] => '' is less than 1 characters long
            [_responseCode:Paymill\Services\PaymillException:private] => 
            [_httpStatusCode:Paymill\Services\PaymillException:private] => 400
            [_rawObject:Paymill\Services\PaymillException:private] => 
            [message:protected] => '' is less than 1 characters long
            [string:Exception:private] => 
            [code:protected] => 400
...
[__PHP_Incomplete_Class_Name] => Paymill\Models\Request\Transaction
                                            [_amount:Paymill\Models\Request\Transaction:private] => 6613
                                            [_description:Paymill\Models\Request\Transaction:private] => Order ID: 111111-11111-1111
                                            [_currency:Paymill\Models\Request\Transaction:private] => EUR
                                            [_payment:Paymill\Models\Request\Transaction:private] => pay_1234566789
                                            [_client:Paymill\Models\Request\Transaction:private] => client_123456
                                            [_preauthorization:Paymill\Models\Request\Transaction:private] => 
                                            [_token:Paymill\Models\Request\Transaction:private] => 123456
                                            [_feeAmount:Paymill\Models\Request\Transaction:private] => 
                                            [_feePayment:Paymill\Models\Request\Transaction:private] => 
                                            [_feeCurrency:Paymill\Models\Request\Transaction:private] => 
                                            [_source:Paymill\Models\Request\Transaction:private] => 
                                            [_shippingAddress:Paymill\Models\Request\Transaction:private] => Array
                                                (
                                                    [name] => Full name
                                                    [street_address] => full address
                                                    [street_address_addition] => N/A
                                                    [city] => full city
                                                    [state] => state as well
                                                    [postal_code] => 123456
                                                    [country] => CC
                                                )

                                            [_billingAddress:Paymill\Models\Request\Transaction:private] => Array
                                                (
                                                    [name] => Full name
                                                    [street_address] => full address
                                                    [street_address_addition] => N/A
                                                    [city] => full city
                                                    [state] => state as well
                                                    [postal_code] => 123456
                                                    [country] => CC
                                                    [phone] => 123456
                                                )

                                            [_items:Paymill\Models\Request\Transaction:private] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [name] => full item name
                                                            [amount] => 123456
                                                            [description] => full description
                                                            [quantity] => 1
                                                            [item_number] => 123456-1
                                                            [url] => https://123123.html
                                                        )
...
[_shipping_amount:Paymill\Models\Request\Transaction:private] => 400
                                            [_handling_amount:Paymill\Models\Request\Transaction:private] => 
                                            [_mandateReference:Paymill\Models\Request\Transaction:private] => 
                                            [_id:protected] => 
                                            [_serviceResource:protected] => Transactions/
                                            [_filter:protected] => 
                                        )

                                    [1] => create
                                )

                        )

这就是我发起交易的方式

$transaction->setClient($this->getClient()->getId())
                        ->setPayment($this->getPayment()->getId())
                        ->setToken($this->getToken())
                        ->setAmount($this->getBasket('total')*100)
                        ->setBillingAddress($billing_address)
                        ->setShippingAddress($shipping_address)
                        ->setCurrency($this->getConfig('currency'))
                        ->setItems($items)
                        ->setDescription("Order ID: " . $this->getBasket('cart_order_id'))
                        ->setShippingAmount($this->getBasket('shipping')['value']*100);
            $this->d($this->getClient());
            $r = $this->getRequest()->create($transaction);
4

1 回答 1

1

问题解决了。其中一个项目的描述字段为空。奇怪的是 Exception 没有包含导致问题的字段名称。

于 2016-01-20T14:45:54.960 回答