Created
August 30, 2016 12:46
-
-
Save deftOfCenter/02c002b7ef0eda635c9499b9683cd66f to your computer and use it in GitHub Desktop.
Cartstack Notification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def notify_cartstack | |
require 'httpclient' | |
key = ENV["CARTSTACK_KEY"] | |
siteid = ENV["CARTSTACK_SITEID"] | |
url = URI.parse("https://api.cartstack.com/ss/v1/?key=#{key}&siteid=#{siteid}&email=#{email}&total=#{total}") | |
client = HTTPClient.new | |
res = client.request 'GET', url | |
body = JSON.parse(res.body) | |
resp_code = body["resp"] | |
if resp_code && resp_code == "100" | |
logger.info ("Cartstack Order processed notification success.") | |
else | |
logger.error ("Cartstack error. Code #{resp_code}. Watch out!") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment