MultiSafepay / opencart

MultiSafepay OpenCart plugin
5 stars 7 forks source link

Working with customer balance problem #6

Closed dennisbuijsgmailcom closed 2 years ago

dennisbuijsgmailcom commented 2 years ago

Hi

When I pay an order with customer account that has a balance amount available, this balance amount is always just in the Multisafepay transaction, see attachement. Two things, you can see it does not check the order total against the balance amount, so I must pay a negative amount. Second when in the order I don't use credits, so total['credit'] is not available, I don't want to see it in Multisafepay.

So I change the code to check if total credit is available and use that amount in the order. See code below.

private function getCustomerBalanceItem($order_id) { $order_totals = $this->getOrderTotals($order_id); / Dennis / $has_credit = array_search('credit', array_column($order_totals, 'code')); if ($has_credit === false) { return false; }

    $this->load->language($this->route);
    $customer_additional_data = $this->getAdditionalCustomerData();
    $order_info = $this->getOrderInfo($order_id);
    return $this->getNegativeCartItemObject(
        -$order_totals[$has_credit]['value'], // Dennis $customer_additional_data['customer_balance'],
        $order_info,
        $this->language->get('text_customer_balance'),
        1,
        'CREDIT',
        0
    );
}

Also on line about 107 an extra check:

// Customer Balance - Credit $customer_additional_data = $this->getAdditionalCustomerData(); if ($customer_additional_data['customer_balance'] > 0) { $customer_balance_item = $this->getCustomerBalanceItem($order_id); / Dennis / if ($customer_balance_item) { $shopping_cart_items[$this->config->get($this->total_extension_key_prefix . 'credit_sort_order')][] = $customer_balance_item; } }

danielcivit commented 2 years ago

Hello Dennis.

We have been spoken in our internal ticket system, but now I would like to share some comments here, because it could be positive for someone else.

By default in a clean OpenCart, when the customer balance is positive it will always be included in the order. The customer do not have any choice about this. Is not like a coupon, or like a gift voucher in which a code is needed. However is clear your feedback and proposal are good to improve our support for third party extensions (like the one you are using) and after some small modifications, now this should work properly in our latest release 3.13.0.

If you still experiment any issue, feel free to reopen this Github issue or open any other.

Thanks again for report this issue and for your feedback.