Skip to content

Commit

Permalink
#286 initial stubs for supporting mollie as a payment provider
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Jun 5, 2017
1 parent 3d00e3a commit 141b09e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
25 changes: 25 additions & 0 deletions src/main/java/alfio/manager/MollieManager.java
@@ -0,0 +1,25 @@
/**
* This file is part of alf.io.
*
* alf.io is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* alf.io is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with alf.io. If not, see <http://www.gnu.org/licenses/>.
*/
package alfio.manager;

import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

@Component
@Log4j2
public class MollieManager {
}
14 changes: 2 additions & 12 deletions src/main/java/alfio/manager/PaypalManager.java
Expand Up @@ -21,19 +21,18 @@
import alfio.model.Event;
import alfio.model.system.Configuration;
import alfio.model.system.ConfigurationKeys;
import alfio.repository.TicketRepository;
import alfio.repository.TicketReservationRepository;
import alfio.util.MonetaryUtil;
import com.paypal.api.payments.*;
import com.paypal.api.payments.Transaction;
import com.paypal.base.rest.APIContext;
import com.paypal.base.rest.PayPalRESTException;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.codec.digest.HmacUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder;
Expand All @@ -48,23 +47,14 @@

@Component
@Log4j2
@AllArgsConstructor
public class PaypalManager {

private final ConfigurationManager configurationManager;
private final MessageSource messageSource;
private final ConcurrentHashMap<String, String> cachedWebProfiles = new ConcurrentHashMap<>();
private final TicketReservationRepository ticketReservationRepository;

@Autowired
public PaypalManager(ConfigurationManager configurationManager,
TicketReservationRepository ticketReservationRepository,
MessageSource messageSource,
TicketRepository ticketRepository) {
this.configurationManager = configurationManager;
this.messageSource = messageSource;
this.ticketReservationRepository = ticketReservationRepository;
}

private APIContext getApiContext(Event event) {
int orgId = event.getOrganizationId();
boolean isLive = configurationManager.getBooleanConfigValue(Configuration.from(orgId, ConfigurationKeys.PAYPAL_LIVE_MODE), false);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/alfio/model/system/ConfigurationKeys.java
Expand Up @@ -101,6 +101,10 @@ public enum ConfigurationKeys {
PAYPAL_LIVE_MODE("Enable live mode for Paypal", false, SettingCategory.PAYMENT_PAYPAL, ComponentType.BOOLEAN, false, EnumSet.of(SYSTEM, ORGANIZATION), true),
//

//
MOLLIE_API_KEY("Mollie API key", false, SettingCategory.PAYMENT_MOLLIE, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION), false),
//

//
VAT_NR("VAT number", false, SettingCategory.INVOICE, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION), true),
INVOICE_NUMBER_PATTERN("Invoice number pattern, example: INVOICE-%d", false, SettingCategory.INVOICE, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
Expand All @@ -125,6 +129,7 @@ public enum SettingCategory {
PAYMENT_STRIPE("Stripe.com settings"),
PAYMENT_PAYPAL("PayPal settings"),
PAYMENT_OFFLINE("Offline payment settings"),
PAYMENT_MOLLIE("Mollie settings"),
INVOICE("Invoice settings"),
INVOICE_EU("Invoice settings for EU"),
MAIL("E-Mail settings");
Expand Down
Expand Up @@ -95,7 +95,7 @@ <h2>Invoice settings</h2>
</div>
</div>

<div class="page-header" data-ng-if="organizationConf.paymentPaypal || organizationConf.paymentStripe || organizationConf.paymentOffline">
<div class="page-header" data-ng-if="organizationConf.paymentPaypal || organizationConf.paymentStripe || organizationConf.paymentMollie || organizationConf.paymentOffline">
<h2>Payment</h2>
<span>Payment provider settings</span>
</div>
Expand Down Expand Up @@ -127,6 +127,20 @@ <h2>Payment</h2>
</div>
</div>

<div data-ng-if="organizationConf.paymentMollie" class="panel panel-default">
<div class="panel-heading">
<div class="panel-title"></i> Mollie configuration</div>
</div>
<div class="panel-body">
<div class="alert alert-info">
<p><i class="fa fa-info-circle"></i> in order to accept payments through Mollie, you must have Live API key.</p>
</div>
<div data-ng-repeat="setting in organizationConf.paymentMollie.settings">
<setting data-obj="setting" data-display-delete-if-needed="true" data-delete-handler="organizationConf.delete(config)" data-ng-class="{'system-setting': setting.configurationPathLevel === 'SYSTEM'}"></setting>
</div>
</div>
</div>

<div data-ng-if="organizationConf.paymentOffline" class="panel panel-default">
<div class="panel-heading">
<div class="panel-title"><i class="fa fa-exchange"></i> Offline payment configuration</div>
Expand Down
Expand Up @@ -95,7 +95,7 @@ <h2>Invoice settings</h2>
</div>


<div class="page-header" data-ng-if="systemConf.paymentPaypal || systemConf.paymentStripe || systemConf.paymentOffline">
<div class="page-header" data-ng-if="systemConf.paymentPaypal || systemConf.paymentStripe || systemConf.paymentMollie || systemConf.paymentOffline">
<h2>Payment</h2>
<span>Payment provider settings</span>
</div>
Expand Down Expand Up @@ -127,6 +127,20 @@ <h2>Payment</h2>
</div>
</div>

<div data-ng-if="systemConf.paymentMollie" class="panel panel-default">
<div class="panel-heading">
<div class="panel-title"> Mollie configuration</div>
</div>
<div class="panel-body">
<div class="alert alert-info">
<p><i class="fa fa-info-circle"></i> in order to accept payments through Mollie, you must have Live API key.</p>
</div>
<div data-ng-repeat="setting in systemConf.paymentMollie.settings">
<setting data-obj="setting" data-display-delete-if-needed="true" data-delete-handler="systemConf.delete(config)" data-ng-class="{'system-setting': setting.configurationPathLevel === 'SYSTEM'}"></setting>
</div>
</div>
</div>

<div data-ng-if="systemConf.paymentOffline" class="panel panel-default">
<div class="panel-heading">
<div class="panel-title"><i class="fa fa-exchange"></i> Offline payment configuration</div>
Expand Down
Expand Up @@ -113,7 +113,7 @@
mailAttemptsCount: _.find(original['MAIL'], function(e) {return e.configurationKey === 'MAIL_ATTEMPTS_COUNT';})
};
}
_.forEach(['PAYMENT_STRIPE', 'PAYMENT_PAYPAL', 'PAYMENT_OFFLINE', 'INVOICE_EU'], function(group) {
_.forEach(['PAYMENT_STRIPE', 'PAYMENT_PAYPAL', 'PAYMENT_MOLLIE', 'PAYMENT_OFFLINE', 'INVOICE_EU'], function(group) {
if(angular.isDefined(original[group]) && original[group].length > 0) {
transformed[_.camelCase(group)] = {
settings: original[group]
Expand Down

0 comments on commit 141b09e

Please sign in to comment.