Mx Merchant API Calls

def make_payment_with_form_data merchant_id = '282063484' encoded_string = Base64.encode64("CorkCRM.sandbox:!36Ud3xF+Wb&KkLx") url = URI.parse("https://sandbox.api.mxmerchant.com/checkout/v3/payment?echo=true") req = Net::HTTP::Post.new(url) req.set_form_data("merchantId" => merchant_id,"tenderType" => 'Card',"amount" => "10.00", "cardAccount" => { "number" => "<number>", "expiryMonth"=>"<month>", "expiryYear"=>"<year>","cvv"=>"<cvv>", 'avsZip' => "30004", 'avsStreet' => "2001 Westside",}) # req.body = data req['Authorization'] = "Basic "+ encoded_string req['Content-Type'] = "application/json" req['Content-Length'] = 0 req_options = { use_ssl: url.scheme == "https", } res = Net::HTTP.start(url.host, url.port,req_options) {|http| http.request(req) } puts res.body end def make_payment_with_body merchant_id = '282063484' encoded_string = Base64.encode64("CorkCRM.sandbox:!36Ud3xF+Wb&KkLx") url = URI.parse("https://sandbox.api.mxmerchant.com/checkout/v3/payment?echo=true") req = Net::HTTP::Post.new(url) req.body = {"merchantId" => merchant_id,"tenderType" => 'Card',"amount" => "10.00", "cardAccount" => { "number" => "<number>", "expiryMonth"=>"<month>", "expiryYear"=>"<year>","cvv"=>"<cvv>", 'avsZip' => "30004", 'avsStreet' => "2001 Westside"}}.to_json # req.body = data req['Authorization'] = "Basic "+ encoded_string req['Content-Type'] = "application/json" req['Content-Length'] = 0 req_options = { use_ssl: url.scheme == "https", } res = Net::HTTP.start(url.host, url.port,req_options) {|http| http.request(req) } puts res.body end

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.