@Test(groups = "slow") public void testUniqueExternalPaymentMethod() throws PaymentApiException { paymentApi.addPaymentMethod(account, "thisonewillwork", ExternalPaymentProviderPlugin.PLUGIN_NAME, true, null, ImmutableList.<PluginProperty>of(), callContext); try { paymentApi.addPaymentMethod(account, "thisonewillnotwork", ExternalPaymentProviderPlugin.PLUGIN_NAME, true, null, ImmutableList.<PluginProperty>of(), callContext); } catch (PaymentApiException e) { assertEquals(e.getCode(), ErrorCode.PAYMENT_EXTERNAL_PAYMENT_METHOD_ALREADY_EXISTS.getCode()); } }
protected void setupAccount() throws Exception { account = createAccountWithNonOsgiPaymentMethod(getAccountData(0)); assertNotNull(account); paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, true, paymentMethodPlugin, PLUGIN_PROPERTIES, callContext); }
private void setupAccount() throws Exception { final AccountData accountData = getAccountData(0); account = accountUserApi.createAccount(accountData, testCallContext); assertNotNull(account); final PaymentMethodPlugin info = createPaymentMethodPlugin(); paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, true, info, PLUGIN_PROPERTIES, testCallContext); }
private Account addTestExternalPaymentMethod(final Account account, final PaymentMethodPlugin paymentMethodInfo) throws Exception { final UUID paymentMethodId = paymentApi.addPaymentMethod(account, paymentMethodInfo.getExternalPaymentMethodId(), ExternalPaymentProviderPlugin.PLUGIN_NAME, true, paymentMethodInfo, ImmutableList.<PluginProperty>of(), callContext); return accountApi.getAccountById(account.getId(), internalCallContext); }
protected Account createAccountWithNonOsgiPaymentMethod(final AccountData accountData) throws Exception { final Account account = createAccount(accountData); final PaymentMethodPlugin info = createPaymentMethodPlugin(); paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, true, info, PLUGIN_PROPERTIES, callContext); return accountUserApi.getAccountById(account.getId(), callContext); }
return paymentApi.addPaymentMethod(account, paymentMethodJson.getExternalKey(), paymentMethodJson.getPluginName(), isDefault, paymentData.getPluginDetail(), pluginProperties, callContext);
@Test(groups = "slow") public void testCreateAuthWithControl() throws PaymentApiException { final PaymentMethodPlugin paymentMethodInfo = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, null); final UUID newPaymentMethodId = paymentApi.addPaymentMethod(account, null, MockPaymentProviderPlugin.PLUGIN_NAME, false, paymentMethodInfo, ImmutableList.<PluginProperty>of(), callContext); testPaymentControlPluginApi.setNewPaymentMethodId(newPaymentMethodId); final Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, account.getPaymentMethodId(), null, BigDecimal.TEN, Currency.USD, null,null, UUID.randomUUID().toString(), ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext); Assert.assertEquals(payment.getPaymentMethodId(), newPaymentMethodId); verifyOnSuccess(payment.getId(), payment.getExternalKey(), payment.getTransactions().get(0).getId(), payment.getTransactions().get(0).getExternalKey(), BigDecimal.TEN, Currency.USD); }
@Test(groups = "slow") public void testAuthSuccessWithPaymentControlNullPaymentMethodId() throws Exception { final AccountData accountData = getAccountData(1); final Account account = accountUserApi.createAccount(accountData, callContext); // Add non-default payment method final PaymentMethodPlugin info = createPaymentMethodPlugin(); final UUID paymentMethodId = paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, false, info, PLUGIN_PROPERTIES, callContext); testPaymentControlWithControl.setAdjustedPaymentMethodId(paymentMethodId); busHandler.pushExpectedEvents(NextEvent.PAYMENT); final Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, null, null, BigDecimal.ONE, account.getCurrency(), null, null, null, properties, paymentOptions, callContext); assertListenerStatus(); final Payment paymentWithAttempts = paymentApi.getPayment(payment.getId(), false, true, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(paymentWithAttempts.getPaymentMethodId(), paymentMethodId); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().size(), 1); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().get(0).getPaymentMethodId(), paymentMethodId); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().get(0).getStateName(), "SUCCESS"); }
@Test(groups = "slow") public void testRefreshWithDeletedPaymentMethod() throws Exception { final Account account = testHelper.createTestAccount("super@bar.com", true); Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 1); final UUID firstPmId = account.getPaymentMethodId(); String secondPaymentMethodExternalKey = UUID.randomUUID().toString(); final UUID secondPmId = paymentApi.addPaymentMethod(account, secondPaymentMethodExternalKey, MockPaymentProviderPlugin.PLUGIN_NAME, true, new DefaultNoOpPaymentMethodPlugin(secondPaymentMethodExternalKey, false, null), PLUGIN_PROPERTIES, callContext); Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 2); Assert.assertEquals(paymentApi.getAccountPaymentMethods(account.getId(), false, false, PLUGIN_PROPERTIES, callContext).size(), 2); // Remove second PM from plugin getPluginApi().deletePaymentMethod(account.getId(), secondPmId, PLUGIN_PROPERTIES, callContext); Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 1); Assert.assertEquals(paymentApi.getAccountPaymentMethods(account.getId(), false, false, PLUGIN_PROPERTIES, callContext).size(), 2); // Verify that the refresh sees that PM as being deleted now final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, callContext, internalCallContext); Assert.assertEquals(methods.size(), 1); checkPaymentMethodExistsWithStatus(methods, firstPmId, true); final PaymentMethodModelDao deletedPMModel = paymentDao.getPaymentMethodIncludedDeleted(secondPmId, internalCallContext); Assert.assertNotNull(deletedPMModel); Assert.assertFalse(deletedPMModel.isActive()); }
@Test(groups = "slow") public void testAuthFailureWithPaymentControlNullPaymentMethodId() throws Exception { final AccountData accountData = getAccountData(1); final Account account = accountUserApi.createAccount(accountData, callContext); // Add non-default payment method final PaymentMethodPlugin info = createPaymentMethodPlugin(); final UUID paymentMethodId = paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, false, info, PLUGIN_PROPERTIES, callContext); testPaymentControlWithControl.setAdjustedPaymentMethodId(paymentMethodId); paymentPlugin.makeNextPaymentFailWithError(); busHandler.pushExpectedEvents(NextEvent.PAYMENT_ERROR); final Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, null, null, BigDecimal.ONE, account.getCurrency(), null, null, null, properties, paymentOptions, callContext); assertListenerStatus(); final Payment paymentWithAttempts = paymentApi.getPayment(payment.getId(), false, true, ImmutableList.<PluginProperty>of(), callContext); Assert.assertEquals(paymentWithAttempts.getPaymentMethodId(), paymentMethodId); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().size(), 1); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().get(0).getPaymentMethodId(), paymentMethodId); Assert.assertEquals(paymentWithAttempts.getPaymentAttempts().get(0).getStateName(), "ABORTED"); }
paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, true, paymentMethodPlugin, PLUGIN_PROPERTIES, callContext);
public UUID addTestPaymentMethod(final String pluginName, final Account account, final PaymentMethodPlugin paymentMethodInfo, final Iterable<PluginProperty> pluginProperties) throws Exception { final boolean setDefault = paymentMethodInfo.isDefaultPaymentMethod(); final UUID paymentMethodId = paymentApi.addPaymentMethod(account, paymentMethodInfo.getExternalPaymentMethodId(), pluginName, setDefault, paymentMethodInfo, pluginProperties, context); if (isFastTest() && setDefault) { final Account account1 = new MockAccountBuilder(account).paymentMethodId(paymentMethodId).build(); accountApi.updateAccount(account1, context); } return paymentMethodId; }