Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upVoiding requests
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.
Include a model
Add model inclusion to your source code:
require 'judopay/models/void'
1. Create the 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.
2 .Check the void result
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:
{
"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.
Press h to open a hovercard with more details.