Skip to content

Commit

Permalink
+new version
Browse files Browse the repository at this point in the history
  • Loading branch information
feyzullahdemir committed May 16, 2023
1 parent 0a48e71 commit 2720906
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 173 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added iyzico/.DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions iyzico/admin/controller/payment/iyzico.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class iyzico extends \Opencart\System\Engine\Controller {
private $error = array();
private $iyzico;
private $module_version = VERSION;
private $module_product_name = '1.6';
private $module_product_name = '2.0';


private $fields = array(
Expand Down Expand Up @@ -148,7 +148,7 @@ public function index(): void
$data['footer'] = $this->load->controller('common/footer');
$data['locale'] = $this->language->get('code');
$data['iyzico_webhook_url_key'] = $this->config->get('webhook_iyzico_webhook_url_key');
$data['iyzico_webhook_url'] = HTTP_CATALOG.'index.php?route=extension/iyzico/payment/iyzico|webhook&key=' .$this->config->get('webhook_iyzico_webhook_url_key');
$data['iyzico_webhook_url'] = HTTP_CATALOG.'index.php?route=extension/iyzico/payment/iyzico%7Cwebhook&key=' .$this->config->get('webhook_iyzico_webhook_url_key');
$data['module_version'] = $this->module_product_name;
$data['iyzico_webhook_button'] = $this->config->get('payment_iyzico_webhook_active_button');

Expand Down
48 changes: 21 additions & 27 deletions iyzico/catalog/controller/payment/iyzico.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class iyzico extends \Opencart\System\Engine\Controller {

private $module_version = VERSION;
private $module_product_name = '1.6';
private $module_product_name = '2.0';

private $paymentConversationId;
private $webhookToken;
Expand All @@ -16,18 +16,15 @@ public function index() {

$this->load->language('extension/iyzico/payment/iyzico');

$data['form_class'] = $this->config->get('payment_iyzico_design');
$data['form_type'] = $this->config->get('payment_iyzico_design');
$data['config_theme'] = $this->config->get('config_theme');
$data['onepage_desc'] = $this->language->get('iyzico_onepage_desc');

if($data['form_type'] == 'onepage')
$data['form_class'] = 'responsive';

if (isset($this->session->data['order_id'])) {
//$this->cart->clear();

$data['user_login_check'] = $this->customer->isLogged();
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}

return $this->load->view('extension/iyzico/payment/iyzico_form',$data);
return $this->getCheckoutFormToken();


}
Expand Down Expand Up @@ -85,7 +82,7 @@ public function getCheckoutFormToken() {

$api_key = $this->config->get('payment_iyzico_api_key');
$secret_key = $this->config->get('payment_iyzico_secret_key');
$payment_source = "OPENCART-4x-".$this->module_version."|".$this->module_product_name."|".$this->config->get('payment_iyzico_design');
$payment_source = "OPENCART-4x-".$this->module_version."|".$this->module_product_name;

$user_create_date = $this->model_extension_iyzico_payment_iyzico->getUserCreateDate($user_id);

Expand All @@ -110,7 +107,7 @@ public function getCheckoutFormToken() {
$iyzico->basketId = $order_id;
$iyzico->paymentGroup = "PRODUCT";
$iyzico->forceThreeDS = "0";
$iyzico->callbackUrl = $this->url->link('extension/iyzico/payment/iyzico|getCallBack', '', true);
$iyzico->callbackUrl = $this->url->link('extension/iyzico/payment/iyzico%7CgetCallBack', '', true);
$iyzico->cardUserKey = $this->model_extension_iyzico_payment_iyzico->findUserCardKey($customer_id,$api_key);
$iyzico->paymentSource = $payment_source;

Expand Down Expand Up @@ -189,18 +186,16 @@ public function getCheckoutFormToken() {

$form_response = $this->model_extension_iyzico_payment_iyzico->createFormInitializeRequest($iyzico_json,$authorization_data);

$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($form_response));

$data['iyzico_redirect'] = $form_response->paymentPageUrl;
return $this->load->view('extension/iyzico/payment/iyzico_form',$data);



}


public function getCallBack($webhook = null, $webhookPaymentConversationId = null ,$webhookToken = null) {
if(!isset($webhook) or !isset($webhookPaymentConversationId) or !isset($webhookToken))
{
exit;
}


try {
Expand Down Expand Up @@ -254,6 +249,7 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul
$request_response = $this->model_extension_iyzico_payment_iyzico->createFormInitializeDetailRequest($iyzico_json,$authorization_data);



if ($webhook == "webhook" && $webhookIyziEventType != 'CREDIT_PAYMENT_AUTH' && $request_response->status == 'failure'){
return $this->webhookHttpResponse("errorCode: ".$request_response->errorCode ." - " . $request_response->errorMessage, 404);
}
Expand Down Expand Up @@ -319,23 +315,21 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul
$orderMessage = 'iyzico Banka Havale/EFT ödemesi bekleniyor.';
$this->setWebhookText(0);
$this->model_checkout_order->addHistory($iyzico_local_order->order_id, $this->config->get('payment_iyzico_order_status'), $orderMessage);
return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|successpage'));
return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Csuccesspage'));
}

if($webhook != 'webhook' && $request_response->paymentStatus == 'PENDING_CREDIT' && $request_response->status == 'success')
{
$orderMessage = 'Alışveriş kredisi işlemi başlatıldı.';
$this->setWebhookText(1);
$this->model_checkout_order->addHistory($iyzico_local_order->order_id, 1,$orderMessage);
return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|successpage'));
return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Csuccesspage'));
}
$this->setWebhookText(0);

if($request_response->paymentStatus != 'SUCCESS' || $request_response->status != 'success' || $order_id != $request_response->basketId ) {

/* Redirect Error */
$errorMessage = isset($request_response->errorMessage) ? $request_response->errorMessage : $this->language->get('payment_failed');
throw new \Exception($errorMessage);
echo '<div class="alert alert-danger alert-dismissible" style="opacity: 0.994559;"><i class="fa-solid fa-circle-exclamation">Ödemeniz alınamadı.Anasayfaya yönlendirliyorsunuz.</div>';
return $this->response->redirect($this->url->link('checkout/checkout'));
}

/* Save Card */
Expand Down Expand Up @@ -377,7 +371,7 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul
return $this->webhookHttpResponse("Order Created by Webhook - Sipariş webhook tarafından oluşturuldu.", 200);
}

return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|successpage'));
return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Csuccesspage'));

} catch (Exception $e) {

Expand All @@ -390,7 +384,7 @@ public function getCallBack($webhook = null, $webhookPaymentConversationId = nul

$this->session->data['iyzico_error_message'] = $errorMessage;

return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico|errorpage'));
return $this->response->redirect($this->url->link('extension/iyzico/payment/iyzico%7Cerrorpage'));

}

Expand All @@ -410,7 +404,7 @@ public function errorPage() {
$data['error_message'] = $this->session->data['iyzico_error_message'];
$data['error_icon'] = 'catalog/view/theme/default/image/iyzico/payment/iyzico_error_icon.png';

return $this->response->setOutput($this->load->view('extension/iyzico/payment/iyzico|iyzico_error', $data));
return $this->response->setOutput($this->load->view('extension/iyzico/payment/iyzico%7Ciyzico_error', $data));

}

Expand Down
2 changes: 1 addition & 1 deletion iyzico/catalog/view/template/payment/iyzico_error.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ header }}
<div id="error-not-found" class="container">

<div class="row">{{ column_left }}
{% if column_left and column_right %}
{% set class = 'col-sm-6' %}
Expand Down
144 changes: 2 additions & 142 deletions iyzico/catalog/view/template/payment/iyzico_form.twig
Original file line number Diff line number Diff line change
@@ -1,144 +1,4 @@
<style>
.loading{width:40px;height:40px;background-color:#1E64FF;margin:100px auto;-webkit-animation:sk-rotateplane 1.2s infinite ease-in-out;animation:sk-rotateplane 1.2s infinite ease-in-out}@-webkit-keyframes sk-rotateplane{0%{-webkit-transform:perspective(120px)}50%{-webkit-transform:perspective(120px) rotateY(180deg)}100%{-webkit-transform:perspective(120px) rotateY(180deg) rotateX(180deg)}}@keyframes sk-rotateplane{0%{transform:perspective(120px) rotateX(0) rotateY(0);-webkit-transform:perspective(120px) rotateX(0) rotateY(0)}50%{transform:perspective(120px) rotateX(-180.1deg) rotateY(0);-webkit-transform:perspective(120px) rotateX(-180.1deg) rotateY(0)}100%{transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg);-webkit-transform:perspective(120px) rotateX(-180deg) rotateY(-179.9deg)}}.brand{margin:auto}.brand p{color:#1E64FF;text-align:center;margin-top:-100px}
header.css-cc3hwu-InstallmentRadiosHeader.eltfla65::before{
width: 0px!important;
}
header.css-cc3hwu-InstallmentRadiosHeader.eltfla65{
box-shadow: none!important;
}
</style>
<div id="loadingContainer">
<div class="loading"></div>
<div class="brand">
<p>iyzico</p>
{% if form_type == 'onepage' %}
<br>
<p style="margin:40px;font-size:16px;">{{ onepage_desc }}</p>
{% endif %}

</div>
</div>

<div class="iyzico_checkout_form_payment" style="display:none;">
<div class="iyzico-payment-form-wrapper" id="payment"></div>
<div id="iyzipay-checkout-form" class="{{form_class}}"></div>
</div>

<meta http-equiv="Refresh" content="0; url='{{iyzico_redirect}}'" />
<script type="text/javascript">
function getFormTokenCall(checkout) {
var configTheme = '{{ config_theme }}';
if (typeof iyziInit != 'undefined') {
delete iyziInit;
}
$.ajax({
url: 'index.php?route=extension/iyzico/payment/iyzico|getcheckoutformtoken',
type: 'post',
dataType: 'json',
cache: false,
success: function(json) {
if(json != null) {
if(checkout == 'onepage' && configTheme == 'journal3') {
$('.popup-checkout-payment').hide();
$('.journal-loading-overlay').hide();
$(html).css("overflow", "auto!important");
var html = '';
html += '<div class="iyzico_checkout_form_payment" style="display:none;">';
html += ' <div class="iyzico-payment-form-wrapper" id="payment"></div>';
html += ' <div id="iyzipay-checkout-form" class="responsive"></div>';
html += '</div>';
$('.quick-checkout-payment').append(html);
}
if (typeof json.checkoutFormContent != "undefined" && json.checkoutFormContent != "") {
$(".iyzico_checkout_form_payment").show( "slow", function() {
$('.iyzico-payment-form-wrapper').append(json.checkoutFormContent);
$(".iyzico-payment-form-wrapper").promise().done(function() {
$('#loadingContainer').css('display','none');
});
});
if(checkout == 'onepage' && configTheme != 'journal3') {
$(".checkout-loading").css("opacity","100");
$("#payment-confirm-button").css("pointer-events","visible");
$('#journal-checkout-confirm-button').css('display','none');
}
} else {
$(".iyzico_checkout_form_payment").show();
$('.iyzico-payment-form-wrapper').append('<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button>' + json.errorMessage + '</div>');
$('#iyzico-loader').css('display','none');
}
} else {
$(".iyzico_checkout_form_payment").show();
$('.iyzico-payment-form-wrapper').append('<div class="alert alert-danger"><button type="button" class="close" data-dismiss="alert">×</button>Connection Error</div>');
$('#iyzico-loader').css('display','none');
}
}
});
}
function customCheckoutFormTokenCall(checkout) {
$(".confirm-button, #quick-checkout-button-confirm").click(function(e) {
var ajaxData,errors,done = null;
$( document ).ajaxComplete(function( event, xhr, settings ) {
ajaxData = JSON.parse(xhr.responseText);
errors = ajaxData.response.error;
if(typeof errors != 'undefined' && errors == null && done == null) {
done = true;
return getFormTokenCall(checkout);
}
});
e.preventDefault();
});
}
window.location.href = "{{iyzico_redirect}}";
</script>

{% if form_type != 'onepage' %}
<script>
$(document).ready(function(){
return getFormTokenCall('default');
});
</script>
{% elseif form_type == 'onepage' %}
<style>
.no-touchevents{
overflow: auto!important;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
return customCheckoutFormTokenCall('onepage');
});
</script>
{% endif %}
2 changes: 1 addition & 1 deletion iyzico/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "iyzico",
"code": "iyzico",
"license": "GPL",
"version": "1.6.0",
"version": "2.0.0",
"author": "iyzico",
"link": "https://www.iyzico.com/"
}

0 comments on commit 2720906

Please sign in to comment.