adamthedeveloper / wepay-rails

Collect payments from wepay in your rails application.
MIT License
32 stars 24 forks source link

Ft preapprovals #26

Closed lvxn0va closed 11 years ago

lvxn0va commented 11 years ago

Hi I've gotten Wepay pre-approvals and delayed charge working on my end. I've also included sample code for the controllers which can be stripped if needed and put in the wiki to help people test. My understanding is the controllers aren't generated with the gem installation so are optional for people to copy if they want from the Github source.

Most of the code matches the master branch checkout methods except for the redirects to the "Success" actions which renders text confirmation. I've also adjusted code to the wepay-rails.rb and WepayCheckoutRecord.

The most difficult part of pre-approvals and delayed charging is that when adding a pre-approval to a checkout/create call, it's not necessary to send the user to Wepay, and the charge is made immediately. I redirected to the success action on the charge_controller to merge new checkout_id into the full record from the preapproval call.

Anyway, I'm a beginner at rails so none of the code is precious to me! If you see how to do something better please feel free to change it accordingly..Thanks mate

adamthedeveloper commented 11 years ago

I'll take a look at all of this and get back to you. Thanks for your contribution! Once it's merged, please create a wiki addition to showcase how to use your pre-approval feature.

lvxn0va commented 11 years ago

Yes I will..sorry about all the strange commits, really had to tweak the redirects to get the checkout record to update satisfactorily.

adamthedeveloper commented 11 years ago

How is your change working out for you? Are you using it in production ok?

lvxn0va commented 11 years ago

Thx it works great. No production yet, still in stage, but all the preapp and charge code work good for the catarse application so far. I will try to tackle some tests for the Wepay rails code when I come up for air on the other project.

As a side note, the master branch in my fork is edging toward the catarse customizations and crowdfunding..I've had to make changes that suited my application.

Even though the master branch is more current, the code in the ft-preapprovals branch is more aligned with the Wepay-rails gem and better suited for the users in case you decide to push it.