mirror of
https://github.com/pretix/pretix.git
synced 2026-05-21 17:54:08 +00:00
Add refund details to API
This commit is contained in:
@@ -126,6 +126,8 @@ The provider class
|
|||||||
|
|
||||||
.. automethod:: api_payment_details
|
.. automethod:: api_payment_details
|
||||||
|
|
||||||
|
.. automethod:: api_refund_details
|
||||||
|
|
||||||
.. automethod:: matching_id
|
.. automethod:: matching_id
|
||||||
|
|
||||||
.. automethod:: shred_payment_info
|
.. automethod:: shred_payment_info
|
||||||
|
|||||||
@@ -553,12 +553,22 @@ class OrderPaymentSerializer(I18nAwareModelSerializer):
|
|||||||
'details')
|
'details')
|
||||||
|
|
||||||
|
|
||||||
|
class RefundDetailsField(serializers.Field):
|
||||||
|
def to_representation(self, value: OrderRefund):
|
||||||
|
pp = value.payment_provider
|
||||||
|
if not pp:
|
||||||
|
return {}
|
||||||
|
return pp.api_refund_details(value)
|
||||||
|
|
||||||
|
|
||||||
class OrderRefundSerializer(I18nAwareModelSerializer):
|
class OrderRefundSerializer(I18nAwareModelSerializer):
|
||||||
payment = SlugRelatedField(slug_field='local_id', read_only=True)
|
payment = SlugRelatedField(slug_field='local_id', read_only=True)
|
||||||
|
details = RefundDetailsField(source='*', allow_null=True, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = OrderRefund
|
model = OrderRefund
|
||||||
fields = ('local_id', 'state', 'source', 'amount', 'payment', 'created', 'execution_date', 'comment', 'provider')
|
fields = ('local_id', 'state', 'source', 'amount', 'payment', 'created', 'execution_date', 'comment', 'provider',
|
||||||
|
'details')
|
||||||
|
|
||||||
|
|
||||||
class OrderURLField(serializers.URLField):
|
class OrderURLField(serializers.URLField):
|
||||||
|
|||||||
@@ -877,6 +877,15 @@ class BasePaymentProvider:
|
|||||||
"""
|
"""
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def api_refund_details(self, refund: OrderRefund):
|
||||||
|
"""
|
||||||
|
Will be called to populate the ``details`` parameter of the refund in the REST API.
|
||||||
|
|
||||||
|
:param refund: The refund in question.
|
||||||
|
:return: A serializable dictionary
|
||||||
|
"""
|
||||||
|
return {}
|
||||||
|
|
||||||
def matching_id(self, payment: OrderPayment):
|
def matching_id(self, payment: OrderPayment):
|
||||||
"""
|
"""
|
||||||
Will be called to get an ID for matching this payment when comparing pretix records with records of an external
|
Will be called to get an ID for matching this payment when comparing pretix records with records of an external
|
||||||
@@ -959,6 +968,9 @@ class BoxOfficeProvider(BasePaymentProvider):
|
|||||||
"payment_data": payment.info_data.get('payment_data', {}),
|
"payment_data": payment.info_data.get('payment_data', {}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def api_refund_details(self, refund: OrderRefund):
|
||||||
|
return self.api_payment_details(refund)
|
||||||
|
|
||||||
def payment_control_render(self, request, payment) -> str:
|
def payment_control_render(self, request, payment) -> str:
|
||||||
if not payment.info:
|
if not payment.info:
|
||||||
return
|
return
|
||||||
@@ -1191,6 +1203,9 @@ class GiftCardPayment(BasePaymentProvider):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def api_refund_details(self, refund: OrderRefund):
|
||||||
|
return self.api_payment_details(refund)
|
||||||
|
|
||||||
def payment_partial_refund_supported(self, payment: OrderPayment) -> bool:
|
def payment_partial_refund_supported(self, payment: OrderPayment) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user