0

I'm not able of solve this problem, I'm stuck here trying figure out what is happening, i installed a payment extension, and when i try pay the product with a credit card, everything works, my payment server confirms the transation and the OpenCart sends email both to seller and to costumer, the problem is, after finish the transation, OpenCart is not adding the order history, to seller and to the costumer, I tryed look on the extension source code, but everything looks fine to me. i ask about it to other people and no one have problems with this extension. the log files just output:

2017-08-19 4:50:29 - FEE5D6-AF8F438F43BD-F004C9EFA444-E7BD05

and this is the piece of js at payment extension whitch call the function to confirm the payment:

PagSeguroDirectPayment.createCardToken({
            cardNumber: $('input#numero-cartao').val(),
            brand: $('input#bandeira').val(),
            cvv: $('input#cvv').val(),
            expirationMonth: expiration[0],
            expirationYear: expiration[1],
            success: function(data) {
                $.ajax({
                    url: 'index.php?route=extension/payment/pagseguro_cartao/transition',
                    data: 'creditCardToken=' + data.card.token + '&senderHash=' + PagSeguroDirectPayment.getSenderHash() + '&installmentQuantity=' + $('select#parcelas option:selected').attr('data-value') + '&installmentValue=' + $('select#parcelas').val() + '&creditCardHolderName=' + $('input#nome').val() + '&creditCardHolderCPF=' + $('input#cpf').val() + '&creditCardHolderBirthDate=' + $('input#data-nascimento').val() + '&creditCardHolderPhone=' + $('input#telefone').val(),
                    type: 'POST',
                    dataType: 'JSON',
                    success: function(data){
                        if (data.error) {
                            $('#warning').html( getError(data.error.code, data.error.message) ).show();
                        } else {
                            $('#button-confirm').attr('disabled');

                            $.ajax({
                                url: 'index.php?route=extension/payment/pagseguro_cartao/confirm',
                                data: 'status=' + data.status,
                                type: 'POST',
                                success: function() {
                                    /*location.href = '{{ continue }}'*/
                                }
                            });
                        }
                    },
                    complete: function(data) {
                        $('#button-confirm').button('reset');
                    }
                });
            },
            error: function(data) {
                console.log(data);
                var html = '<ul>';
                $.each(data.errors, function(i,e){
                    html += '<li>' + getError(i,e) + '</li>';
                });
                html += '</ul>';

                $('#warning').html(html).show();

                $('#button-confirm').button('reset');
            }
        });
    });

and the controller at catalog/controller/extension/payment:

public function confirm() {
        $this->load->model('checkout/order');

        switch ($this->request->post['status']) {
            case 1:
                $status = $this->config->get('payment_pagseguro_aguardando_pagamento');
                break;
            case 2:
                $status = $this->config->get('payment_pagseguro_analise');
                break;
            case 3:
                $status = $this->config->get('payment_pagseguro_paga');
                break;
            case 4:
                $status = $this->config->get('payment_pagseguro_disponivel');
                break;
            case 5:
                $status = $this->config->get('payment_pagseguro_disputa');
                break;
            case 6:
                $status = $this->config->get('payment_pagseguro_devolvida');
                break;
            case 7:
                $status = $this->config->get('payment_pagseguro_cancelada');
                break;
            default: 
                $status = $this->config->get('payment_pagseguro_aguardando_pagamento');
                break;
        }

        $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $status);

        if (isset($this->session->data['order_id'])) {
            $this->cart->clear();
            unset($this->session->data['shipping_method']);
            unset($this->session->data['shipping_methods']);
            unset($this->session->data['payment_method']);
            unset($this->session->data['payment_methods']);
            unset($this->session->data['comment']);
            unset($this->session->data['coupon']);
            unset($this->session->data['pagseguro_desconto']);
            unset($this->session->data['pagseguro_acrescimo']);
        }
    }
}
Vy Do
  • 46,709
  • 59
  • 215
  • 313

1 Answers1

0

Apparently all the order history ajax calls from the admin area, run through the API. Which API controller is in the catalog folder. So, if you have redirection rules into your .htaccess file, then the whole ajax request doesn't work.

I would suggest you, to run Console from Google Chrome or Firefox and open the Network tab. When you add a new Order History, check the response from the server. You will find the problem.

Konstantinos
  • 418
  • 3
  • 10
  • my logs now output something about undefined index order_id when call the function addOrderHistory ```$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $status);``` –  Sep 08 '17 at 13:55