Search in sources :

Example 6 with ComboPaymentTransaction

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

the class TestPayment method testComboAuthorizationAbortedPayment.

@Test(groups = "slow")
public void testComboAuthorizationAbortedPayment() throws Exception {
    final Account accountJson = getAccount();
    accountJson.setAccountId(null);
    final String paymentExternalKey = UUID.randomUUID().toString();
    final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
    mockPaymentControlProviderPlugin.setAborted(true);
    try {
        paymentApi.createComboPayment(comboPaymentTransaction, Arrays.asList(MockPaymentControlProviderPlugin.PLUGIN_NAME), requestOptions);
        fail();
    } catch (KillBillClientException e) {
        assertEquals(e.getResponse().getStatusCode(), 422);
    }
    assertFalse(mockPaymentControlProviderPlugin.isOnFailureCallExecuted());
    assertFalse(mockPaymentControlProviderPlugin.isOnSuccessCallExecuted());
}
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 7 with ComboPaymentTransaction

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

the class TestTenantKV method createComboPaymentTransaction.

private Payment createComboPaymentTransaction(final RequestOptions requestOptions) throws KillBillClientException {
    final Account accountJson = getAccount();
    accountJson.setAccountId(null);
    final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
    info.setProperties(null);
    final String paymentMethodExternalKey = UUID.randomUUID().toString();
    final PaymentMethod paymentMethodJson = new PaymentMethod(null, paymentMethodExternalKey, null, true, PLUGIN_NAME, info, null);
    final String authTransactionExternalKey = UUID.randomUUID().toString();
    final PaymentTransaction authTransactionJson = new PaymentTransaction();
    authTransactionJson.setAmount(BigDecimal.TEN);
    authTransactionJson.setCurrency(accountJson.getCurrency());
    authTransactionJson.setPaymentExternalKey(UUID.randomUUID().toString());
    authTransactionJson.setTransactionExternalKey(authTransactionExternalKey);
    authTransactionJson.setTransactionType(TransactionType.AUTHORIZE);
    callbackServlet.pushExpectedEvents(ExtBusEventType.ACCOUNT_CREATION, ExtBusEventType.ACCOUNT_CHANGE, ExtBusEventType.PAYMENT_SUCCESS);
    final ComboPaymentTransaction comboAuthorization = new ComboPaymentTransaction(accountJson, paymentMethodJson, authTransactionJson, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of(), null);
    final Payment payment = paymentApi.createComboPayment(comboAuthorization, NULL_PLUGIN_NAMES, requestOptions);
    callbackServlet.assertListenerStatus();
    assertEquals(payment.getTransactions().get(0).getStatus(), TransactionStatus.SUCCESS);
    return 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) Payment(org.killbill.billing.client.model.gen.Payment) 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