Skip to content
Oleg Fetisov edited this page Sep 27, 2016 · 3 revisions

Voiding 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.

Creating a void

At first you need to create and fill Void model:

  # result_preauth - successful pre-authorization response
  void = Judopay::Void.new(
    :receipt_id => result_preauth.receipt_id,
    :amount => 5.01
  )

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

Check the void result

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

    result_void = void.create    
    if result_void.result == 'Success'
        puts 'Void successful'
    else
        puts 'There were some problems while processing your void'
    end

If the void is successful, you'll receive a response Mash like this:

{
  "receipt_id"=>"xxxxxxxxx",
  "original_receipt_id"=>"xxxxxxxxx",
  "type"=>"VOID",
  "created_at"=>"2016-09-27T09:48:35.4447+01:00",
  "result"=>"Success",
  "message"=>"Void successful",
  "judo_id"=>'xxxxxxxxx',
  "merchant_name"=>"xxxxxxxxx",
  "appears_on_statement_as"=>"xxxxxxxxx",
  "original_amount"=>"5.01",
  "amount_collected"=>"0.00",
  "net_amount"=>"5.01",
  "amount"=>"5.01",
  "currency"=>"GBP",
  "card_details"=>{
    "card_lastfour"=>"3436",
    "end_date"=>"1220",
    "card_token"=>"xxxxxxxxx",
    "card_type"=>1
  },
  "consumer"=>{
    "consumer_token"=>"xxxxxxxxx",
    "your_consumer_reference"=>"xxxxxxxxx"
  }
}

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

Clone this wiki locally