Collecting on a Pre Authorization

ofetisov edited this page Jun 13, 2017 · 8 revisions

Collecting a pre-auth requires that you have the receipt_id and amount of the pre-auth transaction. Before you make a payment please check if your SDK is initialized.

Include a model

Add model inclusion to your source code:

require 'judopay/models/collection'
Creating a new collection

To collect a pre-auth funds you need to create and fill Collection model:

    # result_preauth - successful pre-authorization response    
    collection =
        :receipt_id => result_preauth.receipt_id,
        :your_payment_reference => 'xxxxxx',
        :amount => 10.00

You can check on the required fields and the format of each field in the Judopay REST API reference.

Check the collection result

And after that you need to send the request to the API. Your code will look like that:

    result_collection = collection.create
    if result_collection.result == 'Success'
        puts 'Successfully collected'
        puts 'There were some problems while processing your collection'

If the collection is successful, you'll receive a response array like this:

  "message"=>"Collection successful",

It is also important to handle different exceptions in your code. See our Error handling section.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.