Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PayuProvider.refund #4

Merged
merged 5 commits into from
Mar 19, 2024
Merged

Conversation

radekholy24
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 85.18519% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 90.56%. Comparing base (c494c81) to head (d9b8740).

Files Patch % Lines
payments_payu/provider.py 85.18% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master       #4      +/-   ##
==========================================
- Coverage   91.66%   90.56%   -1.11%     
==========================================
  Files           2        2              
  Lines         324      371      +47     
  Branches       51       58       +7     
==========================================
+ Hits          297      336      +39     
- Misses          9       15       +6     
- Partials       18       20       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -550 to 561
if refunded_price == payment.total:
if refunded_price == payment.captured_amount:
payment.change_status(PaymentStatus.REFUNDED)
else:
payment.total -= refunded_price
payment.captured_amount -= refunded_price
payment.save()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -559 to +582
status = data["order"]["status"]
status_map = {
"COMPLETED": PaymentStatus.CONFIRMED,
"PENDING": PaymentStatus.INPUT,
"WAITING_FOR_CONFIRMATION": PaymentStatus.INPUT,
"CANCELED": PaymentStatus.REJECTED,
"NEW": PaymentStatus.WAITING,
}
if PaymentStatus.CONFIRMED and "totalAmount" in data["order"]:
status = status_map[data["order"]["status"]]
if (
status == PaymentStatus.CONFIRMED
and "totalAmount" in data["order"]
):
payment.captured_amount = dequantize_price(
data["order"]["totalAmount"],
data["order"]["currencyCode"],
)
payment.change_status(status_map[status])
payment.change_status(status)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that that if PaymentStatus.CONFIRMED was just a bug?

@radekholy24 radekholy24 marked this pull request as ready for review March 14, 2024 15:13
f"refund {refund_id} of payment {payment.id} in different currency not supported yet: "
f"{refund_currency}"
)
return refund_amount
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that we return the amount before the refund actually happens but this is how PayPal refunds work too so I decided to be consistent...

@PetrDlouhy PetrDlouhy merged commit f6096f1 into PetrDlouhy:master Mar 19, 2024
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants