killbill-aplcache
Changes
payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java 9(+7 -2)
payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentRoutingPluginApi.java 10(+5 -5)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentRoutingProviderPlugin.java 13(+7 -6)
payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentRoutingProviderPlugin.java 13(+7 -6)
payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentRoutingResult.java 22(+18 -4)
payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentRoutingProviderPlugin.java 13(+7 -6)
pom.xml 2(+1 -1)
Details
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java
index 28af33a..49b1c11 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/PaymentStateContext.java
@@ -1,8 +1,8 @@
/*
- * Copyright 2014 Groupon, Inc
- * Copyright 2014 The Billing Project, LLC
+ * Copyright 2014-2015 Groupon, Inc
+ * Copyright 2014-2015 The Billing Project, LLC
*
- * Groupon licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -49,6 +49,7 @@ public class PaymentStateContext {
protected String paymentExternalKey;
protected String paymentTransactionExternalKey;
protected Currency currency;
+ protected Iterable<PluginProperty> properties;
// Can be updated later via paymentTransactionModelDao (e.g. for auth or purchase)
protected final UUID paymentId;
@@ -56,7 +57,6 @@ public class PaymentStateContext {
protected final Account account;
protected final TransactionType transactionType;
protected final boolean shouldLockAccountAndDispatch;
- protected final Iterable<PluginProperty> properties;
protected final InternalCallContext internalCallContext;
protected final CallContext callContext;
protected final boolean isApiPayment;
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java
index 7461aca..7fa7ff3 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryablePaymentStateContext.java
@@ -1,7 +1,8 @@
/*
- * Copyright 2014 Groupon, Inc
+ * Copyright 2014-2015 Groupon, Inc
+ * Copyright 2014-2015 The Billing Project, LLC
*
- * Groupon licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -78,6 +79,10 @@ public class RetryablePaymentStateContext extends PaymentStateContext {
this.currency = currency;
}
+ public void setProperties(final Iterable<PluginProperty> properties) {
+ this.properties = properties;
+ }
+
public PaymentTransaction getCurrentTransaction() {
if (result == null || result.getTransactions() == null) {
return null;
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
index a2d01b9..c9fb5b1 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/sm/RetryOperationCallback.java
@@ -203,6 +203,9 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
if (pluginResult.getAdjustedPaymentMethodId() != null) {
input.setPaymentMethodId(pluginResult.getAdjustedPaymentMethodId());
}
+ if (pluginResult.getAdjustedPluginProperties() != null) {
+ input.setProperties(pluginResult.getAdjustedPluginProperties());
+ }
}
private OperationResult getOperationResultOnException(final PaymentStateContext paymentStateContext) {
@@ -237,7 +240,7 @@ public abstract class RetryOperationCallback extends OperationCallbackBase<Payme
paymentStateContext.getTransactionType(),
prevResult.getAdjustedAmount() != null ? prevResult.getAdjustedAmount() : inputPaymentRoutingContext.getAmount(),
prevResult.getAdjustedCurrency() != null ? prevResult.getAdjustedCurrency() : inputPaymentRoutingContext.getCurrency(),
- paymentStateContext.getProperties(),
+ prevResult.getAdjustedPluginProperties() != null ? prevResult.getAdjustedPluginProperties() : inputPaymentRoutingContext.getPluginProperties(),
retryablePaymentStateContext.isApiPayment(),
paymentStateContext.callContext);
diff --git a/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentRoutingPluginApi.java b/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentRoutingPluginApi.java
index e6a4ad4..e1b5ddf 100644
--- a/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentRoutingPluginApi.java
+++ b/payment/src/main/java/org/killbill/billing/payment/invoice/InvoicePaymentRoutingPluginApi.java
@@ -126,7 +126,7 @@ public final class InvoicePaymentRoutingPluginApi implements PaymentRoutingPlugi
case REFUND:
return getPluginRefundResult(paymentRoutingContext, internalContext);
case CHARGEBACK:
- return new DefaultPriorPaymentRoutingResult(false, paymentRoutingContext.getAmount(), null, null);
+ return new DefaultPriorPaymentRoutingResult(false, paymentRoutingContext.getAmount());
default:
throw new IllegalStateException("Unexpected transactionType " + transactionType);
}
@@ -244,7 +244,7 @@ public final class InvoicePaymentRoutingPluginApi implements PaymentRoutingPlugi
" aborted : invoice balance is = " + invoice.getBalance() +
", requested payment amount is = " + paymentRoutingPluginContext.getAmount());
} else {
- return new DefaultPriorPaymentRoutingResult(isAborted, requestedAmount, null, null);
+ return new DefaultPriorPaymentRoutingResult(isAborted, requestedAmount);
}
} catch (final InvoiceApiException e) {
throw new PaymentRoutingApiException(e);
@@ -277,7 +277,7 @@ public final class InvoicePaymentRoutingPluginApi implements PaymentRoutingPlugi
" aborted : invoice item sum amount is " + amountToBeRefunded +
", requested refund amount is = " + paymentRoutingPluginContext.getAmount());
} else {
- return new DefaultPriorPaymentRoutingResult(isAborted, amountToBeRefunded, null, null);
+ return new DefaultPriorPaymentRoutingResult(isAborted, amountToBeRefunded);
}
}
@@ -450,8 +450,8 @@ public final class InvoicePaymentRoutingPluginApi implements PaymentRoutingPlugi
inputAmount != null &&
invoice.getBalance().compareTo(inputAmount) < 0) {
log.info("Invoice " + invoice.getId() +
- " has a balance of " + invoice.getBalance().floatValue() +
- " less than retry payment amount of " + inputAmount.floatValue());
+ " has a balance of " + invoice.getBalance().floatValue() +
+ " less than retry payment amount of " + inputAmount.floatValue());
return BigDecimal.ZERO;
}
if (inputAmount == null) {
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentRoutingProviderPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentRoutingProviderPlugin.java
index 9b89e1d..3b11dec 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentRoutingProviderPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultNoOpPaymentRoutingProviderPlugin.java
@@ -1,7 +1,8 @@
/*
- * Copyright 2014 Groupon, Inc
+ * Copyright 2014-2015 Groupon, Inc
+ * Copyright 2014-2015 The Billing Project, LLC
*
- * Groupon licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -34,17 +35,17 @@ public class DefaultNoOpPaymentRoutingProviderPlugin implements PaymentRoutingPl
private DateTime nextRetryDate;
@Override
- public PriorPaymentRoutingResult priorCall(final PaymentRoutingContext retryPluginContext, Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
- return new DefaultPriorPaymentRoutingResult(isRetryAborted, null, null, null);
+ public PriorPaymentRoutingResult priorCall(final PaymentRoutingContext retryPluginContext, final Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
+ return new DefaultPriorPaymentRoutingResult(isRetryAborted);
}
@Override
- public OnSuccessPaymentRoutingResult onSuccessCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
+ public OnSuccessPaymentRoutingResult onSuccessCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
return null;
}
@Override
- public OnFailurePaymentRoutingResult onFailureCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
+ public OnFailurePaymentRoutingResult onFailureCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
return new DefaultFailureCallResult(nextRetryDate);
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentRoutingProviderPlugin.java b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentRoutingProviderPlugin.java
index 6830fd9..5f6e510 100644
--- a/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentRoutingProviderPlugin.java
+++ b/payment/src/main/java/org/killbill/billing/payment/provider/DefaultPaymentRoutingProviderPlugin.java
@@ -1,7 +1,8 @@
/*
- * Copyright 2014 Groupon, Inc
+ * Copyright 2014-2015 Groupon, Inc
+ * Copyright 2014-2015 The Billing Project, LLC
*
- * Groupon licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -31,17 +32,17 @@ public class DefaultPaymentRoutingProviderPlugin implements PaymentRoutingPlugin
public static final String PLUGIN_NAME = "__DEFAULT_PAYMENT_CONTROL__";
@Override
- public PriorPaymentRoutingResult priorCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
- return new DefaultPriorPaymentRoutingResult(false, null, null, null);
+ public PriorPaymentRoutingResult priorCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
+ return new DefaultPriorPaymentRoutingResult(false);
}
@Override
- public OnSuccessPaymentRoutingResult onSuccessCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) {
+ public OnSuccessPaymentRoutingResult onSuccessCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) {
return null;
}
@Override
- public OnFailurePaymentRoutingResult onFailureCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) {
+ public OnFailurePaymentRoutingResult onFailureCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) {
return new DefaultFailureCallResult(null);
}
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentRoutingResult.java b/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentRoutingResult.java
index f0b8f61..7e48e2c 100644
--- a/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentRoutingResult.java
+++ b/payment/src/main/java/org/killbill/billing/payment/retry/DefaultPriorPaymentRoutingResult.java
@@ -1,7 +1,8 @@
/*
- * Copyright 2014 Groupon, Inc
+ * Copyright 2014-2015 Groupon, Inc
+ * Copyright 2014-2015 The Billing Project, LLC
*
- * Groupon licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -20,6 +21,7 @@ import java.math.BigDecimal;
import java.util.UUID;
import org.killbill.billing.catalog.api.Currency;
+import org.killbill.billing.payment.api.PluginProperty;
import org.killbill.billing.routing.plugin.api.PriorPaymentRoutingResult;
public class DefaultPriorPaymentRoutingResult implements PriorPaymentRoutingResult {
@@ -28,19 +30,26 @@ public class DefaultPriorPaymentRoutingResult implements PriorPaymentRoutingResu
private final BigDecimal adjustedRetryAmount;
private final Currency adjustedCurrency;
private final UUID adjustedPaymentMethodId;
+ private final Iterable<PluginProperty> adjustedPluginProperties;
public DefaultPriorPaymentRoutingResult(final boolean isAborted,
final BigDecimal adjustedRetryAmount,
final Currency adjustedCurrency,
- final UUID adjustedPaymentMethodId) {
+ final UUID adjustedPaymentMethodId,
+ final Iterable<PluginProperty> adjustedPluginProperties) {
this.isAborted = isAborted;
this.adjustedRetryAmount = adjustedRetryAmount;
this.adjustedCurrency = adjustedCurrency;
this.adjustedPaymentMethodId = adjustedPaymentMethodId;
+ this.adjustedPluginProperties = adjustedPluginProperties;
+ }
+
+ public DefaultPriorPaymentRoutingResult(final boolean isAborted, final BigDecimal adjustedRetryAmount) {
+ this(isAborted, adjustedRetryAmount, null, null, null);
}
public DefaultPriorPaymentRoutingResult(final boolean isAborted) {
- this(isAborted, null, null, null);
+ this(isAborted, null);
}
@Override
@@ -62,4 +71,9 @@ public class DefaultPriorPaymentRoutingResult implements PriorPaymentRoutingResu
public UUID getAdjustedPaymentMethodId() {
return adjustedPaymentMethodId;
}
+
+ @Override
+ public Iterable<PluginProperty> getAdjustedPluginProperties() {
+ return adjustedPluginProperties;
+ }
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentRoutingProviderPlugin.java b/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentRoutingProviderPlugin.java
index 5c72c72..7e9ff9b 100644
--- a/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentRoutingProviderPlugin.java
+++ b/payment/src/test/java/org/killbill/billing/payment/provider/MockPaymentRoutingProviderPlugin.java
@@ -1,7 +1,8 @@
/*
- * Copyright 2014 Groupon, Inc
+ * Copyright 2014-2015 Groupon, Inc
+ * Copyright 2014-2015 The Billing Project, LLC
*
- * Groupon licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -45,17 +46,17 @@ public class MockPaymentRoutingProviderPlugin implements PaymentRoutingPluginApi
}
@Override
- public PriorPaymentRoutingResult priorCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
- return new DefaultPriorPaymentRoutingResult(isAborted, null, null, null);
+ public PriorPaymentRoutingResult priorCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
+ return new DefaultPriorPaymentRoutingResult(isAborted);
}
@Override
- public OnSuccessPaymentRoutingResult onSuccessCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
+ public OnSuccessPaymentRoutingResult onSuccessCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
return null;
}
@Override
- public OnFailurePaymentRoutingResult onFailureCall(final PaymentRoutingContext paymentControlContext, Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
+ public OnFailurePaymentRoutingResult onFailureCall(final PaymentRoutingContext paymentControlContext, final Iterable<PluginProperty> properties) throws PaymentRoutingApiException {
return new DefaultFailureCallResult(nextRetryDate);
}
}
pom.xml 2(+1 -1)
diff --git a/pom.xml b/pom.xml
index 67c26f2..767de1a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>killbill-oss-parent</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.12</version>
+ <version>0.13-SNAPSHOT</version>
</parent>
<artifactId>killbill</artifactId>
<version>0.15.0-SNAPSHOT</version>