How to make a return to Stripe?

I am trying to make a return to Stripe

require "stripe"

Stripe.api_key = "sk_test_xxxxxxxxxxxxxxxx"
refund = Stripe::Refund.create(
  :charge => "ch_16fdjakjlfcCAuPNIGx6R4o"
)
  end

But I get this error

undefined create method for Stripe :: Refund: Class

I have gem 'stripe'in my gemfile

+4
source share
1 answer

It is worth checking the version of the strip vent you are using. Earlier versions returned the fee directly from the payment object, rather than creating an explicit refund. For example.

charge = Stripe::Charge.retrieve("ch_123")
charge.refund

It looks like this approach will still work with the last lowercase gem, although the documentation points to the approach Stripe::Refundyou tried, so I guess this is the best way with the last gem.

+4
source

Source: https://habr.com/ru/post/1607771/


All Articles