【问题标题】:Paymill - failed transaction - '' is less than 1 characters longPaymill - 交易失败 - '' 长度小于 1 个字符
【发布时间】:2016-01-17 15:52:50
【问题描述】:

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

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

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

  2. 正确创建了客户端和付款对象。我可以在我的 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);

【问题讨论】:

    标签: php api transactions paymill


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-11
      • 2020-04-13
      • 2012-12-28
      • 2014-04-09
      • 1970-01-01
      • 1970-01-01
      • 2015-08-27
      • 1970-01-01
      相关资源
      最近更新 更多