Skip to content

Commit

Permalink
3.0.2 released.
Browse files Browse the repository at this point in the history
  • Loading branch information
fatihtoprak committed Oct 19, 2022
1 parent 50f07ca commit 07b71b6
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 95 deletions.
11 changes: 8 additions & 3 deletions core/library/Moka_Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public function setInstallments($params)
public function generateInstallmentsTableHtml($params)
{

$assetDir = str_replace('/core/library/', '/assets/' , plugin_dir_url( __FILE__ ));


$storedData = get_option( 'woocommerce_mokapay-installments' );
$avaliableInstallmentsCount = data_get($params, 'maxInstallment');
$paymentId = data_get($params, 'paymentGatewayId');
Expand All @@ -198,7 +201,7 @@ public function generateInstallmentsTableHtml($params)
foreach($storedData as $perStoredInstallmentKey => $perStoredInstallment)
{
$return.='<tr>';
$imagePath = plugins_url( 'moka-woocommerce-master/assets/img/cards/banks/' );
$imagePath = $assetDir. '/img/cards/banks/';

$return.= '<tr>';
$cardImageSlug = data_get($perStoredInstallment, 'groupName');
Expand Down Expand Up @@ -250,7 +253,7 @@ public function generateInstallmentsTableHtml($params)
*/
public function generateInstallmentsTableShortcode()
{

$storedData = get_option( 'woocommerce_mokapay-installments' );

if(!$storedData)
Expand All @@ -266,12 +269,14 @@ public function generateInstallmentsTableShortcode()
}

$return.= '</tr></thead>';

$assetDir = str_replace('/core/library/', '/assets/' , plugin_dir_url( __FILE__ ));

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

$return.='<tr>';
$imagePath = plugins_url( 'moka-woocommerce-master/assets/img/cards/banks/' );
$imagePath = $assetDir.'img/cards/banks/';
$cardImageSlug = data_get($perStoredInstallment, 'groupName');
$cardSymbol = '<img style="width:100px !important;max-width:unset;" src="'.$imagePath.$cardImageSlug.'.svg" />';
if(!$cardImageSlug)
Expand Down
21 changes: 14 additions & 7 deletions core/library/Moka_Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OptimistHub_Moka_Gateway extends WC_Payment_Gateway {

public function __construct()
{

$this->id = 'mokapay';
$this->icon = ''; // TODO : Moka Icon
$this->has_fields = true;
Expand Down Expand Up @@ -691,6 +691,9 @@ private function formatOrder( $orderId )
$getAmount = $order->get_total();
$customerId = $order->get_user_id();

$orderItems = $order->get_items();
$hasSubscription = $this->isOrderHasSubscriptionProduct($orderItems);

$orderData = [
'CardHolderFullName' => (string) data_get($postData, $this->id.'-name-oncard'),
'CardNumber' => (string) self::formatCartNumber(data_get($postData, $this->id.'-card-number')),
Expand Down Expand Up @@ -736,6 +739,11 @@ private function formatOrder( $orderId )
// TODO : Basket Product Details
//'BasketProduct' => self::formatBaksetProducts($order),
];

if($hasSubscription)
{
$orderData['Description'] = 'RecurringPayment-'.$orderId;
}

return $orderData;

Expand Down Expand Up @@ -1290,19 +1298,18 @@ private function getSubscriptionProductPeriod($orderItems)
$__data = get_post_meta($productId);
$__per = data_get($__data, '_period_per.0', null);
$__in = data_get($__data, '_period_in.0', null);

$__inString = ['gun' => 'day', 'ay' => 'month', 'hafta' => 'week'];

$currentTime = Carbon::parse(current_datetime()->format('Y-m-d H:i:s'));
$__per = str_replace(['her-','her_', 'her'], '1', $__per);

$nextTry = $currentTime::now()->add($__per, $__inString[$__in]);
$nextTry = $currentTime::now()->add($__per, $__in);

$period = [
'current_time' => Carbon::parse($currentTime)->format('Y-m-d H:i:s'),
'next_try' => Carbon::parse($nextTry)->format('Y-m-d H:i:s'),
'period_string' => $__per.'-'.$__inString[$__in],
];
'period_string' => $__per.' '.$__in,
];

ray($period);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions core/library/Moka_Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exit;
}

define('OPTIMISTHUB_MOKA_PAY_VERSION', '3.0.1');
define('OPTIMISTHUB_MOKA_PAY_VERSION', '3.0.2');

global $mokaVersion;
$mokaVersion = OPTIMISTHUB_MOKA_PAY_VERSION;
Expand Down Expand Up @@ -65,7 +65,8 @@ public function optimisthubDashBoardWidgetInit()
*/
public function recentNewsByOptimisthub()
{
echo '<p><strong>Ücretsiz</strong> Moka POS WooCommerce Eklentisi Optimist Hub Bünyesinde geliştirilmiştir. Açık kaynak kodlu eklentiye sizler de katkıda bulunabilirsiniz. <a href="https://github.com/optimisthub/moka-woocommerce">></a></p> <p style="display:flex;justify-content:center;align-items:center"> <a href="https://optimisthub.com/?ref='. get_bloginfo("wpurl").'&source=moka-woocommerce" target="_blank"> <img style="width:220px" src="'.plugins_url( 'moka-woocommerce-master/assets/img/optimisthub.svg' ).'" alt=""> </a> </p>';
$assetDir = str_replace('/core/library/', '/assets/' , plugin_dir_url( __FILE__ ));
echo '<p><strong>Ücretsiz</strong> Moka POS WooCommerce Eklentisi Optimist Hub Bünyesinde geliştirilmiştir. Açık kaynak kodlu eklentiye sizler de katkıda bulunabilirsiniz. <a href="https://github.com/optimisthub/moka-woocommerce">></a></p> <p style="display:flex;justify-content:center;align-items:center"> <a href="https://optimisthub.com/?ref='. get_bloginfo("wpurl").'&source=moka-woocommerce" target="_blank"> <img style="width:220px" src="'.$assetDir.'/img/optimisthub.svg'.'" alt=""> </a> </p>';
}

}
Expand Down
33 changes: 18 additions & 15 deletions core/library/Moka_Subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ public function registerSubscriptionProductTabContent($tabs)
'label' => __( 'Abonelik Periyodu', 'moka-woocommerce' ),
'value' => $product_object->get_meta( '_period_per', true ),
'options' => [
'her' => 'Her',
'her_2' => 'Her 2.',
'her_3' => 'Her 3.',
'her_4' => 'Her 4.',
'1' => 'Her',
'2' => 'Her 2.',
'3' => 'Her 3.',
'4' => 'Her 4.',
],
'default' => '',
'placeholder' => __( 'Period', 'moka-woocommerce' ),
Expand All @@ -219,7 +219,7 @@ public function registerSubscriptionProductTabContent($tabs)
'class' => 'select short',
'label' => '',
'value' => $product_object->get_meta( '_period_in', true ),
'options' => ['gun' => 'Gün','hafta' => 'Hafta', 'ay' => 'Ay'],
'options' => ['day' => 'Gün','week' => 'Hafta', 'month' => 'Ay', 'year'=> 'Yıl'],
'default' => '',
'placeholder' => __( 'Period', 'moka-woocommerce' ),
]
Expand Down Expand Up @@ -301,7 +301,8 @@ public function addToCartButtonProductSummary()
<?php echo __("Subscribe", "moka-woocommerce"); ?>
</a>
</p>
<p><?php echo "<br>".__('Renewal Period', 'moka-woocommerce').' : '.__($periodString, 'moka-woocommerce'); ?></p>
<p><?php echo "<br>".__('Renewal Period', 'moka-woocommerce').' : '.data_get($period, '_period_per.0'). ' ' .__(data_get($period,'_period_in.0'), 'moka-woocommerce'); ?>
</p>
<?php do_action( 'woocommerce_after_add_to_cart_button' );
}
}
Expand All @@ -318,10 +319,10 @@ public function displayCartItemCustomMetaData( $itemData, $cartItem )
{
$productId = data_get($cartItem, 'product_id');
$period = get_post_meta($productId);
$periodString = data_get($period, '_period_per.0'). ' ' .data_get($period,'_period_in.0');
$periodString = data_get($period, '_period_per.0'). ' ' .__(data_get($period,'_period_in.0'), 'moka-woocommerce');
$itemData[] = [
'key' => __('Renewal Period', 'moka-woocommerce'),
'value' => __($periodString, 'moka-woocommerce'),
'value' => $periodString,
'display' => '',
];
return $itemData;
Expand Down Expand Up @@ -515,10 +516,11 @@ public function runSubscriptionPayments()
'Description' => 'RecurringPayment-'.$orderId,
'isSubscriptionPayment' => true,
];


$doPayment = $payment->initializePayment($requestParams);
$isSuccess = data_get($doPayment, 'Data.IsSuccessful');

if($isSuccess)
{
// Save Log
Expand All @@ -538,17 +540,18 @@ public function runSubscriptionPayments()
// Update Subscription information
$subscriptionPeriod = data_get($perValue, 'subscription_period');
$currentTime = Carbon::parse(current_datetime()->format('Y-m-d H:i:s'));
$__inString = ['day', 'month', 'week'];

$__per = str_replace(['her-', 'her_'], '1 ', $subscriptionPeriod);
$__per = explode('-',$__per);

$__data = get_post_meta($productId);
$__per = data_get($__data, '_period_per.0', null);
$__in = data_get($__data, '_period_in.0', null);

$nextTry = $currentTime::now()->add($__per, $__in);

$nextTry = $currentTime::now()->add($__per[0],$__per[1]);

$period = [
'current_time' => Carbon::parse($currentTime)->format('Y-m-d H:i:s'),
'next_try' => Carbon::parse($nextTry)->format('Y-m-d H:i:s'),
'period_string' => implode('-',$__per),
'period_string' => $__per.' '.$__in,
];

$wpdb->query(
Expand Down
4 changes: 3 additions & 1 deletion core/library/static/Optimisthub.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
<hr>
<br>
<a href="https://optimisthub.com/?ref=<?php echo get_bloginfo('wpurl'); ?>&source=moka-woocommerce" target="_blank">
<img style="width:220px" src="<?php echo plugins_url( 'moka-woocommerce-master/assets/img/optimisthub.svg' ); ?>" alt="">
<img style="width:220px"
src="<?php echo str_replace('/core/library/', '/assets/' , plugin_dir_url( __FILE__ )).'/img/optimisthub.svg'; ?>"
alt="">
</a>
<p><strong>Ücretsiz</strong> Moka POS WooCommerce Eklentisi Optimist Hub Bünyesinde geliştirilmiştir.</p>

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Moka Payment Gateway for WooCommerce
* Plugin URI: https://github.com/optimisthub/moka-woocommerce
* Description: Moka Payment gateway for woocommerce
* Version: 3.0.1
* Version: 3.0.2
* Author: Optimist Hub
* Author URI: https://optimisthub.com?ref=mokaPayment
* Domain Path: /languages/
Expand Down
Binary file modified languages/moka-woocommerce-en_US.mo
Binary file not shown.
42 changes: 9 additions & 33 deletions languages/moka-woocommerce-en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-08T11:49:40+00:00\n"
"PO-Revision-Date: 2022-09-06 16:26+0300\n"
"PO-Revision-Date: 2022-10-20 01:49+0300\n"
"Last-Translator: Fatih Toprak <patron@fatihtoprak.com>\n"
"Language-Team: \n"
"Language: en_US\n"
Expand Down Expand Up @@ -155,41 +155,17 @@ msgstr "Subscribe"
msgid "Renewal Period"
msgstr "Renewal Period"

msgid "her gun"
msgstr "Daily"
msgid "day"
msgstr "day"

msgid "her hafta"
msgstr "Weekly"
msgid "week"
msgstr "week"

msgid "her ay"
msgstr "Monthly"
msgid "month"
msgstr "month"

msgid "her_2 gun"
msgstr "Every two days"

msgid "her_2 hafta"
msgstr "Every two weeks"

msgid "her_2 ay"
msgstr "Every two months"

msgid "her_3 gun"
msgstr "Every three days"

msgid "her_3 hafta"
msgstr "Every three weeks"

msgid "her_3 ay"
msgstr "Every three months"

msgid "her_4 gun"
msgstr "Every four days"

msgid "her_4 hafta"
msgstr "Every four weeks"

msgid "her_4 ay"
msgstr "Every four months"
msgid "year"
msgstr "year"

msgid "Subscription"
msgstr "Subscription"
Expand Down
Binary file modified languages/moka-woocommerce-tr_TR.mo
Binary file not shown.
42 changes: 9 additions & 33 deletions languages/moka-woocommerce-tr_TR.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-08T11:49:40+00:00\n"
"PO-Revision-Date: 2022-09-06 16:26+0300\n"
"PO-Revision-Date: 2022-10-20 01:49+0300\n"
"Last-Translator: Fatih Toprak <patron@fatihtoprak.com>\n"
"Language-Team: \n"
"Language: tr_TR\n"
Expand Down Expand Up @@ -156,41 +156,17 @@ msgstr "Aboneliği Başlat"
msgid "Renewal Period"
msgstr "Yenilenme Periyodu"

msgid "her gun"
msgstr "Günlük"
msgid "day"
msgstr "gün"

msgid "her hafta"
msgstr "Haftalık"
msgid "week"
msgstr "hafta"

msgid "her ay"
msgstr "Aylık"
msgid "month"
msgstr "ay"

msgid "her_2 gun"
msgstr "Her iki günde bir"

msgid "her_2 hafta"
msgstr "Her iki haftada bir"

msgid "her_2 ay"
msgstr "Her iki ayda bir"

msgid "her_3 gun"
msgstr "Her üç günde bir"

msgid "her_3 hafta"
msgstr "Her üç haftada bir"

msgid "her_3 ay"
msgstr "Her üç ayda bir"

msgid "her_4 gun"
msgstr "Her dört günde bir"

msgid "her_4 hafta"
msgstr "Her dört haftada bir"

msgid "her_4 ay"
msgstr "Her dört ayda bir"
msgid "year"
msgstr "yıl"

msgid "Subscription"
msgstr "Abonelikler"
Expand Down

0 comments on commit 07b71b6

Please sign in to comment.