Skip to content

Commit

Permalink
fix: Removendo linhas não utilizadas
Browse files Browse the repository at this point in the history
  • Loading branch information
lucastgama committed Jul 30, 2024
1 parent efb678b commit 56d1fd7
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions src/includes/gateways/CreditPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,8 @@ public function payment_fields()
{
$cart = $this->vindi_settings->woocommerce->cart;
$order_id = filter_input(INPUT_GET, 'order_id', FILTER_SANITIZE_NUMBER_INT) ?? absint(get_query_var('order-pay'));

$total = $this->calculate_total($order_id, $cart);

$installments = $this->build_cart_installments($total);

$user_payment_profile = $this->build_user_payment_profile();
$payment_methods = $this->routes->getPaymentMethods();

Expand Down Expand Up @@ -169,7 +166,6 @@ private function calculate_total($order_id, $cart)
} else {
$total = $this->get_cart_total($cart);
}

return $total;
}

Expand Down Expand Up @@ -215,7 +211,6 @@ public function build_cart_installments($total)
$installments[$times] = $this->get_cart_installments($times, $total);
}
}

return $installments;
}

Expand Down Expand Up @@ -248,12 +243,7 @@ public function get_cart_total($cart)

public function verify_user_payment_profile()
{
$old_payment_profile = (int) filter_input(
INPUT_POST,
'vindi-old-cc-data-check',
FILTER_SANITIZE_NUMBER_INT
);

$old_payment_profile = (int) filter_input(INPUT_POST,'vindi-old-cc-data-check',FILTER_SANITIZE_NUMBER_INT);
return 1 === $old_payment_profile;
}

Expand All @@ -277,7 +267,6 @@ protected function get_order_max_installments($order_total)
if ($this->is_single_order()) {
$order_max_times = floor($order_total / $this->smallest_installment);
$max_times = empty($order_max_times) ? 1 : $order_max_times;

return min($this->max_installments, $max_times, $this->get_installments());
}
return $this->get_installments();
Expand All @@ -289,21 +278,17 @@ private function build_user_payment_profile()
$user_vindi_id = get_user_meta(wp_get_current_user()->ID, 'vindi_customer_id', true);
$payment_profile = WC()->session->get('current_payment_profile');
$current_customer = WC()->session->get('current_customer');

if (!isset($payment_profile) || ($current_customer['code'] ?? null) != $user_vindi_id) {
$payment_profile = $this->routes->getPaymentProfile($user_vindi_id);
}

if (($payment_profile['type'] ?? null) !== 'PaymentProfile::CreditCard') {
return $user_payment_profile;
}

if (false === empty($payment_profile)) {
$user_payment_profile['holder_name'] = $payment_profile['holder_name'];
$user_payment_profile['payment_company'] = $payment_profile['payment_company']['code'];
$user_payment_profile['card_number'] = sprintf('**** **** **** %s', $payment_profile['card_number_last_four']);
}

WC()->session->set('current_payment_profile', $payment_profile);
return $user_payment_profile;
}
Expand All @@ -312,9 +297,7 @@ protected function get_installments()
{
if ($this->is_single_order())
return $this->installments;

$installments = 0;

foreach ($this->vindi_settings->woocommerce->cart->cart_contents as $item) {
$plan_id = $item['data']->get_meta('vindi_plan_id');

Expand Down

0 comments on commit 56d1fd7

Please sign in to comment.