|
|
@ -31,6 +31,8 @@ from .billing import PaymentSource |
|
|
|
from .enums import ( |
|
|
|
PaymentGateway, |
|
|
|
PaymentStatus, |
|
|
|
RefundDisqualificationReason, |
|
|
|
RefundReason, |
|
|
|
SubscriptionType, |
|
|
|
try_enum, |
|
|
|
) |
|
|
@ -117,7 +119,7 @@ class Payment(Hashable): |
|
|
|
The URL to download the VAT invoice for this payment, if available. |
|
|
|
refund_invoices_urls: List[:class:`str`] |
|
|
|
A list of URLs to download VAT credit notices for refunds on this payment, if available. |
|
|
|
refund_disqualification_reasons: List[:class:`str`] |
|
|
|
refund_disqualification_reasons: List[:class:`RefundDisqualificationReason`] |
|
|
|
A list of reasons why the payment cannot be refunded, if any. |
|
|
|
""" |
|
|
|
|
|
|
@ -172,7 +174,9 @@ class Payment(Hashable): |
|
|
|
self.payment_gateway_payment_id: Optional[str] = data.get('payment_gateway_payment_id') |
|
|
|
self.invoice_url: Optional[str] = data.get('downloadable_invoice') |
|
|
|
self.refund_invoices_urls: List[str] = data.get('downloadable_refund_invoices', []) |
|
|
|
self.refund_disqualification_reasons: List[str] = data.get('premium_refund_disqualification_reasons', []) |
|
|
|
self.refund_disqualification_reasons: List[RefundDisqualificationReason] = [ |
|
|
|
try_enum(RefundDisqualificationReason, r) for r in data.get('premium_refund_disqualification_reasons', []) |
|
|
|
] |
|
|
|
self._flags: int = data.get('flags', 0) |
|
|
|
|
|
|
|
# The subscription object does not include the payment source ID |
|
|
@ -225,19 +229,24 @@ class Payment(Hashable): |
|
|
|
await self._state.http.void_payment(self.id) |
|
|
|
self.status = PaymentStatus.failed |
|
|
|
|
|
|
|
async def refund(self, reason: Optional[int] = None) -> None: |
|
|
|
async def refund(self, reason: RefundReason = RefundReason.other) -> None: |
|
|
|
"""|coro| |
|
|
|
|
|
|
|
Refund the payment. |
|
|
|
Refund the payment. Refunds can only be made for payments less than 5 days old. |
|
|
|
|
|
|
|
Parameters |
|
|
|
---------- |
|
|
|
reason: :class:`RefundReason` |
|
|
|
The reason for the refund. |
|
|
|
|
|
|
|
.. versionadded:: 2.1 |
|
|
|
|
|
|
|
Raises |
|
|
|
------ |
|
|
|
HTTPException |
|
|
|
Refunding the payment failed. |
|
|
|
""" |
|
|
|
# reason here is an enum (0-8), but I was unable to find the enum values |
|
|
|
# Either way, it's optional and this endpoint isn't really used anyway |
|
|
|
await self._state.http.refund_payment(self.id, reason) |
|
|
|
await self._state.http.refund_payment(self.id, int(reason)) |
|
|
|
self.status = PaymentStatus.refunded |
|
|
|
|
|
|
|
|
|
|
|