use of org.killbill.billing.client.model.gen.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(paymentMethodApi.searchPaymentMethods(UUID.randomUUID().toString(), null, NULL_PLUGIN_PROPERTIES, requestOptions).size(), 0);
Assert.assertEquals(paymentMethodApi.searchPaymentMethods(UUID.randomUUID().toString(), PLUGIN_NAME, NULL_PLUGIN_PROPERTIES, requestOptions).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 = paymentMethodApi.getPaymentMethod(accountJson.getPaymentMethodId(), false, true, NULL_PLUGIN_PROPERTIES, AuditLevel.NONE, requestOptions);
// Search random key again
Assert.assertEquals(paymentMethodApi.searchPaymentMethods(UUID.randomUUID().toString(), null, NULL_PLUGIN_PROPERTIES, requestOptions).size(), 0);
Assert.assertEquals(paymentMethodApi.searchPaymentMethods(UUID.randomUUID().toString(), PLUGIN_NAME, NULL_PLUGIN_PROPERTIES, requestOptions).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.gen.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();
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);
}
use of org.killbill.billing.client.model.gen.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, null);
final HostedPaymentPageFields hppFields = new HostedPaymentPageFields();
final ComboHostedPaymentPage comboHostedPaymentPage = new ComboHostedPaymentPage(account, paymentMethod, hppFields, ImmutableList.<PluginProperty>of(), null);
final HostedPaymentPageFormDescriptor hostedPaymentPageFormDescriptor = paymentGatewayApi.buildComboFormDescriptor(comboHostedPaymentPage, NULL_PLUGIN_NAMES, NULL_PLUGIN_PROPERTIES, requestOptions);
Assert.assertNotNull(hostedPaymentPageFormDescriptor.getKbAccountId());
}
use of org.killbill.billing.client.model.gen.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, 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;
}
Aggregations