use of org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin in project killbill by killbill.
the class PaymentMethodProcessor method createOrGetExternalPaymentMethod.
public UUID createOrGetExternalPaymentMethod(final String paymentMethodExternalKey, final Account account, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext context) throws PaymentApiException {
// Check if this account has already used the external payment plugin
// If not, it's the first time - add a payment method for it
final PaymentMethod externalPaymentMethod = getExternalPaymentMethod(properties, callContext, context);
if (externalPaymentMethod != null) {
return externalPaymentMethod.getId();
}
final DefaultNoOpPaymentMethodPlugin props = new DefaultNoOpPaymentMethodPlugin(UUIDs.randomUUID().toString(), false, properties);
return addPaymentMethod(paymentMethodExternalKey, ExternalPaymentProviderPlugin.PLUGIN_NAME, account, false, props, properties, callContext, context);
}
use of org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin in project killbill by killbill.
the class TestPaymentApiNoDB method beforeMethod.
@BeforeMethod(groups = "fast")
public void beforeMethod() throws Exception {
if (hasFailed()) {
return;
}
super.beforeMethod();
final PaymentMethodPlugin paymentMethodInfo = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null);
account = testHelper.addTestPaymentMethod(account, paymentMethodInfo);
}
use of org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin in project killbill by killbill.
the class TestPaymentMethodProcessorRefreshWithDB method testRefreshWithNewPaymentMethod.
@Test(groups = "slow")
public void testRefreshWithNewPaymentMethod() throws Exception {
final Account account = testHelper.createTestAccount("foo@bar.com", true);
Assert.assertEquals(getPluginApi().getPaymentMethods(account.getId(), true, PLUGIN_PROPERTIES, callContext).size(), 1);
final UUID existingPMId = account.getPaymentMethodId();
// Add new payment in plugin directly
final UUID newPmId = UUID.randomUUID();
getPluginApi().addPaymentMethod(account.getId(), newPmId, new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, ImmutableList.<PluginProperty>of()), false, PLUGIN_PROPERTIES, callContext);
// Verify that the refresh does indeed show 2 PMs
final List<PaymentMethod> methods = paymentMethodProcessor.refreshPaymentMethods(MockPaymentProviderPlugin.PLUGIN_NAME, account, PLUGIN_PROPERTIES, callContext, internalCallContext);
Assert.assertEquals(methods.size(), 2);
checkPaymentMethodExistsWithStatus(methods, existingPMId, true);
checkPaymentMethodExistsWithStatus(methods, newPmId, true);
}
use of org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin in project killbill by killbill.
the class TestPaymentApiWithControl method testAddPaymentMethodWithControl.
@Test(groups = "slow")
public void testAddPaymentMethodWithControl() throws PaymentApiException {
final PaymentMethodPlugin paymentMethodInfo = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), false, null);
testPaymentControlPluginApi.setNewPaymentMethodName(MockPaymentProviderPlugin.PLUGIN_NAME);
final UUID newPaymentMethodId = paymentApi.addPaymentMethodWithPaymentControl(account, null, "SomeDummyValueToBeChanged", false, paymentMethodInfo, ImmutableList.<PluginProperty>of(), PAYMENT_OPTIONS, callContext);
final PaymentMethod paymentMethod = paymentApi.getPaymentMethodById(newPaymentMethodId, false, false, ImmutableList.<PluginProperty>of(), callContext);
Assert.assertEquals(paymentMethod.getPluginName(), MockPaymentProviderPlugin.PLUGIN_NAME);
final Payment payment = paymentApi.createAuthorizationWithPaymentControl(account, newPaymentMethodId, null, BigDecimal.TEN, Currency.USD, null, UUID.randomUUID().toString(), 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);
}
Aggregations