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());
}
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());
}
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);
}
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;
}
Aggregations