Search in sources :

Example 1 with PaymentMethod

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

the class KillbillClient method createAccountWithExternalPaymentMethod.

protected Account createAccountWithExternalPaymentMethod() throws Exception {
    final Account input = createAccount();
    final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
    final PaymentMethod paymentMethodJson = new PaymentMethod(null, UUIDs.randomUUID().toString(), input.getAccountId(), true, ExternalPaymentProviderPlugin.PLUGIN_NAME, info);
    killBillClient.createPaymentMethod(paymentMethodJson, requestOptions);
    return killBillClient.getAccount(input.getExternalKey(), requestOptions);
}
Also used : Account(org.killbill.billing.client.model.Account) PaymentMethodPluginDetail(org.killbill.billing.client.model.PaymentMethodPluginDetail) PaymentMethod(org.killbill.billing.client.model.PaymentMethod)

Example 2 with PaymentMethod

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

the class TestPaymentMethod method testGePaymentMethodsByKey.

@Test(groups = "slow", description = "Create/retrieve by externalKey")
public void testGePaymentMethodsByKey() throws Exception {
    final Account accountJson = createAccountWithDefaultPaymentMethod("foo");
    final PaymentMethod paymentMethodJson1 = killBillClient.getPaymentMethodByKey("foo", true);
    final PaymentMethod paymentMethodJson2 = killBillClient.getPaymentMethod(accountJson.getPaymentMethodId(), true);
    Assert.assertEquals(paymentMethodJson1, paymentMethodJson2);
    final PaymentMethod paymentMethodJson3 = killBillClient.getPaymentMethodByKey("doesnotexist", true);
    Assert.assertNull(paymentMethodJson3);
}
Also used : Account(org.killbill.billing.client.model.Account) PaymentMethod(org.killbill.billing.client.model.PaymentMethod) Test(org.testng.annotations.Test)

Example 3 with PaymentMethod

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

the class TestInvoicePayment method setupScenarioWithPayment.

private InvoicePayment setupScenarioWithPayment() throws Exception {
    final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
    final List<InvoicePayment> paymentsForAccount = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId());
    Assert.assertEquals(paymentsForAccount.size(), 1);
    final InvoicePayment paymentJson = paymentsForAccount.get(0);
    // Check the PaymentMethod from paymentMethodId returned in the Payment object
    final UUID paymentMethodId = paymentJson.getPaymentMethodId();
    final PaymentMethod paymentMethodJson = killBillClient.getPaymentMethod(paymentMethodId, true);
    Assert.assertEquals(paymentMethodJson.getPaymentMethodId(), paymentMethodId);
    Assert.assertEquals(paymentMethodJson.getAccountId(), accountJson.getAccountId());
    // Verify the refunds
    final List<PaymentTransaction> objRefundFromJson = getPaymentTransactions(paymentsForAccount, TransactionType.REFUND.toString());
    Assert.assertEquals(objRefundFromJson.size(), 0);
    return paymentJson;
}
Also used : PaymentTransaction(org.killbill.billing.client.model.PaymentTransaction) InvoicePaymentTransaction(org.killbill.billing.client.model.InvoicePaymentTransaction) Account(org.killbill.billing.client.model.Account) InvoicePayment(org.killbill.billing.client.model.InvoicePayment) PaymentMethod(org.killbill.billing.client.model.PaymentMethod) UUID(java.util.UUID)

Example 4 with PaymentMethod

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

the class TestPayment method testCreateRetrievePayment.

@Test(groups = "slow")
public void testCreateRetrievePayment() throws Exception {
    final Account account = createAccountWithDefaultPaymentMethod();
    final String externalPaymentKey = UUID.randomUUID().toString();
    final UUID paymentId = testCreateRetrievePayment(account, null, externalPaymentKey, 1);
    final Payment payment = killBillClient.getPaymentByExternalKey(externalPaymentKey);
    assertEquals(payment.getPaymentId(), paymentId);
    final PaymentMethod paymentMethodJson = new PaymentMethod(null, UUID.randomUUID().toString(), account.getAccountId(), false, PLUGIN_NAME, new PaymentMethodPluginDetail());
    final PaymentMethod nonDefaultPaymentMethod = killBillClient.createPaymentMethod(paymentMethodJson, createdBy, reason, comment);
    testCreateRetrievePayment(account, nonDefaultPaymentMethod.getPaymentMethodId(), UUID.randomUUID().toString(), 2);
}
Also used : Account(org.killbill.billing.client.model.Account) Payment(org.killbill.billing.client.model.Payment) PaymentMethod(org.killbill.billing.client.model.PaymentMethod) PaymentMethodPluginDetail(org.killbill.billing.client.model.PaymentMethodPluginDetail) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Example 5 with PaymentMethod

use of org.killbill.billing.client.model.PaymentMethod 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(paymentMethodId, null, null, true, PLUGIN_NAME, info);
    final ComboPaymentTransaction comboPaymentTransaction = new ComboPaymentTransaction(accountJson, paymentMethodJson, null, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of());
    final Payment payment = killBillClient.createPayment(comboPaymentTransaction, ImmutableMap.<String, String>of(), requestOptions);
    // Client returns null in case of a 404
    Assert.assertNull(payment);
}
Also used : 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) UUID(java.util.UUID) Test(org.testng.annotations.Test)

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