PayPal refunds: Actively fetch sale ID if not known (#2134)

Co-authored-by: Martin Gross <gross@rami.io>
This commit is contained in:
Raphael Michel
2021-06-25 11:12:52 +02:00
committed by GitHub
parent d4712266ff
commit 573284c480

View File

@@ -533,6 +533,14 @@ class Paypal(BasePaymentProvider):
sale = paypalrestsdk.Sale.find(v['id'])
break
if not sale:
pp_payment = paypalrestsdk.Payment.find(refund.payment.info_data['id'])
for res in pp_payment.transactions[0].related_resources:
for k, v in res.to_dict().items():
if k == 'sale':
sale = paypalrestsdk.Sale.find(v['id'])
break
pp_refund = sale.refund({
"amount": {
"total": self.format_price(refund.amount),