module ZipMoney::Express

Constants

ACTION_CANCEL_QUOTE
ACTION_CONFIRM_ORDER
ACTION_CONFIRM_SHIPPING_METHOD
ACTION_FINALISE_ORDER
ACTION_GET_QUOTE_DETAILS
ACTION_GET_SHIPPING_METHODS

Attributes

merchant_id[RW]
merchant_key[RW]

Public Class Methods

append_api_credentials(response) click to toggle source

Appends api credentials to the express checkout response

@param [response] response

# File lib/zipMoney/express.rb, line 34
def self.append_api_credentials(response)
        response = Hash.new if !response.is_a?(Hash)

        if response["merchant_id"]  == nil 
           response["merchant_id"]  = Configuration.merchant_id
        end

        if response["merchant_key"] == nil
           response["merchant_key"] = Configuration.merchant_key
        end
        response     
end
prepare_response(response) click to toggle source

Prepars the express checkout response

@param [response] response

# File lib/zipMoney/express.rb, line 50
def self.prepare_response(response)
        response = Util.json_parse(response)
        append_api_credentials(response)
end
process(action, request, &block) click to toggle source

Process the express checkout action

@param [action] Action @param [request] Express checkout request @param [block] Actions to be taken for respective actions

Returns the response to the zipMoney Express Api

# File lib/zipMoney/express.rb, line 19
def self.process(action, request, &block)
            raise ExpressRequestError, "Action empty" if action.nil?                    
            raise ExpressRequestError, "Request empty" if request.nil?
            request = Util.json_parse(request)
            Configuration.credentials_valid(request["merchant_id"], request["merchant_key"])
            if (block.arity > 0)
                    response = block.call(action, request)
                    raise ExpressResponseError, "No response provided" if response.nil?
                    puts send_response(response)
            end 
    end
send_response(response) click to toggle source

Prints the express checkout response

@param [response] response

# File lib/zipMoney/express.rb, line 58
def self.send_response(response)
        prepare_response(response).to_json
end