DefaultWorldpayOrderService implements WorldpayOrderService { @Override public StoredCredentials createStoredCredentials(final Usage usage, final MerchantInitiatedReason merchantInitiatedReason, final String transactionIdentifier) { Preconditions.checkArgument(Objects.nonNull(usage), "Usage must be specified when creating a storedCredentials"); return new StoredCredentials(merchantInitiatedReason,transactionIdentifier,usage); } DefaultWorldpayOrderService(final CommonI18NService commonI18NService, final WorldpayUrlService worldpayUrlService, final SiteConfigService siteConfigService); @Override Amount createAmount(final Currency currency, final int amount); @Override Amount createAmount(final CurrencyModel currencyModel, final double amount); @Override Amount createAmount(final Currency currency, final double amount); @Override BigDecimal convertAmount(final Amount amount); @Override Session createSession(final WorldpayAdditionalInfoData worldpayAdditionalInfo); @Override Browser createBrowser(final WorldpayAdditionalInfoData worldpayAdditionalInfo); @Override BasicOrderInfo createBasicOrderInfo(final String worldpayOrderCode, final String description, final Amount amount); @Override Shopper createShopper(final String customerEmail, final Session session, final Browser browser); @Override Shopper createAuthenticatedShopper(final String customerEmail, final String authenticatedShopperID, final Session session, final Browser browser); @Override TokenRequest createTokenRequest(final String tokenEventReference, final String tokenReason); @Override TokenRequest createTokenRequestForDeletion(final String tokenEventReference, final String tokenReason, final String authenticatedShopperId); @Override CreateTokenServiceRequest createTokenServiceRequest(final MerchantInfo merchantInfo, final String authenticatedShopperId,
                                                               final Payment csePayment, final TokenRequest tokenRequest); @Override Payment createBankPayment(final String paymentMethod, final String shopperBankCode); @Override Payment createKlarnaPayment(final String countryCode, final String languageCode, final String extraMerchantData); @Override Token createToken(final String subscriptionId, final String securityCode); @Override UpdateTokenServiceRequest createUpdateTokenServiceRequest(final MerchantInfo merchantInfo, final WorldpayAdditionalInfoData worldpayAdditionalInfoData,
                                                                     final TokenRequest tokenRequest, final String paymentTokenID,
                                                                     final CardDetails cardDetails); @Override Payment createApplePayPayment(final ApplePayAdditionalAuthInfo worldpayAdditionalInfoApplePayData); @Override Additional3DSData createAdditional3DSData(final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override Cse createCsePayment(final CSEAdditionalAuthInfo cseAdditionalAuthInfo, final Address billingAddress); @Override PayWithGoogleSSL createGooglePayPayment(final String protocolVersion, final String signature, final String signedMessage); @Override StoredCredentials createStoredCredentials(final Usage usage, final MerchantInitiatedReason merchantInitiatedReason, final String transactionIdentifier);  }
@Test public void createStoreCredentials_ShouldCreateAStoredCredentials_WhenAllParametersAreProvided() { when(abstractOrderModelMock.getPaymentInfo().getTransactionIdentifier()).thenReturn(TRANSACTION_IDENTIFIER); final StoredCredentials result = testObj.createStoredCredentials(Usage.USED, MerchantInitiatedReason.RECURRING, TRANSACTION_IDENTIFIER); assertThat(result.getUsage()).isEqualTo(Usage.USED); assertThat(result.getMerchantInitiatedReason()).isEqualTo(MerchantInitiatedReason.RECURRING); assertThat(result.getSchemeTransactionIdentifier()).isEqualTo(TRANSACTION_IDENTIFIER); }
@Test public void createStoreCredentials_ShouldCreateAStoredCredentials_WhenOnlyUsageParameterIsProvided() { when(abstractOrderModelMock.getPaymentInfo().getTransactionIdentifier()).thenReturn(TRANSACTION_IDENTIFIER); final StoredCredentials result = testObj.createStoredCredentials(Usage.USED, null, null); assertThat(result.getUsage()).isEqualTo(Usage.USED); assertThat(result.getMerchantInitiatedReason()).isNull(); assertThat(result.getSchemeTransactionIdentifier()).isNull(); }
@Test(expected = IllegalArgumentException.class) public void createStoreCredentials_ShouldThrowAnIlegalArgumentException_WhenUsageArgumentIsNull() { testObj.createStoredCredentials(null, null, null); }