简体   繁体   中英

Paymill - failed transaction - '' is less than 1 characters long

I got stuck with this error for quite a while and I can't figure out how to solve this problem. I double, even triple, checked data passed to transaction object and still can't find out why it keeps throwing me this " '' is less than 1 characters long " error message. I couldn't even find documentation for that error message on the internet.

Brief overview of current state of my code:

  1. My transaction object creation is wrapped in try..catch statement (\\Paymill\\Services\\PaymillException)

  2. Client and Payment objects created correctly. I can see those two on my paymill control panel.

  3. I'm passing shopping cart array to Transaction object as well

  4. Item description is being derived using this sequence: trim(substr(html_entity_decode($item['description']), 0, 123)) . "..." trim(substr(html_entity_decode($item['description']), 0, 123)) . "..."

  5. Payment is being made via credit card

  6. First payment was successful second one fails

here's partial exception object output:

[__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
                                )

                        )

This is how I initiate transaction

$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);

Problem solved. One of the items was with empty description field. Strange that Exception did not include a field name which was causing problems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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