balanced / balanced-ruby

Balanced API library in ruby.
MIT License
111 stars 47 forks source link

No way to issue refund without knowing optional debit URI #146

Closed aimee-ault closed 10 years ago

aimee-ault commented 10 years ago

The API documentation indicates that the debit URI is an optional value (https://docs.balancedpayments.com/current/api#issue-a-refund), however the only way using this library to initiate a refund is using a Debit object fetched by debit URI. There should be a method on the Customer object that also allows you to initiate a refund.

mjallday commented 10 years ago

@aimee-ault Balanced does not know what to refund if you don't provide the debit.

The reason the debit uri is optional is because it can be implicit in the URL e.g. /debits/WD12312312/refunds already has the debit in the prefix of the string so it doesn't need to be explicitly passed.

Using the ruby client you can do this one of two ways:

  1. Balanced::Debit.find('/debits/WD123123').refund(amount)
  2. Balanced::Refund.new(:debit_uri => '/debits/WD123123').save

The second one requires you to know the debit but you do not need to fetch it first.

aimee-ault commented 10 years ago

Ah, that's fair. Thanks for answering!