Skip to content

Commit

Permalink
Merge pull request #7 from sozgat/pwi
Browse files Browse the repository at this point in the history
pay with iyzico Prestashop 1.0.1v
  • Loading branch information
sozgat authored Apr 22, 2021
2 parents 1fa2a86 + af85c5c commit ef4d1df
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 458 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Pay with iyzico - PrestaShop Payment Gateway
------------
* Create live account at https://merchant.iyzipay.com
* Create test account at https://sandbox-iyzipay.com
* Create test account at https://sandbox-merchant.iyzipay.com


# Requirements
Expand Down
47 changes: 47 additions & 0 deletions paywithiyzico/classes/PaywithiyzicoModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* 2007-2018 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author iyzico <[email protected]>
* @copyright 2018 iyzico
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of iyzico
*/

class PaywithiyzicoModel extends ObjectModel
{
/**
* @param $price
* @param $order_id
* @return mixed
*/
public static function updateOrderInvoiceTotal($price, $order_id)
{

$tableName = 'order_invoice';
$order_id = (int) $order_id;

$sql = 'UPDATE '._DB_PREFIX_.bqSQL($tableName).'
SET `total_paid_tax_incl` = \''.$price.'\',
`total_products_wt` = \''.$price.'\'
WHERE `id_order` = \''.$order_id.'\'';

return Db::getInstance()->execute($sql);
}
}
4 changes: 2 additions & 2 deletions paywithiyzico/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<module>
<name>paywithiyzico</name>
<displayName><![CDATA[paywithiyzico]]></displayName>
<version><![CDATA[1.0.0]]></version>
<description><![CDATA[paywithiyzico Payment Gateway for PrestaShop]]></description>
<version><![CDATA[1.0.1]]></version>
<description><![CDATA[Pay with iyzico Payment Gateway for PrestaShop]]></description>
<author><![CDATA[paywithiyzico]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[are you sure ?]]></confirmUninstall>
Expand Down
4 changes: 2 additions & 2 deletions paywithiyzico/config_tr.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>paywithiyzico</name>
<displayName><![CDATA[paywithiyzico &Ouml;deme Mod&uuml;l&uuml;]]></displayName>
<displayName><![CDATA[paywithiyzico]]></displayName>
<version><![CDATA[1.0.1]]></version>
<description><![CDATA[PrestaShop i&ccedil;in paywithiyzico &Ouml;deme Ge&ccedil;idi]]></description>
<description><![CDATA[Pay with iyzico Payment Gateway for PrestaShop]]></description>
<author><![CDATA[paywithiyzico]]></author>
<tab><![CDATA[payments_gateways]]></tab>
<confirmUninstall><![CDATA[emin misiniz ?]]></confirmUninstall>
Expand Down
12 changes: 11 additions & 1 deletion paywithiyzico/controllers/front/callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
require_once _PS_MODULE_DIR_.'paywithiyzico/classes/PaywithiyzicoObject.php';
require_once _PS_MODULE_DIR_.'paywithiyzico/classes/PaywithiyzicoPkiStringBuilder.php';
require_once _PS_MODULE_DIR_.'paywithiyzico/classes/PaywithiyzicoRequest.php';
require_once _PS_MODULE_DIR_.'paywithiyzico/classes/PaywithiyzicoModel.php';

class PaywithiyzicoCallBackModuleFrontController extends ModuleFrontController
{
Expand Down Expand Up @@ -86,6 +87,13 @@ public function init()
$requestResponse->paymentId = (int) $requestResponse->paymentId;
$requestResponse->conversationId = (int) $requestResponse->conversationId;

if($requestResponse->paymentStatus == 'INIT_BANK_TRANSFER' && $requestResponse->status == 'success') {
$orderMessage = 'iyzico Banka havalesi/EFT ödemesi bekleniyor.';
$this->module->validateOrder($orderId, Configuration::get('PS_OS_BANKWIRE'), $cartTotal, $this->module->displayName, $orderMessage, $extraVars, NULL, false, $customerSecureKey);

Tools::redirect('index.php?controller=order-confirmation&id_cart='.$orderId.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
}

if (empty($orderId)) {
if ($token) {
$this->cancelPayment($locale, $requestResponse->paymentId, $remoteIpAddr, $apiKey, $secretKey, $rand, $endpoint);
Expand Down Expand Up @@ -151,7 +159,7 @@ public function init()
$extraVars['{date}'] = Tools::displayDate(date('Y-m-d H:i:s'), null, 1).$installmentMessageEmail;

/* Invoice false */
Configuration::updateValue('PS_INVOICE', false);
//Configuration::updateValue('PS_INVOICE', false);
}

$test = $this->module->validateOrder($orderId, Configuration::get('PS_OS_PAYMENT'), $cartTotal, $this->module->displayName, $installmentMessage, $extraVars, $currenyId, false, $customerSecureKey);
Expand All @@ -168,6 +176,8 @@ public function init()

IyzipayModel::updateOrderPayment($requestResponse->paidPrice, $order->reference);

PaywithiyzicoModel::updateOrderInvoiceTotal($requestResponse->paidPrice, $currentOrderId);

/* Open Thread */
$customer_thread = new CustomerThread();
$customer_thread->id_contact = 0;
Expand Down
Binary file modified paywithiyzico/logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 28 additions & 8 deletions paywithiyzico/paywithiyzico.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct()
{
$this->name = 'paywithiyzico';
$this->tab = 'payments_gateways';
$this->version = '1.0.0';
$this->version = '1.0.1';
$this->author = 'iyzico';
$this->need_instance = 1;

Expand All @@ -66,7 +66,7 @@ public function __construct()
$this->InstallmentKey = $this->l('InstallmentKey');
$this->installmentShopping = $this->l('installmentShopping');
$this->installmentOption = $this->l('installmentOption');
$this->commissionAmount = $this->l('commissionAmount');
$this->commissionAmount = $this->l('commissionAmount');



Expand Down Expand Up @@ -131,6 +131,8 @@ public function getContent()

$this->context->smarty->assign('module_dir', $this->_path);

$this->context->smarty->assign('payWithIyzicoVersion', $this->version);

$output = $this->context->smarty->fetch($this->local_path.'views/templates/admin/configure.tpl');


Expand Down Expand Up @@ -377,11 +379,32 @@ private function getOptionText()
*/
private function paymentOptionResult()
{
$title = $this->getOptionText();
$newOptions = array();
$newOptions = array();

$languageId = $this->context->cookie->id_lang;
$languages = Language::getLanguage($languageId);
$languageIsoCode = $languages['iso_code'];

$pwi_logo = Media::getMediaPath(_PS_MODULE_DIR_.$this->name."/views/img/pay_with_iyzico.png");
$title = "Alışverişlerini hızla ve kolayca iyzico ile Öde!";
$this->context->smarty->assign('pwi_description_first', "iyzico ile Öde-Şimdi Kolay!");
$this->context->smarty->assign('pwi_description_second', "Alışverişini ister iyzico bakiyenle, ister saklı kartınla,
ister havale/EFT yöntemi ile kolayca öde; aklına takılan herhangi bir konuda iyzico Korumalı Alışveriş avantajıyla
7/24 canlı destek al.");


if ($languageIsoCode != 'tr'){
$pwi_logo = Media::getMediaPath(_PS_MODULE_DIR_.$this->name."/views/img/pay_with_iyzico_en.png");
$title = "Pay with iyzico-It’s Easy Now!";
$this->context->smarty->assign('pwi_description_first', "");
$this->context->smarty->assign('pwi_description_second', "You can easily pay for your shopping
with your iyzico balance, with your stored card or money transfer method;
get 24/7 live support with the advantage of iyzico Buyer Protection on any matter.");
}

$newOption = new PaymentOption();
$newOption->setModuleName($this->name)
$newOption->setLogo($pwi_logo)
->setModuleName($this->name)
->setCallToActionText($this->trans($title, array(), 'Modules.Paywithiyzico'))
->setAction($this->context->link->getModuleLink($this->name, 'validation', array(), true))
->setAdditionalInformation($this->fetch('module:paywithiyzico/views/templates/front/paywithiyzico.tpl'));
Expand All @@ -398,10 +421,7 @@ private function paymentOptionResult()
private function successAssign($paywithiyzicoResponse)
{

$logo_pwi = Media::getMediaPath(_PS_MODULE_DIR_.$this->name.'/views/img/cards.png');

$this->context->smarty->assign('pwi', $paywithiyzicoResponse->payWithIyzicoPageUrl);
$this->context->smarty->assign('cards_pwi', $logo_pwi);

return $this->paymentOptionResult();

Expand Down
40 changes: 13 additions & 27 deletions paywithiyzico/translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

global $_MODULE;
$_MODULE = array();
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_eb22f094ae2dc17aff069b4080593681'] = 'paywithiyzico Payment Module';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_cb326e4910117145c5ddf577260dd454'] = 'paywithiyzico Payment Gateway for PrestaShop';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_00dc35033910278a465e32a0dfdc50c5'] = 'Pay with iyzico Payment Module';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_575be6e215e11004057500f6508e4f74'] = 'Pay with iyzico Payment Gateway for PrestaShop';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_6f74a2f771f9b8422e24de0f1e5552b2'] = 'Your order has been canceled. Please try again. - basket Items Not Match';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_868478716c083f38439fb9865bfad3f7'] = 'Your payment was made but your order could not be created. Please enter it with the site administrator.';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_8f88271ce67ff89c1a9e057c64ac8b1c'] = '3D Error';
Expand All @@ -19,38 +19,24 @@
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_92d4773a9f32fc3333cb8238471cf763'] = 'You have to enable the cURL extension on your server to install this module';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_cdbe2f170711683cb6624cf9c509cc99'] = 'This module is not available in your country';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_f4f70727dc34561dfde1a3c529b6205c'] = 'Settings';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_45268bdcc9ffe3a5807e75085e768efb'] = 'API Type';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_2e5e61c17add3609c6786a4c9ce1a279'] = 'API Key';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_5eb6bb157528b365f84c27bb4784031b'] = 'Secret Key';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_7a7926523a1bb06ec3373b3ebc482e65'] = 'Payment Text';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_23839755e143e06fdd0f4d848bb02ebe'] = 'Display Form';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_24d323e6f470b88f397b5acfb5bee475'] = 'Overlay Script Position';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_2e7aef81e8f267669342202b86b953f1'] = 'Bottom Left';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_cf917b5704a132696a6d5dcbdb3ec2fc'] = 'Bottom Right';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_6534a09f754b938683b2d81f4b1490ef'] = 'Hidden';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_c9cc8cce247e49bae79f15173ce97354'] = 'Save';
$_MODULE['<{paywithiyzico}prestashop>paywithiyzico_62d3e6f706cd08753269d1e7cb82acc0'] = 'Contract approval is required for the payment form to be active.';
$_MODULE['<{paywithiyzico}prestashop>callback_6a42b5c65308d870ac1ea113c9ee5fd0'] = 'Token Not Found';
$_MODULE['<{paywithiyzico}prestashop>callback_e7e914b797ae5c9f8efc09f5b4817e6b'] = 'Order Not Found';
$_MODULE['<{paywithiyzico}prestashop>callback_6f74a2f771f9b8422e24de0f1e5552b2'] = 'Your order has been canceled. Please try again. - basket Items Not Match';
$_MODULE['<{paywithiyzico}prestashop>callback_8f88271ce67ff89c1a9e057c64ac8b1c'] = '3D Error';
$_MODULE['<{paywithiyzico}prestashop>callback_d25cd344b961a34184b1bb6ffa80710b'] = 'General Error';
$_MODULE['<{paywithiyzico}prestashop>callback_8f09da02ab72ea112fafefed99f3eb11'] = 'Payment by installment';
$_MODULE['<{paywithiyzico}prestashop>callback_514c4aed82cae5530481b9a6e40915d8'] = 'Installment Shopping';
$_MODULE['<{paywithiyzico}prestashop>callback_3d6596ea416c6c6521f523aa41ee12b0'] = 'Installment Option: ';
$_MODULE['<{paywithiyzico}prestashop>callback_8f09da02ab72ea112fafefed99f3eb11'] = 'Payment by installment';
$_MODULE['<{paywithiyzico}prestashop>callback_1ceebcbe9b57cd93212e4ca8945a894d'] = 'Commission Amount: ';
$_MODULE['<{paywithiyzico}prestashop>callback_868478716c083f38439fb9865bfad3f7'] = 'Your payment was made but your order could not be created. Please enter it with the site administrator.';
$_MODULE['<{paywithiyzico}prestashop>confirmation_66b914a3d0878daed70f10d165196200'] = 'An error occured. Please contact the merchant to have more informations';
$_MODULE['<{paywithiyzico}prestashop>redirect_c453a4b8e8d98e82f35b67f433e3b4da'] = 'Payment';
$_MODULE['<{paywithiyzico}prestashop>redirect_902b0d55fddef6f8d651fe1035b7d4bd'] = 'Error';
$_MODULE['<{paywithiyzico}prestashop>validation_e61b0be95b713b117d27dbd19d75f69a'] = 'An error occurred while processing payment';
$_MODULE['<{paywithiyzico}prestashop>confirmation_bddd470742bc2329733e489ed05a8ba1'] = 'Your order is complete. ';
$_MODULE['<{paywithiyzico}prestashop>confirmation_b2f40690858b404ed10e62bdf422c704'] = 'Amount';
$_MODULE['<{paywithiyzico}prestashop>confirmation_e5b8f00cb48fe623703902d21ed16f6f'] = 'Installment Fee';
$_MODULE['<{paywithiyzico}prestashop>confirmation_63d5049791d9d79d86e9a108b0a999ca'] = 'Reference';
$_MODULE['<{paywithiyzico}prestashop>confirmation_19c419a8a4f1cd621853376a930a2e24'] = 'An email has been sent with this information.';
$_MODULE['<{paywithiyzico}prestashop>confirmation_ca7e41a658753c87973936d7ce2429a8'] = 'If you have questions, comments or concerns, please contact our';
$_MODULE['<{paywithiyzico}prestashop>confirmation_cd430c2eb4b87fb3b49320bd21af074e'] = 'expert customer support team.';
$_MODULE['<{paywithiyzico}prestashop>confirmation_7569ab9b5973795ce8c9fc870d38d8e1'] = 'Your order on %s has not been accepted.';
$_MODULE['<{paywithiyzico}prestashop>confirmation_caa4088f1d295cf8ce8e358eb975ab32'] = 'Please, try to order again.';
$_MODULE['<{paywithiyzico}prestashop>error_a25c753ee3e4be15ec0daa5a40deb7b8'] = 'An error occurred';
$_MODULE['<{paywithiyzico}prestashop>error_a25c753ee3e4be15ec0daa5a40deb7b8'] = 'An error occurred';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_bddd470742bc2329733e489ed05a8ba1'] = 'Your order is complete.';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_b2f40690858b404ed10e62bdf422c704'] = 'Amount';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_e5b8f00cb48fe623703902d21ed16f6f'] = 'Installment Fee';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_63d5049791d9d79d86e9a108b0a999ca'] = 'Reference';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_19c419a8a4f1cd621853376a930a2e24'] = 'An email has been sent with this information.';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_ca7e41a658753c87973936d7ce2429a8'] = 'If you have questions, comments or concerns, please contact our.';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_cd430c2eb4b87fb3b49320bd21af074e'] = 'expert customer support team.';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_7569ab9b5973795ce8c9fc870d38d8e1'] = 'Your order on %s has not been accepted.';
$_MODULE['<{paywithiyzico}prestashop>confirmationpwi_caa4088f1d295cf8ce8e358eb975ab32'] = 'Please, try to order again.';
Loading

0 comments on commit ef4d1df

Please sign in to comment.