Skip to content

Instantly share code, notes, and snippets.

@frank-who
Forked from timm-oh/snippet.rb
Created January 6, 2021 14:57
Show Gist options
  • Save frank-who/1baf4be3739ce1dc507376525d60bc4f to your computer and use it in GitHub Desktop.
Save frank-who/1baf4be3739ce1dc507376525d60bc4f to your computer and use it in GitHub Desktop.
Ozow integration
# refer to https://ozow.com/integrations/ for more information
# Ordering with the params matters, see the link above for more information
ozow_params = {
'SiteCode': 'SOME_SITE_CODE', # find this here https://dash.ozow.com/MerchantAdmin/Site
'CountryCode': 'ZA', # only supports ZA currently
'CurrencyCode': 'ZAR', # only supports ZAR currently
'Amount': 1000.00, # this is R1000.00
'TransactionReference': 'SOME_TEST', # your internal reference to match against
'BankReference': "Nice Reference", # the reference that the customer will see on their bank statement
"IsTest": true, # pretty self explanatory
}
# I used #tap because reasons, you're more than welcome to tweak this
ozow_params.tap do |params|
super_secret_key = "SOME_SECRET_KEY" # you'll find this here: https://dash.ozow.com/MerchantAdmin/Merchant/Details (Private Key)
string = params.values.join('').downcase + super_secret_key
params[:HashCheck] = Digest::SHA512.hexdigest(string)
end
base_url = 'https://pay.ozow.com'
# response should be a redirect (302) to a url that looks something like this: :uuid/Secure
response = HTTP.post('https://pay.ozow.com', params: ozow_params)
# https://pay.ozow.com/:uuid/Secure
payment_url = base_url + response.headers['Location']
# you can either load payment_url into an iframe tag, or redirect to that page. Freedom of choice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment