Skip to content

Instantly share code, notes, and snippets.

@timm-oh
Last active January 13, 2021 04:52
Show Gist options
  • Save timm-oh/65ea658accd8e923e90a5ccc99b70411 to your computer and use it in GitHub Desktop.
Save timm-oh/65ea658accd8e923e90a5ccc99b70411 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, # this is R1000, not working well for floats though
'TransactionReference': 'SOME_TEST', # your internal reference to match against
'BankReference': "Nice Reference", # the reference that the customer will see on their bank statement
'Optional1': nil,
'Optional2': nil,
'Optional3': nil,
'Optional4': nil,
'Optional5': nil,
'Customer': nil,
'CancelUrl': 'https://www.example.com/webhooks/ozow/success',
'ErrorUrl': 'https://www.example.com/webhooks/ozow/error',
'SuccessUrl': 'https://www.example.com/webhooks/ozow/success',
'NotifyUrl': 'https://www.example.com/webhooks/ozow/notify' # needs to be an endpoint that accepts a POST request
"IsTest": true, # pretty self explanatory
}
ozow_params = ozow_params.compact_blank
string = ozow_params.values.join('').downcase + "SOME_SECRET_KEY" # you'll find this here: https://dash.ozow.com/MerchantAdmin/Merchant/Details (Private Key)
ozow_params[:HashCheck] = Digest::SHA512.hexdigest(string)
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(base_url, 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