Ruby

Author: Semaka 45 views
				
					require "uri"
require "net/http"

url = URI("https://gateway.switch.tj/api/v1/payment-key")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Basic V2hvb3NoRGVtb0FQSTpmZGZsa2RmZXVlbzM4Mzk4"
request["Content-Type"] = "application/x-www-form-urlencoded"
request["Cookie"] = "PHPSESSID=abk57kqs42fjpdfvv8a78ckfd7"
request.body = "merchant_reference=12312312312&amount=5.00&error_url=https%3A%2F%2Furl-to-your-success-page.co.za&success_url=https%3A%2F%2Furl-to-your-success-page.co.za&cancel_url=https%3A%2F%2Furl-to-your-success-page.co.za&notify_url=https%3A%2F%2Furl-to-your-success-page.co.za&payment_type=credit_card"

response = https.request(request)
puts response.read_body