Skip to content

Commit

Permalink
[AD-20] Recurring payment for subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
kpieloch committed Oct 31, 2023
1 parent 2589085 commit c1872eb
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class DefaultAdyenCheckoutFacade implements AdyenCheckoutFacade {
private static final String IT_LOCALE = "it_IT";
private static final String ES_LOCALE = "es_ES";
private static final String US = "US";
public static final String RECURRING_RECURRING_DETAIL_REFERENCE = "recurring.recurringDetailReference";

private BaseStoreService baseStoreService;
private SessionService sessionService;
Expand Down Expand Up @@ -406,7 +407,7 @@ public OrderData authorisePayment(final HttpServletRequest request, final CartDa
CheckoutPaymentsAction action = paymentsResponse.getAction();

LOGGER.info("Authorize payment with result code: " + resultCode + " action: " + (action != null ? action.getType() : "null"));
// TODO: Put token on order!

if (PaymentsResponse.ResultCodeEnum.AUTHORISED == resultCode || PaymentsResponse.ResultCodeEnum.PENDING == resultCode) {
return createAuthorizedOrder(paymentsResponse);
}
Expand Down Expand Up @@ -533,15 +534,25 @@ public OrderData handle3DSResponse(final Map<String, String> details) throws Exc
private OrderData createAuthorizedOrder(final PaymentsResponse paymentsResponse) throws InvalidCartException {
final CartModel cartModel = cartService.getSessionCart();
final String merchantTransactionCode = cartModel.getCode();
if(!paymentsResponse.getAdditionalData().isEmpty()&&paymentsResponse.getAdditionalData().containsKey("recurring.recurringDetailReference")) {
cartModel.getPaymentInfo().setAdyenSelectedReference(paymentsResponse.getAdditionalData().get("recurring.recurringDetailReference"));
}
//First save the transactions to the CartModel < AbstractOrderModel

updateAdyenSelectedReferenceIfPresent(cartModel, paymentsResponse);

// First save the transactions to the CartModel < AbstractOrderModel
getAdyenTransactionService().authorizeOrderModel(cartModel, merchantTransactionCode, paymentsResponse.getPspReference());

return createOrderFromPaymentsResponse(paymentsResponse);
}

private void updateAdyenSelectedReferenceIfPresent(final CartModel cartModel, final PaymentsResponse paymentsResponse) {
Map<String, String> additionalData = paymentsResponse.getAdditionalData();
if (additionalData != null) {
String recurringDetailReference = additionalData.get(RECURRING_RECURRING_DETAIL_REFERENCE);
if (recurringDetailReference != null) {
cartModel.getPaymentInfo().setAdyenSelectedReference(recurringDetailReference);
}
}
}

/**
* Create order and authorized TX
*/
Expand Down Expand Up @@ -582,7 +593,6 @@ private OrderData fillOrderDataWithPaymentInfo(OrderData orderData, PaymentsResp

if (paymentsResponse.getAdditionalData() != null) {
orderData.setAdyenPosReceipt(paymentsResponse.getAdditionalData().get("pos.receipt"));
//orderData.getPaymentInfo().setgetPaymentInfo().set
}

return orderData;
Expand Down

0 comments on commit c1872eb

Please sign in to comment.