Module Maintenance + création du module Recette

This commit is contained in:
2021-04-01 20:44:45 +02:00
parent a887f6892b
commit 8d8ca3fe2f
92 changed files with 6334 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,408 @@
{extends file="admin-layout.tpl"}
{block name="after-bootstrap-css"}
{/block}
{block name="no-return-functions"}
{$admin_current_location = 'module'}
{/block}
{block name="page-title"}{intl l='PayPlug module configuration' d='payplugmodule.bo.default'}{/block}
{block name="check-resource"}admin.module{/block}
{block name="check-access"}view{/block}
{block name="check-module"}PayPlug{/block}
{block name="main-content"}
<style>
.block {
padding: 20px;
border-bottom: 2px solid #00AB7A;
}
.block h2 {
color: #00AB7A;
}
.block .block {
border: 2px solid rgba(0, 211, 152, 0.61);
}
</style>
<div class="col-md-12">
<div class="panel panel-default">
{form name="payplugmodule_configuration_form"}
<form action="{url path="/admin/module/payplugmodule/configuration"}" method="POST">
{form_hidden_fields form=$form}
{if $form_error}
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path={navigate to="current"}}"/>
{/form_field}
<div class="panel-body">
<div class="row">
<div class="block col-md-12">
<img style="height: 34px;" src="{image file='PayPlugModule/assets/logo-payplug.png' source="PayPlugModule"}" alt="Payment configuration" class="img-responsive" />
</div>
<div class="block col-md-12">
<div class="col-md-12">
<h2>{intl l="PayPlug offer" d='payplugmodule.bo.default'}</h2>
</div>
<div class="col-md-12">
{form_field form=$form field="offer"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label">{$label}{if $required}<span class="required">*</span>{/if}</label>
<br>
{$inputOfferName = {$name}}
{foreach from=$choices item=choice}
<input id="{$name}_{$choice->value}" name="{$name}" type="radio" value="{$choice->value}" {if $data == $choice->value}checked{/if} />
<label class="control-label" for="{$name}_{$choice->value}">{$choice->label}</label>
{/foreach}
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
</div>
<div class="block col-md-12">
<div class="col-md-12">
<h2>{intl l="PayPlug API configuration" d='payplugmodule.bo.default'}</h2>
</div>
<div class="col-md-4">
{form_field form=$form field="api_mode"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
{$label}{if $required}<span class="required">*</span>{/if}
<br>
<select class="form-control" name="{$name}" id="{$name}">
{foreach from=$choices item=choice}
<option value="{$choice->value}" {if $data == $choice->value}selected{/if}>{$choice->label}</option>
{/foreach}
</select>
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="col-md-4">
{form_field form=$form field='live_api_key'}
<label for="{$name}" class="control-label">{$label}</label>
<input id="{$name}" class="form-control" type="text" name="{$name}" value="{$data}"/>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help nofilter}</span>
{/if}
{/form_field}
</div>
<div class="col-md-4">
{form_field form=$form field='test_api_key'}
<label for="{$name}" class="control-label">{$label}</label>
<input id="{$name}" class="form-control" type="text" name="{$name}" value="{$data}"/>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help nofilter}</span>
{/if}
{/form_field}
</div>
</div>
<div class="block col-md-12" id="basic_configuration">
<div class="col-md-12">
<h2>{intl l="PayPlug basic payment configuration" d='payplugmodule.bo.default'}</h2>
</div>
<div class="col-md-12">
{form_field form=$form field="payment_enabled"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
<input type="checkbox" name="{$name}" id="{$name}" {if $data}checked{/if}/>
{$label}
{if $required}<span class="required">*</span>{/if}
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="col-md-12">
{form_field form=$form field="payment_page_type"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
{$label}{if $required}<span class="required">*</span>{/if}
<br>
<select class="form-control" name="{$name}" id="{$name}">
{foreach from=$choices item=choice}
<option value="{$choice->value}" {if $data == $choice->value}selected{/if}>{$choice->label}</option>
{/foreach}
</select>
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="col-md-12">
{render_form_field field="send_confirmation_message_only_if_paid"}
</div>
</div>
<div class="block col-md-12" id="pro_configuration">
<div class="col-md-12">
<h2>{intl l="PayPlug pro offer configuration" d='payplugmodule.bo.default'}</h2>
</div>
<div class="col-md-12">
{form_field form=$form field="one_click_payment_enabled"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
<input type="checkbox" name="{$name}" id="{$name}" {if $data}checked{/if}/>
{$label}
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="col-md-12">
{form_field form=$form field="multi_payment_enabled"}
{$inputMultiPaymentName = $name}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
<input type="checkbox" name="{$name}" id="{$name}" {if $data}checked{/if}/>
{$label}
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="block col-md-12" id="multi_payment_fields">
<div class="alert alert-warning">
{intl l="Payments in several times are not guaranteed, a default may occur on future due dates." d='payplugmodule.bo.default'}
</div>
<div class="col-md-4">
{form_field form=$form field='multi_payment_minimum'}
<label for="auth_key" class="control-label">{$label}</label>
<input id="auth_key" class="form-control" type="number" min="0" name="{$name}" value="{$data}"/>
{/form_field}
</div>
<div class="col-md-4">
{form_field form=$form field='multi_payment_maximum'}
<label for="auth_key" class="control-label">{$label}</label>
<input id="auth_key" class="form-control" type="number" min="0" name="{$name}" value="{$data}"/>
{/form_field}
</div>
<div class="col-md-4">
{form_field form=$form field="multi_payment_times"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
{$label}{if $required}<span class="required">*</span>{/if}
<br>
<select class="form-control" name="{$name}" id="{$name}">
{foreach from=$choices item=choice}
<option value="{$choice->value}" {if $data == $choice->value}selected{/if}>{$choice->label}</option>
{/foreach}
</select>
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="alert alert-info col-md-12">
<p>
{intl l="To trigger the payments on planned date please add a daily cron on this Thelia command " d='payplugmodule.bo.default'}
<strong>php Thelia payplug:treat:multi_payment</strong>
</p>
</div>
</div>
</div>
<div class="block col-md-12" id="premium_configuration">
<div class="col-md-12">
<h2>{intl l="PayPlug premium offer configuration" d='payplugmodule.bo.default'}</h2>
</div>
<div class="col-md-12">
{form_field form=$form field="differed_payment_enabled"}
{$inputDifferedPaymentName = $name}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
<input type="checkbox" name="{$name}" id="{$name}" {if $data}checked{/if}/>
{$label}
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="block col-md-12" id="differed_payment_fields">
<div class="col-md-4">
{form_field form=$form field="differed_payment_authorized_capture_status"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
{$label}{if $required}<span class="required">*</span>{/if}
<br>
<select class="form-control" name="{$name}" id="{$name}">
{loop type="order-status" name="order-status-select" backend_context="1"}
<option value="{$ID}" {if $data == $ID}selected{/if}>{$TITLE}</option>
{/loop}
</select>
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="col-md-4">
{form_field form=$form field="differed_payment_trigger_capture_status"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
{$label}{if $required}<span class="required">*</span>{/if}
<br>
<select class="form-control" name="{$name}" id="{$name}">
{loop type="order-status" name="order-status-select" backend_context="1"}
<option value="{$ID}" {if $data == $ID}selected{/if}>{$TITLE}</option>
{/loop}
</select>
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
<div class="col-md-4">
{form_field form=$form field="differed_payment_capture_expired_status"}
<div class="form-group {if $error}has-error{/if}">
<label class="control-label" for="{$name}">
{$label}{if $required}<span class="required">*</span>{/if}
<br>
<select class="form-control" name="{$name}" id="{$name}">
{loop type="order-status" name="order-status-select" backend_context="1"}
<option value="{$ID}" {if $data == $ID}selected{/if}>{$TITLE}</option>
{/loop}
</select>
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
</div>
{/form_field}
</div>
</div>
</div>
<div class="block col-md-12" id="delivery_type_configuration">
<div class="col-md-12">
<h2>{intl l="PayPlug delivery type configuration" d='payplugmodule.bo.default'}</h2>
<p>{intl l="Please select a Pay Plug delivery type correspondance for each delivery modules" d='payplugmodule.bo.default'}</p>
</div>
<div class="block col-md-12" id="differed_payment_fields">
{foreach from=$deliveryModuleFormFields item="deliveryModuleFormField"}
<div class="col-md-3">
{form_field form=$form field=$deliveryModuleFormField['name']}
<label class="control-label" for="{$name}">
{$label}{if $required}<span class="required">*</span>{/if}
<select class="form-control" name="{$name}" id="{$name}">
{foreach from=$choices item=choice}
<option value="{$choice->value}" {if $data == $choice->value}selected{/if}>{$choice->label}</option>
{/foreach}
</select>
</label>
{if ! empty($label_attr.help)}
<span class="help-block">{$label_attr.help}</span>
{/if}
{/form_field}
</div>
{/foreach}
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-12">
<input type="submit" class="btn btn-success form-control" value="{intl l="Save" d='payplugmodule.bo.default'}">
</div>
</div>
</div>
</form>
{/form}
</div>
{hook name="payplugmodule.configuration.bottom"}
</div>
{/block}
{block name="javascript-initialization"}
{/block}
{block name="javascript-last-call"}
<script type="text/javascript">
var inputOfferName = "{$inputOfferName}";
var inputMultiPaymentName = "{$inputMultiPaymentName}";
var inputDifferedPaymentName = "{$inputDifferedPaymentName}";
{literal}
jQuery(function($) {
displayConfigurationBlock();
displayMultiPaymentBlock();
displayDifferedPaymentBlock();
$('input[name="'+inputOfferName+'"]').click(function(){
displayConfigurationBlock();
});
$('input[name="'+inputMultiPaymentName+'"]').click(function(){
displayMultiPaymentBlock();
});
$('input[name="'+inputDifferedPaymentName+'"]').click(function(){
displayDifferedPaymentBlock();
});
function displayConfigurationBlock() {
var inputOfferChecked = $('input[name="'+inputOfferName+'"]:checked');
var proConfigurationBlock = $("#pro_configuration");
var premiumConfigurationBlock = $("#premium_configuration");
proConfigurationBlock.hide();
premiumConfigurationBlock.hide();
if (inputOfferChecked.val() === 'pro') {
proConfigurationBlock.show();
} else if (inputOfferChecked.val() === 'premium') {
proConfigurationBlock.show();
premiumConfigurationBlock.show();
}
}
function displayMultiPaymentBlock() {
var multiPaymentBlock = $("#multi_payment_fields");
multiPaymentBlock.hide();
if( $('input[name="'+inputMultiPaymentName+'"]').is(':checked') ){
multiPaymentBlock.show();
}
}
function displayDifferedPaymentBlock() {
var differedPaymentBlock = $("#differed_payment_fields");
differedPaymentBlock.hide();
if( $('input[name="'+inputDifferedPaymentName+'"]').is(':checked') ){
differedPaymentBlock.show();
}
}
});
{/literal}
</script>
{/block}

View File

@@ -0,0 +1,168 @@
<div id="orderPayPlug" class="panel panel-default">
<div class="panel-heading">
<h4>{intl l="PayPlug order data" d='payplugmodule.bo.default'}</h4>
</div>
<div>
{form name="payplugmodule_order_action_form_refund"}
{if $form_error}
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
{/form}
{form name="payplugmodule_order_action_form"}
{if $form_error}
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
{/form}
</div>
<table class="table table-condensed table-left-aligned">
<tbody>
{if $amountRefunded || $isPaid}
<tr>
<th>{intl l="Refund" d='payplugmodule.bo.default'}</th>
<td></td>
<td>
{loop type="order" name="refund-order-amount" id=$order_id customer="*" with_prev_next_info="true" backend_context="1"}
{$orderTotalAmount = $TOTAL_TAXED_AMOUNT}
{$orderTotalAmountWithoutShipping = $TOTAL_TAXED_AMOUNT-$POSTAGE}
{/loop}
{if $amountRefunded}
<div class="alert alert-info">{format_money number=$amountRefunded/100} {intl l=" refunded" d='payplugmodule.bo.default'}</div>
{/if}
{if $orderTotalAmount > ($amountRefunded/100) }
<div class="row">
<div class="col-md-4">
<label for="quick_select_amount_refund">{intl l="What do you want refund" d='payplugmodule.bo.default'}</label>
<select class="form-control" name="" id="quick_select_amount_refund" multiple="true">
<option value="{$orderTotalAmount}" selected>{intl l="The entire order" d='payplugmodule.bo.default'} ---- {format_money number=$orderTotalAmount currency_id=$CURRENCY}</option>
<option value="{$orderTotalAmountWithoutShipping}">{intl l="Order without shipping" d='payplugmodule.bo.default'} ----{format_money number=$orderTotalAmountWithoutShipping currency_id=$CURRENCY}</option>
<optgroup label="{intl l="Products" d='payplugmodule.bo.default'}" >
{loop type="order_product" name="order-products" order=$order_id}
<option value="{$REAL_TOTAL_TAXED_PRICE}">[{$PRODUCT_SALE_ELEMENTS_REF}] {$TITLE} ---- {format_money number=$REAL_TOTAL_TAXED_PRICE currency_id=$CURRENCY} </option>
{/loop}
</optgroup>
</select>
</div>
<div class="col-md-4">
<label for="input_amount_refund">{intl l="Adjust amount" d='payplugmodule.bo.default'}</label>
<div class="input-group">
<span class="input-group-addon glyphicon glyphicon-chevron-right"></span>
<input id="input_amount_refund" class="form-control" type="number" max="{$orderTotalAmount - $amountRefunded/100}" value="{$orderTotalAmount - $amountRefunded/100}">
<span class="input-group-addon">{currency attr="symbol"}</span>
</div>
</div>
<div class="col-md-4">
<label for=""></label>
<a class="btn btn-block btn-success image-delete" href="#order_refund_dialog" data-toggle="modal">
{intl l="Refund" d='payplugmodule.bo.default'}
</a>
</div>
</div>
{/if}
</td>
</tr>
{/if}
{if $needCapture}
<tr>
<th>{intl l="Differed payment" d='payplugmodule.bo.default'}</th>
{if null == $capturedAt}
<td>{intl l="Payment capture will expire on " d='payplugmodule.bo.default'}{format_date date=$captureExpireAt}</td>
<td>
<a class="btn btn-block btn-success image-delete" href="#order_capture_dialog" data-toggle="modal">
{intl l="Force the capture for this order" d='payplugmodule.bo.default'}
</a>
</td>
{else}
<td></td>
<td>
{intl l="Payment was captured at " d='payplugmodule.bo.default'}{format_date date=$capturedAt}
</td>
{/if}
</tr>
{/if}
{if count($multiPayments) > 0}
<tr>
<th>{intl l="Multi payment" d='payplugmodule.bo.default'}</th>
<td colspan="2">
<table class="table table-condensed table-left-aligned">
<tr>
<th>{intl l="Payment n° " d='payplugmodule.bo.default'}</th>
<th>{intl l="Amount" d='payplugmodule.bo.default'}</th>
<th>{intl l="Planned at" d='payplugmodule.bo.default'}</th>
<th>{intl l="Paid at" d='payplugmodule.bo.default'}</th>
<th>{intl l="Refunded at" d='payplugmodule.bo.default'}</th>
</tr>
{$paymentCount = 1}
{foreach from=$multiPayments item=multiPayment}
<tr>
<td>{$paymentCount}</td>
<td>{format_money number=$multiPayment['amount']/100}</td>
<td>{if $multiPayment['plannedAt']}{format_date date=$multiPayment['plannedAt']}{else}{intl l="Canceled" d='payplugmodule.bo.default'}{/if}</td>
<td>{if $multiPayment['paidAt']}{format_date date=$multiPayment['paidAt']}{/if}</td>
<td>{if $multiPayment['refundedAt']}{format_date date=$multiPayment['refundedAt']}{/if}</td>
</tr>
{$paymentCount = $paymentCount + 1}
{/foreach}
</table>
</td>
</tr>
{/if}
</tbody>
</table>
</div>
{capture "refund_dialog"}
{form name="payplugmodule_order_action_form_refund"}
{form_hidden_fields form=$form}
{if $form_error}
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path={navigate to="current"}}"/>
{/form_field}
{form_field form=$form field="order_id"}
<input type="hidden" name="{$name}" value="{$order_id}">
{/form_field}
{form_field form=$form field="refund_amount"}
<input id="refund_amount" type="hidden" name="{$name}" value="{$orderTotalAmount}">
{/form_field}
{/form}
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "order_refund_dialog"
dialog_title = {intl l="Refund order" d="payplugmodule.bo.default"}
dialog_message = {intl l="Do you really want to refund this order ?" d="payplugmodule.bo.default"}
form_method = "POST"
form_action = {url path='/admin/payplugmodule/order/refund'}
form_content = {$smarty.capture.refund_dialog nofilter}
}
{capture "capture_dialog"}
{form name="payplugmodule_order_action_form"}
{form_hidden_fields form=$form}
{if $form_error}
<div class="alert alert-danger">{$form_error_message}</div>
{/if}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path={navigate to="current"}}"/>
{/form_field}
{form_field form=$form field="order_id"}
<input type="hidden" name="{$name}" value="{$order_id}">
{/form_field}
{/form}
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "order_capture_dialog"
dialog_title = {intl l="Capture order" d="payplugmodule.bo.default"}
dialog_message = {intl l="Do you really want to capture this order ?" d="payplugmodule.bo.default"}
form_method = "POST"
form_action = {url path='/admin/payplugmodule/order/capture'}
form_content = {$smarty.capture.capture_dialog nofilter}
}

View File

@@ -0,0 +1,21 @@
var inputAmountRefund = $('#input_amount_refund');
var maxAmountRefund = parseFloat(inputAmountRefund.attr('max'));
$("#quick_select_amount_refund").change(function (e) {
var amountToRefund = 0;
var selected = $(e.target).val();
if (null !== selected) {
amountToRefund = selected.reduce(function (a, c) {
return parseFloat(a) + parseFloat(c);
});
}
amountToRefund = amountToRefund > maxAmountRefund ? maxAmountRefund : amountToRefund;
inputAmountRefund.val(amountToRefund).trigger('change');
});
inputAmountRefund.change(function (e) {
var amountToRefund = $(e.target).val() > maxAmountRefund ? maxAmountRefund : $(e.target).val();
$("#refund_amount").val(amountToRefund);
});

View File

@@ -0,0 +1,8 @@
{form_field form=$form field='pay_plug_multi_payment'}
<p>
<input id="{$name}" type="checkbox" name="{$name}" value="1">
<label for="{$name}">{intl l='Pay in %n times without fees.' n={$nTimes} d='payplugmodule.fo.default'}</label>
<br>
{intl l='You will be asked to save your payment card data.' n={url path='/payplug/card/delete'} d='payplugmodule.fo.default'}
</p>
{/form_field}

View File

@@ -0,0 +1,6 @@
<p><strong>{intl l='One click payment is available !' d='payplugmodule.fo.default'}</strong></p>
<p>
{intl l='A payment card ending by %last4 has been previously saved at your request. Payment for your order will be made immediately after clicking the "Next Step" button.' last4=$last4 d='payplugmodule.fo.default'}
<br>
{intl l='To clear your payment card details, <a href="%url">please click here</a>' url={url path='/payplug/card/delete'} d='payplugmodule.fo.default'}.
</p>

View File

@@ -0,0 +1,34 @@
<script type="text/javascript" src="https://api.payplug.com/js/1/form.latest.js"></script>
<script>
var payPlugModuleId = '{$payPlugModuleId}';
{literal}
var form = document.getElementById('form-cart-payment');
form.addEventListener('submit', function (event) {
var payPlugRadio = $('#payment_'+payPlugModuleId);
if(payPlugRadio.is(':checked')) {
event.preventDefault();
var form = $(this);
var url = form.attr('action');
$.ajax({
type: "POST",
url: url,
data: form.serialize(),
}).success(function (data) {
if (true === data.forceRedirect) {
window.location.replace(data.paymentUrl);
} else {
Payplug.showPayment(data.paymentUrl);
}
}).fail(function (data) {
var payPlugLi = payPlugRadio.parent().parent();
console.log(payPlugLi);
console.log(data.responseJSON.error);
payPlugLi.prepend('<div class="alert alert-danger">Error : '+data.responseJSON.error+'</div>');
})
}
});
{/literal}
</script>