Fix Stripe refunds for PaymentIntents

This commit is contained in:
Martin Gross
2019-07-24 15:37:39 +02:00
parent 20d79152a6
commit 5a216b7be9

View File

@@ -451,7 +451,12 @@ class StripeMethod(BasePaymentProvider):
raise PaymentException(_('No payment information found.'))
try:
ch = stripe.Charge.retrieve(payment_info['id'], **self.api_kwargs)
if payment_info['id'].startswith('pi_'):
chargeid = payment_info['charges']['data'][0]['id']
else:
chargeid = payment_info['id']
ch = stripe.Charge.retrieve(chargeid, **self.api_kwargs)
r = ch.refunds.create(
amount=self._get_amount(refund),
)