Search in sources :

Example 1 with ComboPaymentTransaction

use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.

the class TestPayment method testComboAuthorizationControlPluginException.

@Test(groups = "slow")
public void testComboAuthorizationControlPluginException() throws Exception {
    final Account accountJson = getAccount();
    accountJson.setAccountId(null);
    final String paymentExternalKey = UUID.randomUUID().toString();
    final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
    mockPaymentControlProviderPlugin.throwsException(new IllegalStateException());
    try {
        paymentApi.createComboPayment(comboPaymentTransaction, Arrays.asList(MockPaymentControlProviderPlugin.PLUGIN_NAME), requestOptions);
        fail();
    } catch (KillBillClientException e) {
        assertEquals(e.getResponse().getStatusCode(), 500);
    }
}
Also used : Account(org.killbill.billing.client.model.gen.Account) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) KillBillClientException(org.killbill.billing.client.KillBillClientException) Test(org.testng.annotations.Test)

Example 2 with ComboPaymentTransaction

use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.

the class TestPayment method testComboAuthorizationInvalidPaymentMethod.

@Test(groups = "slow")
public void testComboAuthorizationInvalidPaymentMethod() throws Exception {
    final Account accountJson = getAccount();
    accountJson.setAccountId(null);
    final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
    info.setProperties(null);
    final UUID paymentMethodId = UUID.randomUUID();
    final PaymentMethod paymentMethodJson = new PaymentMethod();
    paymentMethodJson.setPluginName(PLUGIN_NAME);
    paymentMethodJson.setPluginInfo(info);
    paymentMethodJson.setIsDefault(true);
    paymentMethodJson.setPaymentMethodId(paymentMethodId);
    final ComboPaymentTransaction comboPaymentTransaction = new ComboPaymentTransaction(accountJson, paymentMethodJson, new PaymentTransaction(), ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of(), null);
    final Payment payment = paymentApi.createComboPayment(comboPaymentTransaction, NULL_PLUGIN_NAMES, requestOptions);
    // Client returns null in case of a 404
    Assert.assertNull(payment);
}
Also used : PaymentTransaction(org.killbill.billing.client.model.gen.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) Account(org.killbill.billing.client.model.gen.Account) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) InvoicePayment(org.killbill.billing.client.model.gen.InvoicePayment) Payment(org.killbill.billing.client.model.gen.Payment) PaymentMethodPluginDetail(org.killbill.billing.client.model.gen.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.gen.PaymentMethod) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Example 3 with ComboPaymentTransaction

use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.

the class TestPayment method testComboAuthorizationControlWithNullPaymentMethodId.

@Test(groups = "slow")
public void testComboAuthorizationControlWithNullPaymentMethodId() throws Exception {
    final Account accountJson = createAccount();
    // Non-default payment method
    final PaymentMethod paymentMethod = createPaymentMethod(accountJson, false);
    mockPaymentControlProviderPlugin.setAdjustedPaymentMethodId(paymentMethod.getPaymentMethodId());
    accountJson.setAccountId(null);
    final String paymentExternalKey = UUID.randomUUID().toString();
    final PaymentTransaction authTransactionJson = new PaymentTransaction();
    authTransactionJson.setPaymentExternalKey(paymentExternalKey);
    authTransactionJson.setAmount(BigDecimal.TEN);
    authTransactionJson.setTransactionType(TransactionType.AUTHORIZE);
    final ComboPaymentTransaction comboPaymentTransaction = new ComboPaymentTransaction();
    comboPaymentTransaction.setAccount(accountJson);
    comboPaymentTransaction.setTransaction(authTransactionJson);
    comboPaymentTransaction.setTransaction(authTransactionJson);
    final Payment payment = paymentApi.createComboPayment(comboPaymentTransaction, ImmutableList.<String>of(MockPaymentControlProviderPlugin.PLUGIN_NAME), requestOptions);
    verifyComboPayment(payment, paymentExternalKey, BigDecimal.TEN, BigDecimal.ZERO, BigDecimal.ZERO, 1, 1);
    assertEquals(paymentApi.getPayment(payment.getPaymentId(), false, true, ImmutableMap.<String, String>of(), AuditLevel.NONE, requestOptions).getPaymentAttempts().size(), 1);
}
Also used : PaymentTransaction(org.killbill.billing.client.model.gen.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) Account(org.killbill.billing.client.model.gen.Account) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) InvoicePayment(org.killbill.billing.client.model.gen.InvoicePayment) Payment(org.killbill.billing.client.model.gen.Payment) PaymentMethod(org.killbill.billing.client.model.gen.PaymentMethod) Test(org.testng.annotations.Test)

Example 4 with ComboPaymentTransaction

use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.

the class TestPayment method testComboAuthorization.

@Test(groups = "slow")
public void testComboAuthorization() throws Exception {
    final Account accountJson = getAccount();
    accountJson.setAccountId(null);
    final String paymentExternalKey = UUID.randomUUID().toString();
    final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
    final Payment payment = paymentApi.createComboPayment(comboPaymentTransaction, NULL_PLUGIN_NAMES, requestOptions);
    verifyComboPayment(payment, paymentExternalKey, BigDecimal.TEN, BigDecimal.ZERO, BigDecimal.ZERO, 1, 1);
    // Void payment using externalKey
    final String voidTransactionExternalKey = UUID.randomUUID().toString();
    PaymentTransaction voidTransaction = new PaymentTransaction();
    voidTransaction.setTransactionExternalKey(voidTransactionExternalKey);
    voidTransaction.setPaymentExternalKey(paymentExternalKey);
    paymentApi.voidPaymentByExternalKey(voidTransaction, NULL_PLUGIN_NAMES, NULL_PLUGIN_PROPERTIES, requestOptions);
    final Payment voidPayment = paymentApi.getPayment(payment.getPaymentId(), NULL_PLUGIN_PROPERTIES, requestOptions);
    verifyPaymentTransaction(accountJson, voidPayment.getPaymentId(), paymentExternalKey, voidPayment.getTransactions().get(1), voidTransactionExternalKey, null, TransactionType.VOID, TransactionStatus.SUCCESS);
}
Also used : PaymentTransaction(org.killbill.billing.client.model.gen.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) Account(org.killbill.billing.client.model.gen.Account) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) InvoicePayment(org.killbill.billing.client.model.gen.InvoicePayment) Payment(org.killbill.billing.client.model.gen.Payment) Test(org.testng.annotations.Test)

Example 5 with ComboPaymentTransaction

use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.

the class TestPayment method createComboPaymentTransaction.

private ComboPaymentTransaction createComboPaymentTransaction(final Account accountJson, final String paymentExternalKey) {
    final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
    info.setProperties(null);
    final String paymentMethodExternalKey = UUID.randomUUID().toString();
    final PaymentMethod paymentMethodJson = new PaymentMethod();
    paymentMethodJson.setExternalKey(paymentMethodExternalKey);
    paymentMethodJson.setPluginName(PLUGIN_NAME);
    paymentMethodJson.setPluginInfo(info);
    final String authTransactionExternalKey = UUID.randomUUID().toString();
    final PaymentTransaction authTransactionJson = new PaymentTransaction();
    authTransactionJson.setAmount(BigDecimal.TEN);
    authTransactionJson.setCurrency(accountJson.getCurrency());
    authTransactionJson.setPaymentExternalKey(paymentExternalKey);
    authTransactionJson.setTransactionExternalKey(authTransactionExternalKey);
    authTransactionJson.setTransactionType(TransactionType.AUTHORIZE);
    return new ComboPaymentTransaction(accountJson, paymentMethodJson, authTransactionJson, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of(), null);
}
Also used : PaymentTransaction(org.killbill.billing.client.model.gen.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.gen.ComboPaymentTransaction) PaymentMethodPluginDetail(org.killbill.billing.client.model.gen.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.gen.PaymentMethod)

Aggregations

ComboPaymentTransaction (org.killbill.billing.client.model.gen.ComboPaymentTransaction)7 Account (org.killbill.billing.client.model.gen.Account)6 PaymentTransaction (org.killbill.billing.client.model.gen.PaymentTransaction)5 Test (org.testng.annotations.Test)5 Payment (org.killbill.billing.client.model.gen.Payment)4 PaymentMethod (org.killbill.billing.client.model.gen.PaymentMethod)4 InvoicePayment (org.killbill.billing.client.model.gen.InvoicePayment)3 PaymentMethodPluginDetail (org.killbill.billing.client.model.gen.PaymentMethodPluginDetail)3 KillBillClientException (org.killbill.billing.client.KillBillClientException)2 UUID (java.util.UUID)1