Logo

dev-resources.site

for different kinds of informations.

Ruby on Rails - Calculating pricing based user's purchasing power parity

Published at
1/10/2025
Categories
rails
ruby
Author
waruna
Categories
2 categories in total
rails
open
ruby
open
Author
6 person written this
waruna
open
Ruby on Rails - Calculating pricing based user's purchasing power parity

Recently, I published a simple ruby gem for calculating pricing for digital products based on the user's purchasing power parity.

Not everyone can afford the default pricing of the high-income world. A cup of Coffee in India or Argentina costs less than in the USA or Singapore. Therefore, I wanted to apply the same principle to a digital product I'm building. I couldn't find an easy way to calculate this with Ruby. Looking around, I got inspired by an NPM package called purchasing-power-parity npm and created a similar library using Ruby.

If you would like to take a look at the source code or would like to contribute here in the link to Github repo.

https://github.com/warunacds/geo_ppp

Library is pretty simple to use. Add this line to your application's Gemfile like any other library

gem 'geo_ppp'
Enter fullscreen mode Exit fullscreen mode

and run bundle

bundle install
Enter fullscreen mode Exit fullscreen mode

now you can call it anywhere you like and it would look like this.

def index
  original_price = 79.99

  begin
    response = GeoPPPFetcher.fetch
     discounted_price = original_price * response['pppConversionFactor']
     data = { original_price: original_price, discounted_price: discounted_price }
     render json: { success: true, data: data }
  rescue StandardError => e
    render json: { success: false, error: e.message }, status: :unprocessable_entity
  end
end
Enter fullscreen mode Exit fullscreen mode

That pretty much it for now. If you like this project or find it useful don't forget to give a star on github.

ruby Article's
30 articles in total
Favicon
Ruby on Rails 8 API not allowing mobile phone connection
Favicon
ruby -run
Favicon
ruby -run, again
Favicon
Ruby on Rails: Your Service Layer is a Lie
Favicon
Die Ruby-Seite von Puppet - Teil 2 - Benutzerdefinierte Funktionen
Favicon
The Ruby side of Puppet - Part 2 - Custom Functions
Favicon
Introducing Ephem
Favicon
What Is It (in Ruby 3.4)?
Favicon
Unable to find Ruby class that definitely exists
Favicon
Devise not accepting JSON Token
Favicon
Ruby on Rails - Calculating pricing based user's purchasing power parity
Favicon
Ruby on Rails 8 - Frontend Rรกpido Usando Tailwind como um Frameworks CSS Classless
Favicon
Use cases for Turbo's Custom Events
Favicon
Meta programming with Ruby Eval: A guide (Part 1)
Favicon
Tracing a method call in Ruby
Favicon
False positives of Lint/Void in assignments
Favicon
Die Ruby-Seite von Puppet - Teil 1 - Benutzerdefinierte Fakten
Favicon
Just committed to learning ruby for sonic pi and rails https://dev.to/highcenburg/2025-roadmap-mastering-ruby-for-sonic-pi-and-rails-696 wish me luck!
Favicon
Building a GitHub Activity CLI - A Ruby Journey
Favicon
I have been thinking of moving forward from Python to Ruby to align my skills with my musicality since I like to learn SonicPi.. But I'm still thinking about it so yeah
Favicon
Task Tracker CLI
Favicon
Rails 8 CRUD: Modern Development Guide 2025
Favicon
When Controllers Take on Too Much Responsibility
Favicon
Ruby on Rails 8 - Frontend Rรกpido com Frameworks CSS Classless ou Class-Light sem CDN
Favicon
Cdg Hoodie or Eric Emanuel Hoodie: The Trend You Need Now
Favicon
Brakeman LSP Support
Favicon
Docker in development: Episode 3
Favicon
Add Invite to Rails 8 Authentication
Favicon
How to Develop an Air Quality Monitoring App with Ruby on Rails
Favicon
School

Featured ones: