Skip to content

Instantly share code, notes, and snippets.

@lcx
Last active October 4, 2017 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lcx/ab3de9d769fce1118a3bde116565875d to your computer and use it in GitHub Desktop.
Save lcx/ab3de9d769fce1118a3bde116565875d to your computer and use it in GitHub Desktop.
# encoding: UTF-8
class Shop
SHOP_CONFIG = YAML.load_file("#{Rails.root}/config/holvi_config.yml")[Rails.env]
def self.get_shop_url
holvi_request = {}
holvi_request["pool"] = SHOP_CONFIG["pool"]
holvi_request["purchases"] = [{"product"=>holvi_product_id}]
holvi_request["firstname"] = firstname
holvi_request["lastname"] = lastname
holvi_request["email"] = email
holvi_request["cancel_url"] = SHOP_CONFIG["cancel_url"]
holvi_request["success_url"] = SHOP_CONFIG["success_url"]
holvi_request["failure_url"] = SHOP_CONFIG["failure_url"]
holvi_request["country"] = "Österreich"
uri = URI.parse("** API URL **")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Token #{SHOP_CONFIG["token"]}"
request.body = holvi_request.to_json
response = http.request(request)
return false unless response.code=="201"
JSON.parse(response.body)
end
def self.check_details(details_url)
uri = URI.parse(details_url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Token #{SHOP_CONFIG["token"]}"
response = http.request(request)
return false if response.code!="200"
JSON.parse(response.body)
end
end
@typoworx-de
Copy link

typoworx-de commented Oct 4, 2017

Is this still working?! Holvi Support told me currently they don't have any API implemented?! Is there any reference-contact at holvi.com to ask for it?
Anyone knows a PHP/Composer implementation for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment