Skip to content

ValidateResponse_Purchase

Jacob McConnell edited this page Jun 10, 2014 · 2 revisions

2Checkout returns both the buyer and a set of sale parameters including any custom parameters to the approved URL when the sale has been completed. The purchase method in the ValidateResponse class provides a binding to validate the MD5 hash.

##Method

###purchase

Use to validate the MD5 hash.

####Arguments

  • hash Parameters
  • Hash of sale params pass by POST to your approved URL. Secret Word needs to be added to hash using secret key.

####Returns

Returns result of validating an approved URL passback.

####Example Usage:

require "sinatra"

post '/' do
 @@response = Twocheckout::ValidateResponse.purchase({:sid => 1817037, :secret => "tango", :order_number => params[:order_number], :total => params[:total], :key => params[:key]})
 @@response.inspect
end

####Example Response:

{
    :code => "PASS",
    :message => "Hash Matched"
}
Clone this wiki locally