Skip to content

StripeProviderV3.refund() returns cents instead of currency units #470

@YounesOMK

Description

@YounesOMK

Steps to reproduce

  1. Create a payment with total=30.00 using StripeProviderV3
  2. Complete the Stripe Checkout session (payment status becomes confirmed)
  3. Call payment.refund()

The refund succeeds on Stripe's side, but captured_amount ends up as -3000 instead of 0.

Cause

convert_amount converts a payment amount to the smallest currency unit for the Stripe API (e.g. 30.00 becomes 3000). This is used correctly when calling stripe.Refund.create().

The problem is that refund() returns that same converted value:

def refund(self, payment, amount=None) -> int:
    to_refund = amount or payment.total
    # ...
    stripe.Refund.create(
        amount=self.convert_amount(payment.currency, to_refund),  # 3000 correct for Stripe
    )
    # ...
    return self.convert_amount(payment.currency, to_refund)  # 3000 returned to BasePayment

But BasePayment.refund() treats the returned value as currency units:

amount = provider.refund(self, amount)
self.captured_amount -= amount  # subtracts 3000 instead of 30.00

i think refund() here should return to_refund directly, not the Stripe-converted value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions