@Test public void perform_shouldReturnAuthorizationResult_whenResponseIsAuthorisedUsingCurrentSiteMerchant() throws WorldpayException { when(worldpayGatewayMock.directAuthorise(directAuthoriseServiceRequestCaptor.capture())).thenReturn(directAuthoriseServiceResponseMock); when(authorizationResultMock.getTransactionStatus()).thenReturn(TransactionStatus.ACCEPTED); when(worldpayOrderServiceMock.convertAmount(amountMock)).thenReturn(BigDecimal.valueOf(3.30)); testObj.perform(subscriptionAuthorizationRequestMock); verify(worldpayGatewayMock).directAuthorise(directAuthoriseServiceRequestCaptor.capture()); verify(worldpayAuthorizationResultConverterMock).convert(directAuthoriseServiceResponseMock); verify(authorizationResultMock).setMerchantTransactionCode(WORLDPAY_ORDER_CODE); verify(authorizationResultMock).setRequestId(WORLDPAY_ORDER_CODE); verify(authorizationResultMock).setRequestToken(MERCHANT_CODE); verify(authorizationResultMock).setCurrency(subscriptionAuthorizationRequestMock.getCurrency()); verify(authorizationResultMock).setAuthorizationTime(any(Date.class)); verify(authorizationResultMock).setTotalAmount(BigDecimal.valueOf(3.30)); verify(worldpayMerchantInfoServiceMock).getCurrentSiteMerchant(); checkDirectAuthoriseServiceRequestValues(); }
@Override public AuthorizationResult perform(final SubscriptionAuthorizationRequest subscriptionAuthorizationRequest) { final WorldpayAdditionalInfoData additionalInfo = getWorldpayAdditionalInfoData(subscriptionAuthorizationRequest.getCv2()); final MerchantInfo merchantInfo = getMerchant(); if (merchantInfo != null) { final String merchantCode = merchantInfo.getMerchantCode(); try { final DirectAuthoriseServiceRequest request = buildWorldpayRequest(subscriptionAuthorizationRequest, additionalInfo, merchantInfo); final DirectAuthoriseServiceResponse response = getWorldpayServiceGateway().directAuthorise(request); return getAuthorizationResult(merchantCode, response, subscriptionAuthorizationRequest); } catch (final WorldpayException e) { LOG.error("Worldpay Exception for transaction: " + subscriptionAuthorizationRequest.getMerchantTransactionCode(), e); return createErrorAuthorizeResult(merchantCode, subscriptionAuthorizationRequest); } } return createErrorAuthorizeResult(UNKNOWN_MERCHANT_CODE, subscriptionAuthorizationRequest); }
DefaultWorldpayTokenisedAuthorizationCommand extends WorldpayCommand implements SubscriptionAuthorizationCommand { @Override public AuthorizationResult perform(final SubscriptionAuthorizationRequest subscriptionAuthorizationRequest) { final WorldpayAdditionalInfoData additionalInfo = getWorldpayAdditionalInfoData(subscriptionAuthorizationRequest.getCv2()); final MerchantInfo merchantInfo = getMerchant(); if (merchantInfo != null) { final String merchantCode = merchantInfo.getMerchantCode(); try { final DirectAuthoriseServiceRequest request = buildWorldpayRequest(subscriptionAuthorizationRequest, additionalInfo, merchantInfo); final DirectAuthoriseServiceResponse response = getWorldpayServiceGateway().directAuthorise(request); return getAuthorizationResult(merchantCode, response, subscriptionAuthorizationRequest); } catch (final WorldpayException e) { LOG.error("Worldpay Exception for transaction: " + subscriptionAuthorizationRequest.getMerchantTransactionCode(), e); return createErrorAuthorizeResult(merchantCode, subscriptionAuthorizationRequest); } } return createErrorAuthorizeResult(UNKNOWN_MERCHANT_CODE, subscriptionAuthorizationRequest); } }
DefaultWorldpayTokenisedAuthorizationCommand extends WorldpayCommand implements SubscriptionAuthorizationCommand { @Override public AuthorizationResult perform(final SubscriptionAuthorizationRequest subscriptionAuthorizationRequest) { final WorldpayAdditionalInfoData additionalInfo = getWorldpayAdditionalInfoData(subscriptionAuthorizationRequest.getCv2()); final MerchantInfo merchantInfo = getMerchant(); if (merchantInfo != null) { final String merchantCode = merchantInfo.getMerchantCode(); try { final DirectAuthoriseServiceRequest request = buildWorldpayRequest(subscriptionAuthorizationRequest, additionalInfo, merchantInfo); final DirectAuthoriseServiceResponse response = getWorldpayServiceGateway().directAuthorise(request); return getAuthorizationResult(merchantCode, response, subscriptionAuthorizationRequest); } catch (final WorldpayException e) { LOG.error("Worldpay Exception for transaction: " + subscriptionAuthorizationRequest.getMerchantTransactionCode(), e); return createErrorAuthorizeResult(merchantCode, subscriptionAuthorizationRequest); } } return createErrorAuthorizeResult(UNKNOWN_MERCHANT_CODE, subscriptionAuthorizationRequest); } DefaultWorldpayTokenisedAuthorizationCommand(final Converter<BillingInfo, Address> worldpayBillingInfoAddressConverter, final Converter<DirectAuthoriseServiceResponse, AuthorizationResult> worldpayAuthorizationResultConverter, final WorldpayDynamicInteractionResolverService worldpayDynamicInteractionResolverService, final WorldpayMerchantInfoService worldpayMerchantInfoService, final WorldpayPaymentTransactionService worldpayPaymentTransactionService, final WorldpayOrderService worldpayOrderService, final WorldpayServiceGateway worldpayServiceGateway); }
DefaultWorldpayTokenisedAuthorizationCommand extends WorldpayCommand implements SubscriptionAuthorizationCommand { @Override public AuthorizationResult perform(final SubscriptionAuthorizationRequest subscriptionAuthorizationRequest) { final WorldpayAdditionalInfoData additionalInfo = getWorldpayAdditionalInfoData(subscriptionAuthorizationRequest.getCv2()); final MerchantInfo merchantInfo = getMerchant(); if (merchantInfo != null) { final String merchantCode = merchantInfo.getMerchantCode(); try { final DirectAuthoriseServiceRequest request = buildWorldpayRequest(subscriptionAuthorizationRequest, additionalInfo, merchantInfo); final DirectAuthoriseServiceResponse response = getWorldpayServiceGateway().directAuthorise(request); return getAuthorizationResult(merchantCode, response, subscriptionAuthorizationRequest); } catch (final WorldpayException e) { LOG.error("Worldpay Exception for transaction: " + subscriptionAuthorizationRequest.getMerchantTransactionCode(), e); return createErrorAuthorizeResult(merchantCode, subscriptionAuthorizationRequest); } } return createErrorAuthorizeResult(UNKNOWN_MERCHANT_CODE, subscriptionAuthorizationRequest); } DefaultWorldpayTokenisedAuthorizationCommand(final Converter<BillingInfo, Address> worldpayBillingInfoAddressConverter, final Converter<DirectAuthoriseServiceResponse, AuthorizationResult> worldpayAuthorizationResultConverter, final WorldpayDynamicInteractionResolverService worldpayDynamicInteractionResolverService, final WorldpayMerchantInfoService worldpayMerchantInfoService, final WorldpayPaymentTransactionService worldpayPaymentTransactionService, final WorldpayOrderService worldpayOrderService, final WorldpayServiceGateway worldpayServiceGateway); @Override AuthorizationResult perform(final SubscriptionAuthorizationRequest subscriptionAuthorizationRequest); }
DefaultWorldpayTokenisedAuthorizationCommand extends WorldpayCommand implements SubscriptionAuthorizationCommand { @Override public AuthorizationResult perform(final SubscriptionAuthorizationRequest subscriptionAuthorizationRequest) { final WorldpayAdditionalInfoData additionalInfo = getWorldpayAdditionalInfoData(subscriptionAuthorizationRequest.getCv2()); final MerchantInfo merchantInfo = getMerchant(); if (merchantInfo != null) { final String merchantCode = merchantInfo.getMerchantCode(); try { final DirectAuthoriseServiceRequest request = buildWorldpayRequest(subscriptionAuthorizationRequest, additionalInfo, merchantInfo); final DirectAuthoriseServiceResponse response = getWorldpayServiceGateway().directAuthorise(request); return getAuthorizationResult(merchantCode, response, subscriptionAuthorizationRequest); } catch (final WorldpayException e) { LOG.error("Worldpay Exception for transaction: " + subscriptionAuthorizationRequest.getMerchantTransactionCode(), e); return createErrorAuthorizeResult(merchantCode, subscriptionAuthorizationRequest); } } return createErrorAuthorizeResult(UNKNOWN_MERCHANT_CODE, subscriptionAuthorizationRequest); } DefaultWorldpayTokenisedAuthorizationCommand(final Converter<BillingInfo, Address> worldpayBillingInfoAddressConverter, final Converter<DirectAuthoriseServiceResponse, AuthorizationResult> worldpayAuthorizationResultConverter, final WorldpayDynamicInteractionResolverService worldpayDynamicInteractionResolverService, final WorldpayMerchantInfoService worldpayMerchantInfoService, final WorldpayPaymentTransactionService worldpayPaymentTransactionService, final WorldpayOrderService worldpayOrderService, final WorldpayServiceGateway worldpayServiceGateway); @Override AuthorizationResult perform(final SubscriptionAuthorizationRequest subscriptionAuthorizationRequest);  }