Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A Ruby library to get user's purchasing power parity based on there geo location.

License

Notifications You must be signed in to change notification settings

warunacds/geo_ppp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Geo Purchasing Power Parity

Sell your digital products at purchasing power parity for based on users country. Not everyone is able to pay for the default pricing of the high income world. Cup of Coffee in Colombia or Indonesia cost less than USA or Australia, apply same principal to your digital products and get more customers. This package is inspired by purchasing-power-parity npm and uses their API.

Installation

Add this line to your application's Gemfile

gem 'geo_ppp'

and run bundle

bundle install

If bundler is not being used to manage dependencies, install the gem by executing:

gem install geo_pp

Usage

GeoPPPFetcher.fetch

will get the purchasing power parity data based on user's IP address.

GeoPPPFetcher.fetch('LK')

will get the purchasing power parity data based on country code provided.

Both above will return a following json structure, you could use pppConversionFactor to convert it price based on user's geographic location

{"countryCodeIsoAlpha2":"LK","countryCodeIsoAlpha3":"LKA","currenciesCountry":{"LKR":{"symbol":"Rs  රු","name":"Sri Lankan rupee"}},"currencyMain":{"exchangeRate":300.701498,"name":"USD","symbol":"$"},"ppp":10040.0,"pppConversionFactor":0.33}
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

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/geo_ppp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the geo_ppp project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

A Ruby library to get user's purchasing power parity based on there geo location.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published