Skip to content

Instantly share code, notes, and snippets.

@MohHeader
Created May 23, 2024 08:25
Show Gist options
  • Save MohHeader/ae28e1b221c4715397ecaeb6e8758c0a to your computer and use it in GitHub Desktop.
Save MohHeader/ae28e1b221c4715397ecaeb6e8758c0a to your computer and use it in GitHub Desktop.
iDev integration - Custom Shopping Cart
# Prepare order number
ordernum = "NWHK-#{_data[:hook].id}"
params = {
ip_address: _data[:visitor_ip], # User's IP
idev_saleamt: [_data[:price], _data[:months]*5].max , # Sales Amount
idev_ordernum: ordernum # Order Number
}
# Add Coupone Code if Exist
params[:coupon_code] = _data[:promo_code] if _data[:promo_code]
# Create the Sale using iDev API endpoint
url = URI("https://stars.noorybooks.com/sale.php")
Net::HTTP.post_form(url, params)
sleep 0.5
approve_params = {
secret: AppConfig.idev['api_secret'],
order_number: ordernum
}
# Approve the comission using iDev API endpoint
approve_url = URI("https://stars.noorybooks.com/API/scripts/approve_commission.php")
Net::HTTP.post_form(approve_url, approve_params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment