Search in sources :

Example 11 with PaymentMethod

use of org.killbill.billing.client.model.PaymentMethod 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(null, paymentMethodExternalKey, null, true, PLUGIN_NAME, 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("AUTHORIZE");
    return new ComboPaymentTransaction(accountJson, paymentMethodJson, authTransactionJson, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of());
}
Also used : PaymentTransaction(org.killbill.billing.client.model.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) PaymentMethodPluginDetail(org.killbill.billing.client.model.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.PaymentMethod)

Example 12 with PaymentMethod

use of org.killbill.billing.client.model.PaymentMethod in project killbill by killbill.

the class TestPaymentGateway method testComboBuildFormDescriptor.

@Test(groups = "slow")
public void testComboBuildFormDescriptor() throws Exception {
    final Account account = getAccount();
    account.setAccountId(null);
    final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
    final PaymentMethod paymentMethod = new PaymentMethod(null, UUID.randomUUID().toString(), null, true, PLUGIN_NAME, info);
    final HostedPaymentPageFields hppFields = new HostedPaymentPageFields();
    final ComboHostedPaymentPage comboHostedPaymentPage = new ComboHostedPaymentPage(account, paymentMethod, ImmutableList.<PluginProperty>of(), hppFields);
    final HostedPaymentPageFormDescriptor hostedPaymentPageFormDescriptor = killBillClient.buildFormDescriptor(comboHostedPaymentPage, ImmutableMap.<String, String>of(), requestOptions);
    Assert.assertNotNull(hostedPaymentPageFormDescriptor.getKbAccountId());
}
Also used : Account(org.killbill.billing.client.model.Account) HostedPaymentPageFormDescriptor(org.killbill.billing.client.model.HostedPaymentPageFormDescriptor) HostedPaymentPageFields(org.killbill.billing.client.model.HostedPaymentPageFields) ComboHostedPaymentPage(org.killbill.billing.client.model.ComboHostedPaymentPage) PaymentMethodPluginDetail(org.killbill.billing.client.model.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.PaymentMethod) Test(org.testng.annotations.Test)

Example 13 with PaymentMethod

use of org.killbill.billing.client.model.PaymentMethod in project killbill by killbill.

the class TestPaymentMethod method testSearchPaymentMethods.

@Test(groups = "slow", description = "Can search payment methods")
public void testSearchPaymentMethods() throws Exception {
    // Search random key
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKey(UUID.randomUUID().toString()).size(), 0);
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKeyAndPlugin(UUID.randomUUID().toString(), PLUGIN_NAME).size(), 0);
    // Create a payment method
    final List<PluginProperty> pmProperties = new ArrayList<PluginProperty>();
    pmProperties.add(new PluginProperty("CC_NAME", "Bozo", false));
    pmProperties.add(new PluginProperty("CC_CITY", "SF", false));
    pmProperties.add(new PluginProperty("CC_LAST_4", "4365", false));
    pmProperties.add(new PluginProperty("CC_STATE", "CA", false));
    pmProperties.add(new PluginProperty("CC_COUNTRY", "Zimbawe", false));
    final Account accountJson = createAccountWithDefaultPaymentMethod(UUID.randomUUID().toString(), pmProperties);
    final PaymentMethod paymentMethodJson = killBillClient.getPaymentMethod(accountJson.getPaymentMethodId(), true);
    // Search random key again
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKey(UUID.randomUUID().toString()).size(), 0);
    Assert.assertEquals(killBillClient.searchPaymentMethodsByKeyAndPlugin(UUID.randomUUID().toString(), PLUGIN_NAME).size(), 0);
    // Last 4
    doSearch("4365", paymentMethodJson);
    // Name
    doSearch("Bozo", paymentMethodJson);
    // City
    doSearch("SF", paymentMethodJson);
    // State
    doSearch("CA", paymentMethodJson);
    // Country
    doSearch("Zimbawe", paymentMethodJson);
}
Also used : PluginProperty(org.killbill.billing.client.model.PluginProperty) Account(org.killbill.billing.client.model.Account) ArrayList(java.util.ArrayList) PaymentMethod(org.killbill.billing.client.model.PaymentMethod) Test(org.testng.annotations.Test)

Example 14 with PaymentMethod

use of org.killbill.billing.client.model.PaymentMethod 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);
    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("AUTHORIZE");
    final ComboPaymentTransaction comboAuthorization = new ComboPaymentTransaction(accountJson, paymentMethodJson, authTransactionJson, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of());
    final Payment payment = killBillClient.createPayment(comboAuthorization, ImmutableMap.<String, String>of(), requestOptions);
    Assert.assertEquals(payment.getTransactions().get(0).getStatus(), TransactionStatus.SUCCESS.toString());
    return payment;
}
Also used : PaymentTransaction(org.killbill.billing.client.model.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) Account(org.killbill.billing.client.model.Account) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) Payment(org.killbill.billing.client.model.Payment) PaymentMethodPluginDetail(org.killbill.billing.client.model.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.PaymentMethod)

Aggregations

PaymentMethod (org.killbill.billing.client.model.PaymentMethod)14 Account (org.killbill.billing.client.model.Account)13 PaymentMethodPluginDetail (org.killbill.billing.client.model.PaymentMethodPluginDetail)10 Test (org.testng.annotations.Test)8 UUID (java.util.UUID)5 Payment (org.killbill.billing.client.model.Payment)4 ComboPaymentTransaction (org.killbill.billing.client.model.ComboPaymentTransaction)3 InvoicePayment (org.killbill.billing.client.model.InvoicePayment)3 PaymentTransaction (org.killbill.billing.client.model.PaymentTransaction)3 InvoicePaymentTransaction (org.killbill.billing.client.model.InvoicePaymentTransaction)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 KillBillClientException (org.killbill.billing.client.KillBillClientException)1 ComboHostedPaymentPage (org.killbill.billing.client.model.ComboHostedPaymentPage)1 HostedPaymentPageFields (org.killbill.billing.client.model.HostedPaymentPageFields)1 HostedPaymentPageFormDescriptor (org.killbill.billing.client.model.HostedPaymentPageFormDescriptor)1 Invoice (org.killbill.billing.client.model.Invoice)1 InvoiceItem (org.killbill.billing.client.model.InvoiceItem)1 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)1