add mollie plugin

This commit is contained in:
Philipp Rothmann 2023-10-02 22:46:46 +02:00
parent 55234b4e27
commit c59eefd219
21 changed files with 1117 additions and 0 deletions

View file

@ -0,0 +1,60 @@
- content_for :javascript do
:javascript
// @todo code duplication of foodsoft_mollie.rb
function paymentFee(amount, feeSpec) {
if (typeof feeSpec === 'number') {
return feeSpec;
}
return feeSpec.split('+').reduce((sum, c) => {
const parsed = c.trim().match(/^(.*)\s*%\s*$/);
if (parsed) {
return sum + (parseFloat(parsed[1]) / 100 * parseFloat(amount));
} else {
return sum + parseFloat(c);
}
}, 0).toFixed(2);
}
function handleInputAmount(){
var amount = parseFloat($('#amount').val());
var isError = false;
$('#fee_list').children('#fee').each(function(){
var fee = $(this).data('fee');
if (amount){
$(this).text(I18n.l("currency", paymentFee(amount, fee)));
} else {
$(this).text(fee);
}
});
}
$('#amount').on('keyup', handleInputAmount);
$(document).ready(handleInputAmount);
%h5= t '.fee'
%dl.dl-horizontal#fee_list
- FoodsoftConfig[:mollie][:fee].each do |k, v|
%dt= k
%dd{id: "fee", data: { fee: v}}"
= form_tag payments_mollie_path, method: :post do
- if params[:text]
.well= params[:text]
.control-group
.control-label
= label_tag 'amount', ((params[:label] or t('.amount_pay')))
.controls
.input-prepend
%span.add-on= t 'number.currency.format.unit'
= text_field_tag 'amount', @amount, readonly: (params[:fixed]=='true'), class: 'input-mini'
- if params[:min]
.help-inline{style: 'margin-bottom: 10px'}
= "(min #{number_to_currency params[:min], precision: 0})"
.control-group
.controls
= submit_tag t('.submit')
= link_to t('ui.or_cancel'), cancel_payments_mollie_path
-# pass through options to allow reusing on error
- %w(label title fixed min text).each do |k|
= hidden_field_tag k, params[k] if params[k]

View file

@ -0,0 +1,2 @@
- title (params[:title] or t('.title'))
= render :partial => 'form'