PrestaShopCorp / ogone

0 stars 7 forks source link

Double payment in Order detail page #9

Open tarekfellah opened 7 years ago

tarekfellah commented 7 years ago

In Validation.php, there's an OrderPayment creation, i think it shouldn't be if ($order->total_paid_real == $order->total_paid && $amount_paid == $order->total_paid) {

                if (version_compare(_PS_VERSION_, '1.5', 'ge')) {
                    $ogone->log('Saving payment info');
                    /*$payment = new OrderPayment();
                    $payment->order_reference = $order->reference;
                    $payment->amount = $amount_paid;
                    $payment->id_currency = $order->id_currency;
                    $payment->payment_method = $ogone->displayName;
                    $payment->transaction_id =  isset($ogone_params['PAYID']) ? $ogone_params['PAYID'] :  '';
                    $payment->card_number =  isset($ogone_params['CARDNO']) ? $ogone_params['CARDNO'] :  '';
                    $payment->card_brand =  isset($ogone_params['BRAND']) ? $ogone_params['BRAND'] :  '';
                    $payment->card_expiration =  isset($ogone_params['ED']) ? $ogone_params['ED'] :  '';
                    $payment->card_holder =  isset($ogone_params['CN']) ? $ogone_params['CN'] :  '';
                    $payment->save();*/

                }
                $ogone->log('Adding history ' . $payment_state_id . ' ' . $existing_id_order);

                /* Send a new message and change the state */
                $history = new OrderHistory();
                $history->id_order = (int) $existing_id_order;
                $history->changeIdOrderState($payment_state_id, (int) $existing_id_order, true);
                $history->addWithemail(true, array());

            }

In PaymentModule class, there's a call to addOrderPayment that adds an Order Payment when order status is logable, or Remote Payment Accepted in logable. I think the code for Order Payment creation is useless, and it creates a double Payments.