-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
Codecov ReportAttention: Patch coverage is
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. |
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is more aligned with https://github.com/jazzband/django-payments/blob/1222e0ab5ec51b525f5d0033833a67ae702df296/payments/models.py#L222 and https://github.com/jazzband/django-payments/blob/1222e0ab5ec51b525f5d0033833a67ae702df296/payments/paypal/__init__.py#L314
Although, the whole expected behavior of Payment.refund
is probably still not clear: jazzband/django-payments#399
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) |
There was a problem hiding this comment.
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?
f"refund {refund_id} of payment {payment.id} in different currency not supported yet: " | ||
f"{refund_currency}" | ||
) | ||
return refund_amount |
There was a problem hiding this comment.
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...
No description provided.