solidusio / solidus_affirm

Affirm payment option for your Solidus storefront
BSD 3-Clause "New" or "Revised" License
6 stars 17 forks source link

Return charge id from capture #66

Closed AlistairNorman closed 4 years ago

AlistairNorman commented 4 years ago

I recently found that there was an issue with how I implemented auto-capturing. With the way I structured it, if you use the purchase method then you authorize and capture at the same time. The issue is that this returns only the ActiveMerchant::Billing:Response from the purchase call which does not contain the id of the affirm payment. This means that the payment that is created will not have a response code and it will not be possible to refund or cancel payments.

This fixes that issues by including the id of the affirm payment in the response from capture which is also the response from purchase in affirm_client.rb

To test: Follow the checkout flow and buy something using Affirm. Find the order in the admin, navigate to payments, and refund the affirm payment.

Let me know what you think here. In my case I found that the payments that didn't have response codes were not too hard to fix because Affirm allows you to make an api request for changes 20 at a time and the response it gives includes the Solidus order number.