-
-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactoring: allow more than one payment method for provider wip: mollie integration * first working prototype * retrieve supported payment methods from payment provider * add additional payment methods * add generic "please select payment method" message * implement refund and getInfo * return empty methods list if the user configured unsupported methods * update frontend (cherry picked from commit 40ba12b)
- Loading branch information
Showing
42 changed files
with
1,223 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/alfio/controller/payment/api/mollie/MolliePaymentWebhookController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* 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.controller.payment.api.mollie; | ||
|
||
import alfio.manager.TicketReservationManager; | ||
import alfio.model.transaction.PaymentProxy; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import static alfio.manager.payment.MollieWebhookPaymentManager.WEBHOOK_URL_TEMPLATE; | ||
|
||
@RestController | ||
@Log4j2 | ||
@AllArgsConstructor | ||
public class MolliePaymentWebhookController { | ||
private final TicketReservationManager ticketReservationManager; | ||
|
||
@SuppressWarnings("MVCPathVariableInspection") | ||
@PostMapping(WEBHOOK_URL_TEMPLATE) | ||
public ResponseEntity<String> receivePaymentConfirmation(HttpServletRequest request, | ||
@PathVariable("eventShortName") String eventName, | ||
@PathVariable("reservationId") String reservationId) { | ||
return Optional.ofNullable(StringUtils.trimToNull(request.getParameter("id"))) | ||
.map(id -> { | ||
var content = "id="+id; | ||
var result = ticketReservationManager.processTransactionWebhook(content, null, PaymentProxy.MOLLIE, | ||
Map.of("eventName", eventName, "reservationId", reservationId)); | ||
if(result.isSuccessful()) { | ||
return ResponseEntity.ok("OK"); | ||
} else if(result.isError()) { | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result.getReason()); | ||
} | ||
return ResponseEntity.ok(result.getReason()); | ||
}) | ||
.orElseGet(() -> ResponseEntity.badRequest().body("NOK")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.