-
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This fixes #483. Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,11 +211,23 @@ private boolean updatePaymentAndTransactionInternal(final PaymentModelDao paymen | |
// Recompute new lastSuccessPaymentState. This is important to be able to allow new operations on the state machine (for e.g an AUTH_SUCCESS would now allow a CAPTURE operation) | ||
final String lastSuccessPaymentState = paymentStateMachineHelper.isSuccessState(newPaymentState) ? newPaymentState : null; | ||
|
||
// Update the processedAmount, processedCurrency if we got a paymentTransactionInfoPlugin from the plugin and if this is a non error state | ||
final BigDecimal processedAmount = (paymentTransactionInfoPlugin != null && isPendingOrFinalTransactionStatus(transactionStatus)) ? | ||
paymentTransactionInfoPlugin.getAmount() : paymentTransaction.getProcessedAmount(); | ||
final Currency processedCurrency = (paymentTransactionInfoPlugin != null && isPendingOrFinalTransactionStatus(transactionStatus)) ? | ||
paymentTransactionInfoPlugin.getCurrency() : paymentTransaction.getProcessedCurrency(); | ||
// Update processedAmount and processedCurrency | ||
final BigDecimal processedAmount; | ||
if (TransactionStatus.SUCCESS.equals(transactionStatus) || TransactionStatus.PENDING.equals(transactionStatus)) { | ||
if (paymentTransactionInfoPlugin == null || paymentTransactionInfoPlugin.getAmount() == null) { | ||
processedAmount = paymentTransaction.getProcessedAmount(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
pierre
Author
Member
|
||
} else { | ||
processedAmount = paymentTransactionInfoPlugin.getAmount(); | ||
} | ||
} else { | ||
processedAmount = BigDecimal.ZERO; | ||
} | ||
final Currency processedCurrency; | ||
if (paymentTransactionInfoPlugin == null || paymentTransactionInfoPlugin.getCurrency() == null) { | ||
processedCurrency = paymentTransaction.getProcessedCurrency(); | ||
} else { | ||
processedCurrency = paymentTransactionInfoPlugin.getCurrency(); | ||
} | ||
|
||
// Update the gatewayErrorCode, gatewayError if we got a paymentTransactionInfoPlugin | ||
final String gatewayErrorCode = paymentTransactionInfoPlugin != null ? paymentTransactionInfoPlugin.getGatewayErrorCode() : paymentTransaction.getGatewayErrorCode(); | ||
|
@@ -239,12 +251,6 @@ private TransactionStatus computeNewTransactionStatusFromPaymentTransactionInfoP | |
return (newTransactionStatus != TransactionStatus.UNKNOWN) ? newTransactionStatus : currentTransactionStatus; | ||
} | ||
|
||
private boolean isPendingOrFinalTransactionStatus(final TransactionStatus transactionStatus) { | ||
return (transactionStatus == TransactionStatus.PENDING || | ||
transactionStatus == TransactionStatus.SUCCESS || | ||
transactionStatus == TransactionStatus.PAYMENT_FAILURE); | ||
} | ||
|
||
private PaymentPluginApi getPaymentPluginApi(final PaymentModelDao item, final String pluginName) { | ||
final PaymentPluginApi pluginApi = pluginRegistry.getServiceForName(pluginName); | ||
Preconditions.checkState(pluginApi != null, "Janitor IncompletePaymentTransactionTask cannot retrieve PaymentPluginApi for plugin %s (payment id %s), skipping", pluginName, item.getId()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,8 +103,22 @@ public void createNewPaymentTransaction() throws PaymentApiException { | |
|
||
public void processPaymentInfoPlugin(final TransactionStatus transactionStatus, @Nullable final PaymentTransactionInfoPlugin paymentInfoPlugin, | ||
final String currentPaymentStateName) { | ||
final BigDecimal processedAmount = paymentInfoPlugin == null ? null : paymentInfoPlugin.getAmount(); | ||
final Currency processedCurrency = paymentInfoPlugin == null ? null : paymentInfoPlugin.getCurrency(); | ||
final BigDecimal processedAmount; | ||
if (TransactionStatus.SUCCESS.equals(transactionStatus) || TransactionStatus.PENDING.equals(transactionStatus)) { | ||
if (paymentInfoPlugin == null || paymentInfoPlugin.getAmount() == null) { | ||
processedAmount = paymentStateContext.getAmount(); | ||
} else { | ||
processedAmount = paymentInfoPlugin.getAmount(); | ||
} | ||
} else { | ||
processedAmount = BigDecimal.ZERO; | ||
} | ||
final Currency processedCurrency; | ||
if (paymentInfoPlugin == null || paymentInfoPlugin.getCurrency() == null) { | ||
This comment has been minimized.
Sorry, something went wrong.
sbrossie
Member
|
||
processedCurrency = paymentStateContext.getCurrency(); | ||
} else { | ||
processedCurrency = paymentInfoPlugin.getCurrency(); | ||
} | ||
final String gatewayErrorCode = paymentInfoPlugin == null ? null : paymentInfoPlugin.getGatewayErrorCode(); | ||
final String gatewayErrorMsg = paymentInfoPlugin == null ? null : paymentInfoPlugin.getGatewayError(); | ||
|
||
|
In that, do we have the correct info set in
paymentTransaction.getProcessedAmount()
. Is it not what we are trying to compute?