Skip to content

Commit

Permalink
hotfix/empty-lines
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihtoprak committed Dec 29, 2021
1 parent 8722f43 commit 593ab04
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
3 changes: 1 addition & 2 deletions core/library/Moka_Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public function generateInstallmentsTableHtml($params)

foreach($storedData as $perStoredInstallmentKey => $perStoredInstallment)
{

$return.='<tr>';
$imagePath = plugins_url( 'moka-woocommerce-master/assets/img/cards/banks/' );

Expand Down Expand Up @@ -349,7 +348,7 @@ private function doRequest($method, $params)
* @param [array] $response
* @return void
*/
private function formatInstallmentResponse($response)
public function formatInstallmentResponse($response)
{
$output = [];

Expand Down
30 changes: 23 additions & 7 deletions core/library/Optimisthub_Ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ class Optimisthub_Ajax
{
public function __construct()
{
$this->mokaPayRequest = new MokaPayment();
$this->mokaOptions = get_option('woocommerce_mokapay_settings');
$this->installments = get_option('woocommerce_mokapay-installments');
$this->installments = get_option('woocommerce_mokapay-installments') ? get_option('woocommerce_mokapay-installments') : self::generateDynamicInstallmentData();
$this->currency = get_option('woocommerce_currency');
$this->enableInstallment = 'yes' === data_get($this->mokaOptions, 'installment');

Expand Down Expand Up @@ -37,27 +38,25 @@ public function validate_bin($params)
$mokaPay = new MokaPayment();
$response = $mokaPay->requestBin(['binNumber' => $binNumber]);


## installments
$bankCode = mb_strtolower(data_get($response, 'BankCode'));
$bankGroup = mb_strtolower(data_get($response, 'GroupName'));

$installments = self::fetchInstallment();

$avaliableInstallment = null;
if($bankGroup)
{

foreach($installments as $perInstallment)
{
if($perInstallment['groupName'] == $bankGroup)
{
$avaliableInstallment = $perInstallment;
}
}
}
## installments
}


## installments
$data= [
'cardInformation' => $response,
'installments' => $avaliableInstallment,
Expand Down Expand Up @@ -208,6 +207,23 @@ private function calculateComissionRate( $total, $percent, $installment )
return number_format(($total/$installment),2);
}

/**
* Set dynamic installment table from live server
*
* @return void
*/
private function generateDynamicInstallmentData()
{
$list = $this->mokaPayRequest->getInstallments();
$list = data_get($list, 'CommissionList');

if(!$list)
{
return false;
}
return $this->mokaPayRequest->formatInstallmentResponse($list);
}

}

new Optimisthub_Ajax();

0 comments on commit 593ab04

Please sign in to comment.