Search in sources :

Example 6 with DefaultNoOpPaymentMethodPlugin

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);
}
Also used : PaymentMethod(org.killbill.billing.payment.api.PaymentMethod) DefaultPaymentMethod(org.killbill.billing.payment.api.DefaultPaymentMethod) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin)

Example 7 with DefaultNoOpPaymentMethodPlugin

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);
}
Also used : DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with DefaultNoOpPaymentMethodPlugin

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);
}
Also used : Account(org.killbill.billing.account.api.Account) PluginProperty(org.killbill.billing.payment.api.PluginProperty) PaymentMethod(org.killbill.billing.payment.api.PaymentMethod) UUID(java.util.UUID) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) Test(org.testng.annotations.Test)

Example 9 with DefaultNoOpPaymentMethodPlugin

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);
}
Also used : DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) UUID(java.util.UUID) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) Test(org.testng.annotations.Test)

Aggregations

DefaultNoOpPaymentMethodPlugin (org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin)9 Test (org.testng.annotations.Test)6 UUID (java.util.UUID)5 Account (org.killbill.billing.account.api.Account)3 PaymentMethod (org.killbill.billing.payment.api.PaymentMethod)3 DateTime (org.joda.time.DateTime)1 MutableCallContext (org.killbill.billing.callcontext.MutableCallContext)1 DefaultPaymentMethod (org.killbill.billing.payment.api.DefaultPaymentMethod)1 PaymentMethodPlugin (org.killbill.billing.payment.api.PaymentMethodPlugin)1 PluginProperty (org.killbill.billing.payment.api.PluginProperty)1 PaymentMethodModelDao (org.killbill.billing.payment.dao.PaymentMethodModelDao)1 BeforeMethod (org.testng.annotations.BeforeMethod)1