Skip to content

Commit

Permalink
Merge pull request #19 from paynl/feature/PLUG-118
Browse files Browse the repository at this point in the history
Feature/plug 118
  • Loading branch information
woutse authored May 25, 2020
2 parents 4850132 + 3afa224 commit a41981c
Show file tree
Hide file tree
Showing 11 changed files with 587 additions and 79 deletions.
94 changes: 94 additions & 0 deletions paynlpaymentmethods/controllers/front/ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php
/*
* 2007-2015 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 PrestaShop SA <[email protected]>
* @copyright 2007-2015 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/

/**
* @since 1.5.0
*/
class PaynlPaymentMethodsAjaxModuleFrontController extends ModuleFrontController
{

public function initContent()
{
$prestaorderid = Tools::getValue('prestaorderid');
$amount = Tools::getValue('amount');

/**
* @var $module PaynlPaymentMethods
*/
$module = $this->module;

try {
$order = new Order($prestaorderid);
} catch (Exception $e) {
$module->payLog('Refund', 'Failed trying to refund ' . $amount . ' on ps-orderid ' . $prestaorderid . ' Order not found. Errormessage: ' . $e->getMessage());
$this->returnResponse(false, 0, 'Could not find order');
}

$paymenyArr = $order->getOrderPayments();
$orderPayment = reset($paymenyArr);
$transactionId = $orderPayment->transaction_id;

$currencyId = $orderPayment->id_currency;
$currency = new Currency($currencyId);
$strCurrency = $currency->iso_code;

$cartId = !empty($order->id_cart) ? $order->id_cart : null;

$module->payLog('Refund', 'Trying to refund ' . $amount . ' ' . $strCurrency . ' on prestashop-orderid ' . $prestaorderid, $cartId, $transactionId);

$arrRefundResult = $module->doRefund($transactionId, $amount, $strCurrency);
$refundResult = $arrRefundResult['data'];

if ($arrRefundResult['result'])
{
$arrResult = $refundResult->getData();
$amountRefunded = !empty($arrResult['amountRefunded']) ? $arrResult['amountRefunded'] : '';

$desc = !empty($arrResult['description']) ? $arrResult['description'] : 'empty';
$module->payLog('Refund', 'Refund success, result message: ' . $desc, $cartId, $transactionId);

$this->returnResponse(true, $amountRefunded, 'succesfully_refunded ' . $strCurrency . ' ' . $amount);
} else {
$module->payLog('Refund', 'Refund failed: ' . $refundResult, $cartId, $transactionId);
$this->returnResponse(false, 0, 'could_not_process_refund');
}

}

private function returnResponse($result, $amountRefunded = '', $message = '')
{
header('Content-Type: application/json;charset=UTF-8');

$returnarray = array(
'success' => $result,
'amountrefunded' => $amountRefunded,
'message' => $message
);

die(json_encode($returnarray));
}

}
19 changes: 10 additions & 9 deletions paynlpaymentmethods/controllers/front/exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ class PaynlPaymentMethodsExchangeModuleFrontController extends ModuleFrontContro
*/
public function postProcess()
{
if($_REQUEST['action'] == 'pending'){
die('TRUE| Ignoring pending');
}
$transactionId = $_REQUEST['order_id'];

# PAY. action
$action = Tools::getValue('action');
$cartid = Tools::getValue('extra1');

$transactionId = $_REQUEST['order_id'];

$module = $this->module;
/**
* @var $module PaynlPaymentMethods
*/
* @var $module PaynlPaymentMethods
*/
$module = $this->module;

$module->payLog('Exchange', 'Action: ' . $action, $cartid, $transactionId);

$module->payLog('Exchange. Action: ' . $action . '. TransactionId: ' . $transactionId);
if($_REQUEST['action'] == 'pending'){
die('TRUE| Ignoring pending');
}

try {
$message = '';
Expand Down
29 changes: 18 additions & 11 deletions paynlpaymentmethods/controllers/front/finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ public function postProcess()
$this->orderStatusId = Tools::getValue('orderStatusId');
$this->paymentSessionId = Tools::getValue('paymentSessionId');

$module = $this->module;
/**
* @var $module PaynlPaymentMethods
*/
/**
* @var $module PaynlPaymentMethods
*/
$module = $this->module;

try {
$transaction = $module->getTransaction($transactionId);
} catch (Exception $e) {
$module->payLog('finishPostProcess', 'Could not retrieve transaction', null, $transactionId);
return;
}

if ($transaction->isPaid() || $transaction->isPending() || $transaction->isBeingVerified() || $transaction->isAuthorized()) {
$module->payLog('finishPostProcess', 'Returning to webshop', $transaction->getExtra1(), $transactionId);

if ($transaction->isPaid() || $transaction->isPending() || $transaction->isBeingVerified() || $transaction->isAuthorized()) {
// naar success
/**
* @var $cart CartCore
Expand Down Expand Up @@ -87,13 +94,13 @@ public function postProcess()

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

} else {
# delete old payment fee
$this->context->cart->deleteProduct(Configuration::get('PAYNL_FEE_PRODUCT_ID'),0);
} else {
# Delete old payment fee
$this->context->cart->deleteProduct(Configuration::get('PAYNL_FEE_PRODUCT_ID'), 0);

// naar checkout
Tools::redirect('index.php?controller=order&step=1');
}
# To checkout
Tools::redirect('index.php?controller=order&step=1');
}

}

Expand Down
5 changes: 2 additions & 3 deletions paynlpaymentmethods/controllers/front/startPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function postProcess()
die($this->module->l('This payment method is not available.', 'validation'));
}


$extra_data = array();
if(isset($_REQUEST['bank'])){
$extra_data['bank'] = $_REQUEST['bank'];
Expand All @@ -63,8 +62,8 @@ public function postProcess()
$redirectUrl = $this->module->startPayment($cart, $paymentOptionId, $extra_data);
Tools::redirect($redirectUrl);
} catch (Exception $e){

die('Error: '.$e->getMessage());
$this->module->payLog('postProcess', 'Error startPayment: ' . $e->getMessage(), $cart->id);
die('Error: ' . $e->getMessage());
}


Expand Down
59 changes: 59 additions & 0 deletions paynlpaymentmethods/css/PAY.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.PAY.panel #dialog-info-modal
{
display:none;
}
.ui-dialog
{
border:0;
background: none;
background-color: #fff;
color: white;
}
.ui-dialog *
{
color: #333;
}
.ui-dialog-title
{
color: #3b3b3b;
}
.ui-dialog-titlebar
{
background:none;
background-color: #5eba6c;
border:0;
border-radius: 0;
}
.PAY.panel .payOption {
margin-right: 30px;
display: inline-block;
width: 350px;
}
.PAY.panel .payOption div.label {
display: inline-block;
color: #333;
}
.PAY.panel .payOption.disabled {
opacity: 0.3;
cursor: default;
}
.PAY.panel .payOption.disabled * {
cursor: default;
}
.PAY.panel div.payFields div.labelvalue {
display: inline-block;
padding: 4px 7px;
background-color: transparent;
border-radius: 4px;
color: #333;
margin-right: 30px;
}
.PAY.panel div.payFields div.label {
display: inline-block;
padding: 8px;
background-color: #eaeaea;
margin-right: 4px;
margin-left: 0;
border-radius: 4px;
color: #272727;
}
30 changes: 22 additions & 8 deletions paynlpaymentmethods/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_14cb4d5344b0a3bf1e97aed5419679ba'] = 'PAY.';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_56250a5892b6e8c3deedac6525e1a6fa'] = 'PAY. betaalmethoden voor PrestaShop';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_a02758d758e8bec77a33d7f392eb3f8a'] = 'Er is voor deze module geen valuta ingesteld';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_f7aae2a74abc8a53ff0ddc6808182d2b'] = 'Weet u zeker dat u dit bedrag wil terugbetalen';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_1f7d859f8eacd7176e673032482543ee'] = 'Terugbetalen';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_729a51874fe901b092899e9e8b31c97a'] = 'Weet u het zeker?';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_2b04fe9fdd308d7d099e439e3fbcf528'] = 'Terugbetalen is niet mogelijk';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_4237c6f83fc2696b6ac87ca894607c03'] = 'Bedrag';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_643562a9ae7099c8aabfdc93478db117'] = 'Bezig met verwerken';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_386c339d37e737a436499d423a77df0c'] = 'Valuta';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_9a4c56a1ee5b7ee89b9a5f705c2fda6c'] = 'Orderbedrag';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_a9ced76f2dd6907220fa95b3a136b04a'] = 'Ongeldig bedrag';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_0767b61acf9e2b7c9c346788ff9d778d'] = 'Terugbetaling gelukt';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_27e600a9fa8e36c761aad9cb1ba5a156'] = 'Betaalmethode';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_9b24ac685f7ec44b2895b9d172d22ccc'] = 'Terugbetalen mislukt. Probeer het later nog eens of pas het bedrag aan.';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_76f0ed934de85cc7131910b32ede7714'] = 'Terugbetaling';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_26cd177f2b6765750334ed39a2f4b5b6'] = 'De orderstatus wordt alleen bij een volledige terugbetaling aangepast naar `Terugbetaald`. De voorraad wordt hierbij niet aangepast.';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_b2d37ae1cedf42ff874289b721860af2'] = 'Log-informatie';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_4f6cbea9f2eade99f783747f7cafb211'] = 'Ga hiervoor naar `Geavanceerde instellingen` en open `Logboeken` en filter bij (indien ingeschakeld bij de plugin instellingen) `Bericht` op `PAY.`';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_020c2091aec3019d02193cef080bcf97'] = 'Betaalmethode toeslag';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_9f06b28a40790c4c4df5739bce3c1eb0'] = 'Verzendkosten';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_68bf367e228f45ba83cb8831a5ee6447'] = 'Nederlands';
Expand All @@ -13,29 +29,30 @@
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_4be8e06d27bca7e1828f2fa9a49ca985'] = 'Italiaans';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_ad225f707802ba118c22987186dd38e8'] = 'Frans';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_86bc3115eb4e9873ac96904a4a68e19e'] = 'Duits';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_086247a9b57fde6eefee2a0c4752242d'] = 'Automatisch';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_06224fd1af0863575df3ea430dd98848'] = 'Kan de Pay.nl SDK niet vinden, heb je de source geinstalleerd in plaats van het pakketbestand?';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_72a1a22dadebb68c2b328ce4acb74781'] = 'Taal van de webshop';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_1be25759cbc758a4cd49adfc7979c0e7'] = 'Taal van de browser';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_d262bca42a884db060f5a6667b21205d'] = 'APItoken is verplicht';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_eca1973b20e3b246847fd7f1648c2599'] = 'ServiceId is verplicht';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_c888438d14855d7d96a2724ee9c306bd'] = 'Instellingen opgeslagen';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_8cfa0f8895de4a51e4055e0a4476e274'] = 'PAY. Account Instellingen. Plugin versie %s';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_0a0d3d18ca5a07d08e62a1c962f91946'] = 'APItoken';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_04542edeb8b2c5b3922716ca8ddd0032'] = 'Je kunt je APItoken vinden onderaan op https://admin.pay.nl/my_merchant';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_b1b404a85c213977a7cabb82b730639c'] = 'ServiceId';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_7a78c463c901a677dc7c205fb2542f9d'] = 'De SL-code van je dienst op https://admin.pay.nl/programs/programs';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_adc1e83ea8057c3b182f292b223612da'] = 'Transactieomschrijving voorvoegsel';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_2ab45b27dbaf728ece860448598238ae'] = 'Een tekst die voor de transactieomschrijving wordt gezet';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_b989ff7da93d9c8344a4c4e765cab502'] = 'Validatievertraging';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_0dad032fbd1b79c430527f7622add693'] = 'Wanneer de betaling is geslaagd, wacht op PAY. om de betaling te valideren voordat de klant wordt doorgestuurd naar de succes pagina';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_00d23a76e43b46dae9ec7aa9dcbebb32'] = 'Ingeschakeld';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_b9f5c797ebbf55adccdd8539a65a0241'] = 'Uitgeschakeld';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_56d40defec5b7682e494af89a7a4d2a9'] = 'Log communicatie en procesinformatie van PAY.';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_4245499695408b974322be6f01b0d17a'] = 'Test modus';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_61142607f22ea506073bcb1c1c74133e'] = 'Start de transacties in sandbox modus om te testen';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_4861c3d5c88af6037e2bfb0d5c309ce1'] = 'Weergave afbeeldingen';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_f7d5170bde3cbe04f1e4c3cb3459dc08'] = 'Laat de afbeeldingen van de betaalmethoden zien in de checkout.';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_3d8bf69f189462bae437c9b50d32f4e1'] = 'Betaalscherm taal';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_1efea134dc382b9d18ef9ed8a21e178f'] = 'Selecteer de taal waarin het betaalscherm wordt weergegeven, gebruikt automatisch de browser taal';
$_MODULE['<{paynlpaymentmethods}prestashop>paynlpaymentmethods_c9cc8cce247e49bae79f15173ce97354'] = 'Opslaan';
$_MODULE['<{paynlpaymentmethods}prestashop>startpayment_e2b7dec8fa4b498156dfee6e4c84b156'] = 'Deze betaalmethode is niet beschikbaar';
$_MODULE['<{paynlpaymentmethods}prestashop>payment_form_ideal_eb45bd2725cb8ac50d0795432a918f86'] = 'Bank';
$_MODULE['<{paynlpaymentmethods}prestashop>payment_form_ideal_3ee7960dc804545cf3cc91a1fbc155ca'] = 'Kies uw bank a.u.b.';
$_MODULE['<{paynlpaymentmethods}prestashop>admin_paymentmethods_0da8d9a75492046bea7f314521e07cae'] = 'Betaalmethoden';
$_MODULE['<{paynlpaymentmethods}prestashop>admin_paymentmethods_49ee3087348e8d44e1feda1917443987'] = 'Naam';
$_MODULE['<{paynlpaymentmethods}prestashop>admin_paymentmethods_9444baf5ee361fb18f91039baab7df9c'] = 'De naam van de betaalmethode';
Expand All @@ -56,6 +73,3 @@
$_MODULE['<{paynlpaymentmethods}prestashop>admin_paymentmethods_6ddb1f21389093a6d6c014a18b680a22'] = 'Betaalkosten als percentage';
$_MODULE['<{paynlpaymentmethods}prestashop>admin_paymentmethods_15552aa94cf4b7239d3746c980512bf1'] = 'Het type toeslag voor deze betaalmethode';
$_MODULE['<{paynlpaymentmethods}prestashop>admin_paymentmethods_fff62f3f9fe367bba8d702ca5ef30c6c'] = 'Waarde van de toeslag';
$_MODULE['<{paynlpaymentmethods}prestashop>payment_form_ideal_eb45bd2725cb8ac50d0795432a918f86'] = 'Bank';
$_MODULE['<{paynlpaymentmethods}prestashop>payment_form_ideal_3ee7960dc804545cf3cc91a1fbc155ca'] = 'Kies uw bank a.u.b.';
$_MODULE['<{paynlpaymentmethods}prestashop>startpayment_e2b7dec8fa4b498156dfee6e4c84b156'] = 'Deze betaalmethode is niet beschikbaar';
Loading

0 comments on commit a41981c

Please sign in to comment.