Skip to content

Custom payment capture not work after update from 2.0.7 to 2.1.0 #5324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mauromm opened this issue Jun 28, 2016 · 4 comments
Closed

Custom payment capture not work after update from 2.0.7 to 2.1.0 #5324

mauromm opened this issue Jun 28, 2016 · 4 comments
Assignees

Comments

@mauromm
Copy link

mauromm commented Jun 28, 2016

When I use a custom payment method, and I am capturing the payment in a custom model, I get the following error:

"Unable to place order. Please try again later."

Debugging, I found:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'base_grand_total' in 'field list', query was:
INSERT INTO sales_invoice_grid (entity_id, increment_id, state, store_id, store_name, order_id, order_increment_id, order_created_at, customer_name, customer_email, customer_group_id, payment_method, store_currency_code, order_currency_code, base_currency_code, global_currency_code, billing_name, billing_address, shipping_address, shipping_information, subtotal, shipping_and_handling, base_grand_total, grand_total, created_at, updated_at) SELECT sales_invoice.entity_id AS entity_id, sales_invoice.increment_id AS increment_id, sales_invoice.state AS state, sales_invoice.store_id AS store_id, sales_order.store_name AS store_name, sales_invoice.order_id AS order_id, sales_order.increment_id AS order_increment_id, sales_order.created_at AS order_created_at, TRIM(CONCAT_WS(' ', IF(sales_order.customer_firstname <> '', sales_order.customer_firstname, NULL), IF(sales_order.customer_lastname <> '', sales_order.customer_lastname, NULL))) AS customer_name, sales_order.customer_email AS customer_email, sales_order.customer_group_id AS customer_group_id, sales_order_payment.method AS payment_method, sales_invoice.store_currency_code AS store_currency_code, sales_invoice.order_currency_code AS order_currency_code, sales_invoice.base_currency_code AS base_currency_code, sales_invoice.global_currency_code AS global_currency_code, TRIM(CONCAT_WS(' ', IF(sales_billing_address.firstname <> '', sales_billing_address.firstname, NULL), IF(sales_billing_address.lastname <> '', sales_billing_address.lastname, NULL))) AS billing_name, TRIM(CONCAT_WS(' ', IF(sales_billing_address.street <> '', sales_billing_address.street, NULL), IF(sales_billing_address.city <> '', sales_billing_address.city, NULL), IF(sales_billing_address.region <> '', sales_billing_address.region, NULL), IF(sales_billing_address.postcode <> '', sales_billing_address.postcode, NULL))) AS billing_address, TRIM(CONCAT_WS(' ', IF(sales_shipping_address.street <> '', sales_shipping_address.street, NULL), IF(sales_shipping_address.city <> '', sales_shipping_address.city, NULL), IF(sales_shipping_address.region <> '', sales_shipping_address.region, NULL), IF(sales_shipping_address.postcode <> '', sales_shipping_address.postcode, NULL))) AS shipping_address, sales_order.shipping_description AS shipping_information, sales_order.base_subtotal AS subtotal, sales_order.base_shipping_amount AS shipping_and_handling, sales_invoice.base_grand_total AS base_grand_total, sales_invoice.grand_total AS grand_total, sales_invoice.created_at AS created_at, sales_invoice.updated_at AS updated_at FROM sales_invoice
LEFT JOIN sales_order ON sales_invoice.order_id = sales_order.entity_id
LEFT JOIN sales_order_address AS sales_shipping_address ON sales_invoice.shipping_address_id = sales_shipping_address.entity_id
LEFT JOIN sales_order_address AS sales_billing_address ON sales_invoice.billing_address_id = sales_billing_address.entity_id
LEFT JOIN sales_order_payment ON sales_invoice.order_id = sales_order_payment.parent_id WHERE (sales_invoice.entity_id = '24') ON DUPLICATE KEY UPDATE entity_id = VALUES(entity_id), increment_id = VALUES(increment_id), state = VALUES(state), store_id = VALUES(store_id), store_name = VALUES(store_name), order_id = VALUES(order_id), order_increment_id = VALUES(order_increment_id), order_created_at = VALUES(order_created_at), customer_name = VALUES(customer_name), customer_email = VALUES(customer_email), customer_group_id = VALUES(customer_group_id), payment_method = VALUES(payment_method), store_currency_code = VALUES(store_currency_code), order_currency_code = VALUES(order_currency_code), base_currency_code = VALUES(base_currency_code), global_currency_code = VALUES(global_currency_code), billing_name = VALUES(billing_name), billing_address = VALUES(billing_address), shipping_address = VALUES(shipping_address), shipping_information = VALUES(shipping_information), subtotal = VALUES(subtotal), shipping_and_handling = VALUES(shipping_and_handling), base_grand_total = VALUES(base_grand_total), grand_total = VALUES(grand_total), created_at = VALUES(created_at), updated_at = VALUES(updated_at)

In my model:

public function order(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
.....
    $transaction = $this->transactionBuilder->setPayment($payment)
         ->setOrder($order)
         ->build(Transaction::TYPE_AUTH)
....
    return $this;
}

When I look into the table sales_invoice_grid , the column base_grand_total does not exist.

On my updated magento 2.1.0, looking into:
.../vendor/magento/module-sales/Setup/InstallSchema.php line 3219

        ->addColumn(
            'base_grand_total',
            \Magento\Framework\DB\Ddl\Table::TYPE_DECIMAL,
            '12,4',
            [],
            'Base Grand Total'

However, I compared the same file in another magento 2.0.7 and column was not added in InstallSchema. When I updated, this column must be added in UpgradeSchema and not in InstallSchema because the column never is added into the updated magento.

To solve the problem I updated the table:

ALTER TABLE `sales_invoice_grid`
    ADD COLUMN `base_grand_total` DECIMAL(12,4) NULL DEFAULT NULL COMMENT 'Base Grand Total' AFTER `grand_total`;
@antonlazarchenko
Copy link

Hi, @mauromm ! I confirm this solution works. Thanx a lot.

@NadiyaS
Copy link
Contributor

NadiyaS commented Jul 1, 2016

Hi @mauromm ,
thanks for reporting this issue. It is already being tracked by MAGETWO-54787 ticket and fix will be delivered soon.
This issue will be closed as duplicate of #4785.

@liquidia
Copy link

liquidia commented Aug 1, 2016

Hi, @mauromm, this fix worked for me too .. but my developer told me this might cause issue with magneto core updates in future(db integrity or corruption of db and or inability to upgrade ). i could not wait for the 2.1.1 as site is up should i be worried about this fix?

Thanks

@davidplopes
Copy link

Works for me too thanks!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants