Search in sources :

Example 26 with PaymentTransaction

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

the class TestPayment method testAuthorizeCompletionUsingPaymentId.

@Test(groups = "slow")
public void testAuthorizeCompletionUsingPaymentId() throws Exception {
    final Account account = createAccountWithDefaultPaymentMethod();
    final UUID paymentMethodId = account.getPaymentMethodId();
    final BigDecimal amount = BigDecimal.TEN;
    final String pending = PaymentPluginStatus.PENDING.toString();
    final ImmutableMap<String, String> pendingPluginProperties = ImmutableMap.<String, String>of(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, pending);
    final ImmutableMap<String, String> pluginProperties = ImmutableMap.of();
    TransactionType transactionType = TransactionType.AUTHORIZE;
    final String paymentExternalKey = UUID.randomUUID().toString();
    final String authTransactionExternalKey = UUID.randomUUID().toString();
    final Payment initialPayment = createVerifyTransaction(account, paymentMethodId, paymentExternalKey, authTransactionExternalKey, transactionType, pending, amount, BigDecimal.ZERO, pendingPluginProperties, 1);
    // Complete operation: first, only specify the payment id
    final PaymentTransaction completeTransactionByPaymentId = new PaymentTransaction();
    completeTransactionByPaymentId.setPaymentId(initialPayment.getPaymentId());
    final Payment completedPaymentByPaymentId = killBillClient.completePayment(completeTransactionByPaymentId, pluginProperties, requestOptions);
    verifyPayment(account, paymentMethodId, completedPaymentByPaymentId, paymentExternalKey, authTransactionExternalKey, transactionType.toString(), TransactionStatus.SUCCESS.name(), amount, amount, BigDecimal.ZERO, BigDecimal.ZERO, 1, 1);
}
Also used : PaymentTransaction(org.killbill.billing.client.model.PaymentTransaction) ComboPaymentTransaction(org.killbill.billing.client.model.ComboPaymentTransaction) Account(org.killbill.billing.client.model.Account) TransactionType(org.killbill.billing.payment.api.TransactionType) Payment(org.killbill.billing.client.model.Payment) UUID(java.util.UUID) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Aggregations

PaymentTransaction (org.killbill.billing.client.model.PaymentTransaction)26 Payment (org.killbill.billing.client.model.Payment)19 Account (org.killbill.billing.client.model.Account)16 ComboPaymentTransaction (org.killbill.billing.client.model.ComboPaymentTransaction)16 Test (org.testng.annotations.Test)15 BigDecimal (java.math.BigDecimal)11 UUID (java.util.UUID)10 TransactionType (org.killbill.billing.payment.api.TransactionType)8 KillBillClientException (org.killbill.billing.client.KillBillClientException)6 InvoicePayment (org.killbill.billing.client.model.InvoicePayment)6 InvoicePaymentTransaction (org.killbill.billing.client.model.InvoicePaymentTransaction)6 PaymentMethod (org.killbill.billing.client.model.PaymentMethod)3 RequestOptions (org.killbill.billing.client.RequestOptions)2 PaymentMethodPluginDetail (org.killbill.billing.client.model.PaymentMethodPluginDetail)2 AccountTimeline (org.killbill.billing.client.model.AccountTimeline)1 AuditLog (org.killbill.billing.client.model.AuditLog)1 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)1 Payments (org.killbill.billing.client.model.Payments)1 AuditLevel (org.killbill.billing.util.api.AuditLevel)1