From df2dc3a8ca9200f12297ca6c4731ac2ce88366ae Mon Sep 17 00:00:00 2001 From: icellama21 Date: Mon, 23 Apr 2012 15:37:25 -0400 Subject: [PATCH] Fixing bugs where amazon transaction status REFUNDED was not being set, or was overwriten by PaymentDetails --- payment/amazon.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/payment/amazon.py b/payment/amazon.py index 41309b97..afabee35 100644 --- a/payment/amazon.py +++ b/payment/amazon.py @@ -144,7 +144,9 @@ def ProcessIPN(request): elif operation == AMAZON_OPERATION_TYPE_REFUND: if status == AMAZON_IPN_STATUS_SUCCESS: - transaction.status = TRANSACTION_STATUS_COMPLETE_PRIMARY + transaction.status = TRANSACTION_STATUS_REFUNDED + elif status == AMAZON_IPN_STATUS_PENDING: + transaction.status = TRANSACTION_STATUS_PENDING else: transaction.status = TRANSACTION_STATUS_ERROR @@ -577,10 +579,22 @@ class PaymentDetails(AmazonRequest): self.local_status = self.response.StatusCode self.message = self.response.StatusMessage + if self.local_status == 'Canceled': self.status = TRANSACTION_STATUS_CANCELED + elif self.local_status == 'Success': - self.status = TRANSACTION_STATUS_COMPLETE_PRIMARY + # + # Note, there is a limitation here. If the current status is refunded, this API will return "Success". + # We must be careful to not overwrite refunded status codes. There is no way that I can find to poll + # to see if a transaction is refunded. I need to investigate all of the data fields and see if we can find + # that information + # + if transaction.status != TRANSACTION_STATUS_REFUNDED: + self.status = TRANSACTION_STATUS_COMPLETE_PRIMARY + else: + self.status = TRANSACTION_STATUS_REFUNDED + elif self.local_status == 'PendingNetworkResponse' or self.local_status == 'PendingVerification': self.status = TRANSACTION_STATUS_PENDING elif self.local_status == 'TransactionDenied':